summaryrefslogtreecommitdiffstats
path: root/llvm/test/Transforms
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2014-07-04 12:36:05 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2014-07-04 12:36:05 +0000
commit3c5b12623952a50d25b9ab9fe14ab5c59bb7b35b (patch)
tree6cad158d900c3f160b05054d9305dcd6a90f60d5 /llvm/test/Transforms
parent778c029e040ea5afadebeb6403ec9088544bbb10 (diff)
downloadbcm5719-llvm-3c5b12623952a50d25b9ab9fe14ab5c59bb7b35b.tar.gz
bcm5719-llvm-3c5b12623952a50d25b9ab9fe14ab5c59bb7b35b.zip
GlobalDCE: Delete available_externally initializers if it allows removing the value the initializer is referring to.
This is useful for functions that are not actually available externally but referenced by a vtable of some kind. Clang emits functions like this for the MS ABI. PR20182. llvm-svn: 212337
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r--llvm/test/Transforms/GlobalDCE/externally_available.ll35
1 files changed, 34 insertions, 1 deletions
diff --git a/llvm/test/Transforms/GlobalDCE/externally_available.ll b/llvm/test/Transforms/GlobalDCE/externally_available.ll
index cc88cb10dcc..3dbada841f9 100644
--- a/llvm/test/Transforms/GlobalDCE/externally_available.ll
+++ b/llvm/test/Transforms/GlobalDCE/externally_available.ll
@@ -1,10 +1,43 @@
-; RUN: opt < %s -globaldce -S | not grep test_
+; RUN: opt < %s -globaldce -S | FileCheck %s
; test_function should not be emitted to the .s file.
+; CHECK-NOT: @test_function
define available_externally i32 @test_function() {
ret i32 4
}
; test_global should not be emitted to the .s file.
+; CHECK-NOT: @test_global
@test_global = available_externally global i32 4
+; CHECK: @x = external constant void ()*
+@x = available_externally constant void()* @f
+; CHECK: @y = external constant i32
+@y = available_externally constant i32 ptrtoint (void()* @g to i32)
+; @h is still alive, so don't remove the initializer too eagerly.
+; CHECK: @z = available_externally constant i8 ptrtoint (void (i8)* @h to i8)
+@z = available_externally constant i8 ptrtoint (void(i8)* @h to i8)
+
+; CHECK-NOT: @f
+define linkonce_odr void @f() {
+ ret void
+}
+
+; CHECK-NOT: @g
+define linkonce_odr void @g() {
+ ret void
+}
+
+; CHECK: define linkonce_odr void @h
+define linkonce_odr void @h(i8) {
+ ret void
+}
+
+define i32 @main() {
+ %f = load void()** @x
+ call void %f()
+ %g = load i32* @y
+ %h = load i8* @z
+ call void @h(i8 %h)
+ ret i32 %g
+}
OpenPOWER on IntegriCloud