diff options
author | Nick Lewycky <nicholas@mxc.ca> | 2012-07-19 22:35:28 +0000 |
---|---|---|
committer | Nick Lewycky <nicholas@mxc.ca> | 2012-07-19 22:35:28 +0000 |
commit | 39e357fafe074babbd9661f3e78239f5ebe7c429 (patch) | |
tree | 98140fd0d928eb480e01756a415c151ced01607f /test/Transforms/GlobalOpt | |
parent | 7f5714f4392590e5a97113a18e1a4e9ad0315571 (diff) |
Don't wipe out global variables that are probably storing pointers to heap
memory. This makes clang play nice with leak checkers.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@160529 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/GlobalOpt')
-rw-r--r-- | test/Transforms/GlobalOpt/2009-11-16-BrokenPerformHeapAllocSRoA.ll | 2 | ||||
-rw-r--r-- | test/Transforms/GlobalOpt/cleanup-pointer-root-users.ll | 20 |
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 +} + |