[gold] Add case being tested by equivalent lld test
authorTeresa Johnson <tejohnson@google.com>
Sun, 14 Feb 2021 01:09:56 +0000 (17:09 -0800)
committerTeresa Johnson <tejohnson@google.com>
Sun, 14 Feb 2021 01:09:56 +0000 (17:09 -0800)
The new tests added by 1487747e990ce9f8851f3d92c3006a74134d7518 for lld
and gold plugin were largely equivalent, but the gold one was missing
one of the cases added to lld. Add that test to the gold plugin version.

llvm/test/tools/gold/X86/devirt_vcall_vis_export_dynamic.ll

index 2785b93..0a374a6 100644 (file)
@@ -1,4 +1,4 @@
-;; Test that --export-dynamic prevents devirtualization.
+;; Test that dynamically exported symbols prevent devirtualization.
 ;; Note that --export-dynamic-symbol and --dynamic-list are tested similarly
 ;; in the v1.16 directory, because those were not properly passed down to the
 ;; plugin until then.
 ; RUN:   --export-dynamic 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
 ; RUN: llvm-dis %t3.0.4.opt.bc -o - | FileCheck %s --check-prefix=CHECK-NODEVIRT-IR
 
+;; Check that all WPD fails with when linking against a shared library containing
+;; preemptible versions of the vtables. In this case the symbols in the object being
+;; linked against the shared library must be exported to .dynsym to allow the runtime
+;; preemption, even without any options.
+
+;; Index based WPD
+; RUN: opt -relocation-model=pic --thinlto-bc -o %t5.o %s
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:          %t5.o -o %t5.so -shared
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:   --plugin-opt=whole-program-visibility \
+; RUN:   --plugin-opt=-pass-remarks=. \
+; RUN:   %t5.o %t5.so -o %t5 \
+; RUN:   --export-dynamic 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
+
+;; Hybrid WPD
+; RUN: opt -relocation-model=pic --thinlto-bc --thinlto-split-lto-unit -o %t5.o %s
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:          %t5.o -o %t5.so -shared
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:   --plugin-opt=whole-program-visibility \
+; RUN:   --plugin-opt=-pass-remarks=. \
+; RUN:   %t5.o %t5.so -o %t5 \
+; RUN:   --export-dynamic 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
+
+;; Regular LTO WPD
+; RUN: opt -relocation-model=pic -o %t5.o %s
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:          %t5.o -o %t5.so -shared
+; RUN: %gold -m elf_x86_64 -plugin %llvmshlibdir/LLVMgold%shlibext \
+; RUN:   --plugin-opt=whole-program-visibility \
+; RUN:   --plugin-opt=-pass-remarks=. \
+; RUN:   %t5.o %t5.so -o %t5 \
+; RUN:   --export-dynamic 2>&1 | FileCheck /dev/null --implicit-check-not single-impl --allow-empty
+
 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
 target triple = "x86_64-grtev4-linux-gnu"