summaryrefslogtreecommitdiff
path: root/test/Transforms/GlobalOpt
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-07-21 08:29:45 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-07-21 08:29:45 +0000
commit61e2ff8f821beec2eefdbb21a5954f74b1c0a295 (patch)
tree83622d2e1b9b9d0f8f9ad3217d8889147a7dafff /test/Transforms/GlobalOpt
parent60287963c7505180500d63b1c1b90f0f4b337430 (diff)
downloadllvm-61e2ff8f821beec2eefdbb21a5954f74b1c0a295.tar.gz
llvm-61e2ff8f821beec2eefdbb21a5954f74b1c0a295.tar.bz2
llvm-61e2ff8f821beec2eefdbb21a5954f74b1c0a295.tar.xz
Teach globalopt to play nice with leak checkers. This is a reapplication of
r160529 that was subsequently reverted. The fix was to not call GV->eraseFromParent() right before the caller does the same. The existing testcases already caught this bug if run under valgrind. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160602 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GlobalOpt')
-rw-r--r--test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll2
-rw-r--r--test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll20
2 files changed, 21 insertions, 1 deletions
diff --git a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
index 54e8f90979..40862bd038 100644
--- a/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
+++ b/test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll
@@ -17,7 +17,7 @@ define void @test() nounwind ssp {
%2 = sext i32 %1 to i64 ; <i64> [#uses=1]
%3 = mul i64 %2, ptrtoint (%struct.strchartype* getelementptr (%struct.strchartype* null, i64 1) to i64) ; <i64> [#uses=1]
%4 = tail call i8* @malloc(i64 %3) ; <i8*> [#uses=1]
-; CHECK: call i8* @malloc(i64
+; CHECK-NOT: call i8* @malloc(i64
%5 = bitcast i8* %4 to %struct.strchartype* ; <%struct.strchartype*> [#uses=1]
store %struct.strchartype* %5, %struct.strchartype** @chartypes, align 8
ret void
diff --git a/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll
new file mode 100644
index 0000000000..0d5cbf5333
--- /dev/null
+++ b/test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll
@@ -0,0 +1,20 @@
+; RUN: opt -globalopt -S -o - < %s | FileCheck %s
+
+@test1 = internal global i8* null
+
+define void @test1a() {
+; CHECK: @test1a
+; CHECK-NOT: store
+; CHECK-NEXT: ret void
+ store i8* null, i8** @test1
+ ret void
+}
+
+define void @test1b(i8* %p) {
+; CHECK: @test1b
+; CHECK-NEXT: store
+; CHECK-NEXT: ret void
+ store i8* %p, i8** @test1
+ ret void
+}
+