[llvm-commits] [poolalloc] r107705 - in /poolalloc/trunk/test/dsa/local: ./ malloc.ll

Will Dietz wdietz2 at illinois.edu
Tue Jul 6 14:39:30 PDT 2010


Author: wdietz2
Date: Tue Jul  6 16:39:30 2010
New Revision: 107705

URL: http://llvm.org/viewvc/llvm-project?rev=107705&view=rev
Log:
Added test to verify DSA detects 'malloc' as a heap allocator.

Added:
    poolalloc/trunk/test/dsa/local/
    poolalloc/trunk/test/dsa/local/malloc.ll

Added: poolalloc/trunk/test/dsa/local/malloc.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/malloc.ll?rev=107705&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/malloc.ll (added)
+++ poolalloc/trunk/test/dsa/local/malloc.ll Tue Jul  6 16:39:30 2010
@@ -0,0 +1,35 @@
+;--check that local detects call to malloc properly (marks them heap)
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-node-for-value "main:b:0" -print-only-flags | grep "H"
+;--check that local has b pointing to node containing c and d
+;RUN: dsaopt %s -dsa-local -analyze -dstest -print-node-for-value "main:b:0" -print-only-values | grep "^c,d$"
+;--check that td/bu don't mark such nodes as incomplete
+;RUN: dsaopt %s -dsa-td -analyze -dstest -print-node-for-value "main:c" -print-only-flags | not grep "I"
+;RUN: dsaopt %s -dsa-bu -analyze -dstest -print-node-for-value "main:c" -print-only-flags | not grep "I"
+
+; ModuleID = 'malloc_free.ll'
+target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
+target triple = "x86_64-unknown-linux-gnu"
+
+define i32 @main() nounwind {
+entry:
+  %retval = alloca i32                            ; <i32*> [#uses=2]
+  %a = alloca i32                                 ; <i32*> [#uses=2]
+  %b = alloca i8*                                 ; <i8**> [#uses=2]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %c = call noalias i8* @malloc(i64 100) nounwind ; <i8*> [#uses=1]
+  store i8* %c, i8** %b, align 8
+  %d = load i8** %b, align 8                      ; <i8*> [#uses=1]
+  call void @free(i8* %d) nounwind
+  store i32 0, i32* %a, align 4
+  %e = load i32* %a, align 4                      ; <i32> [#uses=1]
+  store i32 %e, i32* %retval, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  %retval1 = load i32* %retval                    ; <i32> [#uses=1]
+  ret i32 %retval1
+}
+
+declare noalias i8* @malloc(i64) nounwind
+
+declare void @free(i8*) nounwind





More information about the llvm-commits mailing list