[llvm-commits] [poolalloc] r114552 - in /poolalloc/trunk/test/dsa/local: extern.ll extern2.ll extern3.ll
Will Dietz
wdietz2 at illinois.edu
Wed Sep 22 10:05:47 PDT 2010
Author: wdietz2
Date: Wed Sep 22 12:05:47 2010
New Revision: 114552
URL: http://llvm.org/viewvc/llvm-project?rev=114552&view=rev
Log:
Added various tests regarding incompleteness due to exposure to external code.
Added:
poolalloc/trunk/test/dsa/local/extern.ll
poolalloc/trunk/test/dsa/local/extern2.ll
poolalloc/trunk/test/dsa/local/extern3.ll
Added: poolalloc/trunk/test/dsa/local/extern.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern.ll?rev=114552&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern.ll (added)
+++ poolalloc/trunk/test/dsa/local/extern.ll Wed Sep 22 12:05:47 2010
@@ -0,0 +1,63 @@
+;Test that pointers from external functions are marked incomplete properly
+;Tests on all the DSA passes for three simple cases:
+;--calling an allocator wrapper (shouldn't be incomplete in interprocedural)
+;--calling a undefined (external) function. Should be incomplete at least
+; once the interprocedural passes run.
+;--calling a function that calls an undefined (external) function.
+; Should be incomplete, tests very basic tracking.
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:ptrViaExtern+I"
+
+;RUN: dsaopt %s -dsa-bu -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-bu -analyze -verify-flags "main:ptr-I"
+;RUN: dsaopt %s -dsa-bu -analyze -verify-flags "main:ptrViaExtern+I"
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "main:ptr-I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "main:ptrViaExtern+I"
+
+;RUN: dsaopt %s -dsa-cbu -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-cbu -analyze -verify-flags "main:ptr-I"
+;RUN: dsaopt %s -dsa-cbu -analyze -verify-flags "main:ptrViaExtern+I"
+
+;RUN: dsaopt %s -dsa-eq -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-eq -analyze -verify-flags "main:ptr-I"
+;RUN: dsaopt %s -dsa-eq -analyze -verify-flags "main:ptrViaExtern+I"
+
+;RUN: dsaopt %s -dsa-eqtd -analyze -verify-flags "main:ptrExtern+I"
+;RUN: dsaopt %s -dsa-eqtd -analyze -verify-flags "main:ptr-I"
+;RUN: dsaopt %s -dsa-eqtd -analyze -verify-flags "main:ptrViaExtern+I"
+
+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* @getPointerViaExtern() nounwind {
+entry:
+ %0 = tail call i32* (...)* @getPointerExtern() nounwind ; <i32*> [#uses=1]
+ ret i32* %0
+}
+
+declare i32* @getPointerExtern(...)
+
+define noalias i32* @getPointer() nounwind {
+entry:
+ %0 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %1 = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ ret i32* %1
+}
+
+declare noalias i8* @malloc(i64) nounwind
+
+define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
+entry:
+ %ptr = tail call i32* ()* @getPointer() nounwind
+ %ptrExtern = tail call i32* (...)* @getPointerExtern() nounwind
+ %ptrViaExtern = tail call i32* ()* @getPointerViaExtern() nounwind
+ %val1 = load i32* %ptr, align 4
+ %val2 = load i32* %ptrExtern, align 4
+ %val3 = load i32* %ptrViaExtern, align 4
+ %sum_partial = add i32 %val1, %val2
+ %sum = add i32 %sum_partial, %val3
+ ret i32 %sum
+}
Added: poolalloc/trunk/test/dsa/local/extern2.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern2.ll?rev=114552&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern2.ll (added)
+++ poolalloc/trunk/test/dsa/local/extern2.ll Wed Sep 22 12:05:47 2010
@@ -0,0 +1,38 @@
+;Here we get a pointer from an external function and pass it to a callee.
+;We then test that the flags on that pointer are set appropriately.
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "takesPointer:ptr+I"
+
+;RUN: dsaopt %s -dsa-bu -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-bu -analyze -verify-flags "takesPointer:ptr+I"
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "takesPointer:ptr+I"
+
+;RUN: dsaopt %s -dsa-cbu -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-cbu -analyze -verify-flags "takesPointer:ptr+I"
+
+;RUN: dsaopt %s -dsa-eq -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-eq -analyze -verify-flags "takesPointer:ptr+I"
+
+;RUN: dsaopt %s -dsa-eqtd -analyze -verify-flags "main:ptr+I"
+;RUN: dsaopt %s -dsa-eqtd -analyze -verify-flags "takesPointer:ptr+I"
+
+
+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 @takesPointer(i32* nocapture %ptr) nounwind readonly {
+entry:
+ %0 = load i32* %ptr, align 4 ; <i32> [#uses=1]
+ ret i32 %0
+}
+
+define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
+entry:
+ %ptr = tail call i32* (...)* @getPointerExtern() nounwind
+ %0 = tail call i32 @takesPointer(i32* %ptr) nounwind
+ ret i32 %0
+}
+
+declare i32* @getPointerExtern(...)
Added: poolalloc/trunk/test/dsa/local/extern3.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern3.ll?rev=114552&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern3.ll (added)
+++ poolalloc/trunk/test/dsa/local/extern3.ll Wed Sep 22 12:05:47 2010
@@ -0,0 +1,88 @@
+; ModuleID = 'extern.c'
+;This tests the various cases that could involve incompleteness due
+;to external code, and additionally verifies these flags are NOT set
+;on internal functions.
+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"
+
+declare i32* @getPointerExtern()
+declare void @takesPointerExtern(i32*)
+declare noalias i8* @malloc(i64) nounwind
+declare void @free(i8*) nounwind
+
+;This should be marked incomplete and external due to the
+;unification-based nature of DSA.
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "getPointer:ptr+I"
+define i32* @getPointer() nounwind {
+entry:
+ %0 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %ptr = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ ret i32* %ptr
+}
+
+;This should be marked incomplete and external due to the
+;unification-based nature of DSA.
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "takesPointer:ptr+I"
+define i32 @takesPointer(i32* %ptr) nounwind {
+entry:
+ %0 = load i32* %ptr, align 4 ; <i32> [#uses=1]
+ ret i32 %0
+}
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "getPointerInternal:ptr-I"
+define internal i32* @getPointerInternal() nounwind {
+entry:
+ %0 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=1]
+ %ptr = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ ret i32* %ptr
+}
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "takesPointerInternal:ptr-I"
+define internal i32 @takesPointerInternal(i32* %ptr) nounwind {
+entry:
+ %0 = load i32* %ptr, align 4 ; <i32> [#uses=1]
+ ret i32 %0
+}
+
+define i32 @main(i32 %argc, i8** %argv) nounwind {
+entry:
+ call void @checkExterns() nounwind
+ call void @checkExternals() nounwind
+ call void @checkInternals() nounwind
+ ret i32 0
+}
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExterns:get+I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExterns:take+I"
+define void @checkExterns() nounwind {
+ %get = tail call i32* ()* @getPointerExtern() nounwind ; <i32*> [#uses=0]
+ %1 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=2]
+ %take = bitcast i8* %1 to i32* ; <i32*> [#uses=1]
+ tail call void @takesPointerExtern(i32* %take) nounwind
+ tail call void @free(i8* %1) nounwind
+ ret void
+}
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExternals:get+I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExternals:take+I"
+define void @checkExternals() nounwind {
+entry:
+ %get = tail call i32* ()* @getPointer() nounwind ; <i32*> [#uses=0]
+ %0 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=2]
+ %take = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ tail call i32 @takesPointer(i32* %take) nounwind
+ tail call void @free(i8* %0) nounwind
+ ret void
+}
+
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExternals:get-I"
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkExternals:take-I"
+define void @checkInternals() nounwind {
+entry:
+ %get = tail call i32* ()* @getPointerInternal() nounwind ; <i32*> [#uses=0]
+ %0 = tail call noalias i8* @malloc(i64 4) nounwind ; <i8*> [#uses=2]
+ %take = bitcast i8* %0 to i32* ; <i32*> [#uses=1]
+ tail call i32 @takesPointerInternal(i32* %take) nounwind
+ tail call void @free(i8* %0) nounwind
+ ret void
+}
More information about the llvm-commits
mailing list