summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorPeter Collingbourne <peter@pcc.me.uk>2017-11-01 17:58:39 +0000
committerPeter Collingbourne <peter@pcc.me.uk>2017-11-01 17:58:39 +0000
commit9fb6e1a0370eec770aa43bdcd8db0697f0ee128c (patch)
treee4d29581819e789ede99beb600665b302b8d3159 /llvm/test
parent56db9d6bec6eb1c638d37b01c4d6bf0ed696d1eb (diff)
downloadbcm5719-llvm-9fb6e1a0370eec770aa43bdcd8db0697f0ee128c.tar.gz
bcm5719-llvm-9fb6e1a0370eec770aa43bdcd8db0697f0ee128c.zip
LTO: Apply global DCE to ThinLTO modules at LTO opt level 0.
This is necessary because DCE is applied to full LTO modules. Without this change, a reference from a dead ThinLTO global to a dead full LTO global will result in an undefined reference at link time. This problem is only observable when --gc-sections is disabled, or when targeting COFF, as the COFF port of lld requires all symbols to have a definition even if all references are dead (this is consistent with link.exe). This change also adds an EliminateAvailableExternally pass at -O0. This is necessary to handle the situation on Windows where a non-prevailing copy of a linkonce_odr function has an SEH filter function; any such filters must be DCE'd because they will contain a call to the llvm.localrecover intrinsic, passing as an argument the address of the function that the filter belongs to, and llvm.localrecover requires this function to be defined locally. Fixes PR35142. Differential Revision: https://reviews.llvm.org/D39484 llvm-svn: 317108
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll8
-rw-r--r--llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll10
2 files changed, 17 insertions, 1 deletions
diff --git a/llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll b/llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll
index 66754889f8b..cc508924c67 100644
--- a/llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll
+++ b/llvm/test/LTO/Resolution/X86/Inputs/dead-strip-fulllto.ll
@@ -14,3 +14,11 @@ define void @dead1() {
}
declare void @dead2()
+
+define linkonce_odr i8* @odr() {
+ ret i8* bitcast (void ()* @dead3 to i8*)
+}
+
+define internal void @dead3() {
+ ret void
+}
diff --git a/llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll b/llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
index a9be2751c81..02b0e38fb9b 100644
--- a/llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
+++ b/llvm/test/LTO/Resolution/X86/dead-strip-fulllto.ll
@@ -1,11 +1,18 @@
; RUN: opt -module-summary -o %t %s
; RUN: opt -module-summary -o %t2 %S/Inputs/dead-strip-fulllto.ll
+
; RUN: llvm-lto2 run %t -r %t,main,px -r %t,live1,p -r %t,live2,p -r %t,dead2,p \
-; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, \
+; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, -r %t2,odr, \
; RUN: -save-temps -o %t3
; RUN: llvm-nm %t3.0 | FileCheck --check-prefix=FULL %s
; RUN: llvm-nm %t3.1 | FileCheck --check-prefix=THIN %s
+; RUN: llvm-lto2 run %t -r %t,main,px -r %t,live1,p -r %t,live2,p -r %t,dead2,p \
+; RUN: %t2 -r %t2,live1,p -r %t2,live2, -r %t2,dead1,p -r %t2,dead2, -r %t2,odr, \
+; RUN: -save-temps -o %t3 -O0
+; RUN: llvm-nm %t3.0 | FileCheck --check-prefix=FULL %s
+; RUN: llvm-nm %t3.1 | FileCheck --check-prefix=THIN %s
+
; FULL-NOT: dead
; FULL: U live1
; FULL: T live2
@@ -14,6 +21,7 @@
; THIN-NOT: dead
; THIN: T live1
; THIN: U live2
+; THIN-NOT: odr
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
OpenPOWER on IntegriCloud