[llvm-commits] [poolalloc] r114635 - in /poolalloc/trunk/test/dsa: local/extern.ll local/extern2.ll local/extern3.ll td/extern.ll td/extern2.ll td/extern3.ll td/extern_global.ll

Will Dietz wdietz2 at illinois.edu
Thu Sep 23 01:32:14 PDT 2010


Author: wdietz2
Date: Thu Sep 23 03:32:14 2010
New Revision: 114635

URL: http://llvm.org/viewvc/llvm-project?rev=114635&view=rev
Log:
Added test case for external (and non-external) globals and their completeness.
Also moved extern*.ll tests to test/dsa/td since they're not 'local' tests.

Added:
    poolalloc/trunk/test/dsa/td/extern.ll
      - copied unchanged from r114626, poolalloc/trunk/test/dsa/local/extern.ll
    poolalloc/trunk/test/dsa/td/extern2.ll
      - copied unchanged from r114626, poolalloc/trunk/test/dsa/local/extern2.ll
    poolalloc/trunk/test/dsa/td/extern3.ll
      - copied unchanged from r114626, poolalloc/trunk/test/dsa/local/extern3.ll
    poolalloc/trunk/test/dsa/td/extern_global.ll
Removed:
    poolalloc/trunk/test/dsa/local/extern.ll
    poolalloc/trunk/test/dsa/local/extern2.ll
    poolalloc/trunk/test/dsa/local/extern3.ll

Removed: poolalloc/trunk/test/dsa/local/extern.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern.ll?rev=114634&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern.ll (original)
+++ poolalloc/trunk/test/dsa/local/extern.ll (removed)
@@ -1,63 +0,0 @@
-;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 internal 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
-}

Removed: poolalloc/trunk/test/dsa/local/extern2.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern2.ll?rev=114634&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern2.ll (original)
+++ poolalloc/trunk/test/dsa/local/extern2.ll (removed)
@@ -1,38 +0,0 @@
-;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(...)

Removed: poolalloc/trunk/test/dsa/local/extern3.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/extern3.ll?rev=114634&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/extern3.ll (original)
+++ poolalloc/trunk/test/dsa/local/extern3.ll (removed)
@@ -1,88 +0,0 @@
-; 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 "checkInternals:get-I"
-;RUN: dsaopt %s -dsa-td -analyze -verify-flags "checkInternals: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
-}

Added: poolalloc/trunk/test/dsa/td/extern_global.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/td/extern_global.ll?rev=114635&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/td/extern_global.ll (added)
+++ poolalloc/trunk/test/dsa/td/extern_global.ll Thu Sep 23 03:32:14 2010
@@ -0,0 +1,48 @@
+; ModuleID = 'extern_global.c'
+;This tests how DSA handles external globals and their completeness in TD.
+
+; Externally visible globals should be incomplete
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalInt+I
+; Externally visible global and what it points to should be incomplete
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalIntPtr+I
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalIntPtr:0+I
+; Externally visible global and what it points to should be incomplete,
+; this time with a struct and point to some stack memory...
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalStructWithPointers+I
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalStructWithPointers:8+I
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags globalStructWithPointers:8:8+I
+;RUN: dsaopt %s -dsa-td -analyze -check-same-node=globalStructWithPointers:8,globalStructWithPointers:8:8
+; Globals that aren't marked 'external' shouldn't be incomplete
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags normalGlobal-I
+;RUN: dsaopt %s -dsa-td -analyze -verify-flags internalGlobal-I
+; Check some edges of the graph
+;RUN: dsaopt %s -dsa-td -analyze -check-same-node=normalGlobal:0,globalIntPtr
+;RUN: dsaopt %s -dsa-td -analyze -check-same-node=internalGlobal:0,normalGlobal
+
+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"
+
+%struct.myStruct = type { i32, %struct.myStruct* }
+
+ at globalStructWithPointers = external global %struct.myStruct
+ at globalIntPtr = external global i32*
+ at globalInt = external global i32
+ at normalGlobal = global i32** null
+ at internalGlobal = internal global i32*** null
+
+define i32 @main() nounwind {
+entry:
+;Create the struct and initialize it
+  %s = alloca %struct.myStruct, align 8           ; <%struct.myStruct*> [#uses=1]
+  %0 = getelementptr inbounds %struct.myStruct* %s, i32 0, i32 1 ; <%struct.myStruct**> [#uses=1]
+  store %struct.myStruct* %s, %struct.myStruct** %0, align 8
+  %1 = getelementptr inbounds %struct.myStruct* %s, i32 0, i32 0 ; <i32*> [#uses=1]
+  store i32 100, i32* %1, align 8
+;Store the struct into the global
+  store %struct.myStruct* %s, %struct.myStruct** getelementptr inbounds (%struct.myStruct* @globalStructWithPointers, i64 0, i32 1), align 8
+;Play around with the rest of the globals
+  store i32* @globalInt, i32** @globalIntPtr, align 8
+  store i32** @globalIntPtr, i32*** @normalGlobal, align 8
+  store i32*** @normalGlobal, i32**** @internalGlobal, align 8
+  ret i32 undef
+}





More information about the llvm-commits mailing list