[llvm-commits] [poolalloc] r115392 - in /poolalloc/trunk/test/dsa/local: struct2.ll struct3.ll struct4.ll structFirstField.ll

Arushi Aggarwal aggarwa4 at illinois.edu
Fri Oct 1 18:03:40 PDT 2010


Author: aggarwa4
Date: Fri Oct  1 20:03:40 2010
New Revision: 115392

URL: http://llvm.org/viewvc/llvm-project?rev=115392&view=rev
Log:
Some test cases for structs with casts

Added:
    poolalloc/trunk/test/dsa/local/struct2.ll
    poolalloc/trunk/test/dsa/local/struct3.ll
    poolalloc/trunk/test/dsa/local/struct4.ll
    poolalloc/trunk/test/dsa/local/structFirstField.ll

Added: poolalloc/trunk/test/dsa/local/struct2.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/struct2.ll?rev=115392&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/struct2.ll (added)
+++ poolalloc/trunk/test/dsa/local/struct2.ll Fri Oct  1 20:03:40 2010
@@ -0,0 +1,38 @@
+; casting a struct to int
+
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:r,0:i64|i32*::8:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:r:0,main:x
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:x+SUP2-MR"
+;RUN: dsaopt %s -dsa-local -analyze -verify-flags "main:y+S-UP2MR"
+
+; ModuleID = 'struct2.bc'
+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.R = type { i32*, i32* }
+
+define i32 @main() nounwind {
+entry:
+  %retval = alloca i32                            ; <i32*> [#uses=2]
+  %0 = alloca i32                                 ; <i32*> [#uses=2]
+  %d = alloca i64                                 ; <i64*> [#uses=1]
+  %r = alloca %struct.R                           ; <%struct.R*> [#uses=3]
+  %x = alloca i32                                 ; <i32*> [#uses=1]
+  %y = alloca i32                                 ; <i32*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %1 = getelementptr inbounds %struct.R* %r, i32 0, i32 0 ; <i32**> [#uses=1]
+  store i32* %x, i32** %1, align 8
+  %2 = getelementptr inbounds %struct.R* %r, i32 0, i32 1 ; <i32**> [#uses=1]
+  store i32* %y, i32** %2, align 8
+  %r1 = bitcast %struct.R* %r to i64*             ; <i64*> [#uses=1]
+  %3 = load i64* %r1, align 8                     ; <i64> [#uses=1]
+  store i64 %3, i64* %d, align 8
+  store i32 0, i32* %0, align 4
+  %4 = load i32* %0, align 4                      ; <i32> [#uses=1]
+  store i32 %4, i32* %retval, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  %retval3 = load i32* %retval                    ; <i32> [#uses=1]
+  ret i32 %retval3
+}

Added: poolalloc/trunk/test/dsa/local/struct3.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/struct3.ll?rev=115392&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/struct3.ll (added)
+++ poolalloc/trunk/test/dsa/local/struct3.ll Fri Oct  1 20:03:40 2010
@@ -0,0 +1,55 @@
+; example with casts between structs
+
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:r,0:i32*::8:i32*::16:i8*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:s,0:i32*::8:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:p,0:%\struct.T*
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:r,main:p:0
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:r:8,main:y,main:s:8
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:r:0,main:x,main:s:0
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:r:16,main:c
+; ModuleID = 'struct3.bc'
+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.R = type { i32*, i32*, i8* }
+%struct.S = type { i32*, i32*, i32* }
+%struct.T = type { i32*, i32* }
+
+define i32 @main() nounwind {
+entry:
+  %retval = alloca i32                            ; <i32*> [#uses=2]
+  %0 = alloca i32                                 ; <i32*> [#uses=2]
+  %r = alloca %struct.R                           ; <%struct.R*> [#uses=4]
+  %s = alloca %struct.S                           ; <%struct.S*> [#uses=1]
+  %p = alloca %struct.T*                          ; <%struct.T**> [#uses=2]
+  %x = alloca i32                                 ; <i32*> [#uses=1]
+  %y = alloca i32                                 ; <i32*> [#uses=1]
+  %c = alloca i8                                  ; <i8*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %1 = getelementptr inbounds %struct.R* %r, i32 0, i32 0 ; <i32**> [#uses=1]
+  store i32* %x, i32** %1, align 8
+  %2 = getelementptr inbounds %struct.R* %r, i32 0, i32 1 ; <i32**> [#uses=1]
+  store i32* %y, i32** %2, align 8
+  %3 = getelementptr inbounds %struct.R* %r, i32 0, i32 2 ; <i8**> [#uses=1]
+  store i8* %c, i8** %3, align 8
+  %r1 = bitcast %struct.R* %r to %struct.T*       ; <%struct.T*> [#uses=1]
+  store %struct.T* %r1, %struct.T** %p, align 8
+  %s2 = bitcast %struct.S* %s to %struct.T*       ; <%struct.T*> [#uses=2]
+  %4 = load %struct.T** %p, align 8               ; <%struct.T*> [#uses=2]
+  %5 = getelementptr inbounds %struct.T* %4, i32 0, i32 0 ; <i32**> [#uses=1]
+  %6 = getelementptr inbounds %struct.T* %s2, i32 0, i32 0 ; <i32**> [#uses=1]
+  %7 = load i32** %6, align 8                     ; <i32*> [#uses=1]
+  store i32* %7, i32** %5, align 8
+  %8 = getelementptr inbounds %struct.T* %4, i32 0, i32 1 ; <i32**> [#uses=1]
+  %9 = getelementptr inbounds %struct.T* %s2, i32 0, i32 1 ; <i32**> [#uses=1]
+  %10 = load i32** %9, align 8                    ; <i32*> [#uses=1]
+  store i32* %10, i32** %8, align 8
+  store i32 0, i32* %0, align 4
+  %11 = load i32* %0, align 4                     ; <i32> [#uses=1]
+  store i32 %11, i32* %retval, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  %retval4 = load i32* %retval                    ; <i32> [#uses=1]
+  ret i32 %retval4
+}

Added: poolalloc/trunk/test/dsa/local/struct4.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/struct4.ll?rev=115392&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/struct4.ll (added)
+++ poolalloc/trunk/test/dsa/local/struct4.ll Fri Oct  1 20:03:40 2010
@@ -0,0 +1,41 @@
+;accessing 1st field using struct pointer
+
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:r,0:i32|i32*::8:i32*::16:i8*
+
+; ModuleID = 'struct4.bc'
+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.R = type { i32*, i32*, i8* }
+
+define i32 @main() nounwind {
+entry:
+  %retval = alloca i32                            ; <i32*> [#uses=2]
+  %0 = alloca i32                                 ; <i32*> [#uses=2]
+  %r = alloca %struct.R                           ; <%struct.R*> [#uses=4]
+  %x = alloca i32                                 ; <i32*> [#uses=1]
+  %y = alloca i32                                 ; <i32*> [#uses=1]
+  %c = alloca i8                                  ; <i8*> [#uses=1]
+  %p = alloca i32*                                ; <i32**> [#uses=2]
+  %d = alloca i32                                 ; <i32*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %1 = getelementptr inbounds %struct.R* %r, i32 0, i32 0 ; <i32**> [#uses=1]
+  store i32* %x, i32** %1, align 8
+  %2 = getelementptr inbounds %struct.R* %r, i32 0, i32 1 ; <i32**> [#uses=1]
+  store i32* %y, i32** %2, align 8
+  %3 = getelementptr inbounds %struct.R* %r, i32 0, i32 2 ; <i8**> [#uses=1]
+  store i8* %c, i8** %3, align 8
+  %r1 = bitcast %struct.R* %r to i32*             ; <i32*> [#uses=1]
+  store i32* %r1, i32** %p, align 8
+  %4 = load i32** %p, align 8                     ; <i32*> [#uses=1]
+  %5 = load i32* %4, align 4                      ; <i32> [#uses=1]
+  store i32 %5, i32* %d, align 4
+  store i32 0, i32* %0, align 4
+  %6 = load i32* %0, align 4                      ; <i32> [#uses=1]
+  store i32 %6, i32* %retval, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  %retval2 = load i32* %retval                    ; <i32> [#uses=1]
+  ret i32 %retval2
+}

Added: poolalloc/trunk/test/dsa/local/structFirstField.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/local/structFirstField.ll?rev=115392&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/local/structFirstField.ll (added)
+++ poolalloc/trunk/test/dsa/local/structFirstField.ll Fri Oct  1 20:03:40 2010
@@ -0,0 +1,45 @@
+; can use a struct pointer to access the first field of the pointer
+
+
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:p,0:%\struct.S*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:s,0:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:r,0:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=main:q,0:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:p:0,main:s
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=main:s:0,main:x,main:r:0,main:q:0
+
+; ModuleID = 'structFirstField.bc'
+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.S = type { i32* }
+
+define void @main() nounwind {
+entry:
+  %0 = alloca %struct.S                           ; <%struct.S*> [#uses=2]
+  %x = alloca i32                                 ; <i32*> [#uses=1]
+  %q = alloca i32*                                ; <i32**> [#uses=2]
+  %r = alloca i32*                                ; <i32**> [#uses=1]
+  %s = alloca %struct.S                           ; <%struct.S*> [#uses=2]
+  %p = alloca %struct.S*                          ; <%struct.S**> [#uses=2]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  store %struct.S* %s, %struct.S** %p, align 8
+  store i32* %x, i32** %q, align 8
+  %q1 = bitcast i32** %q to %struct.S*            ; <%struct.S*> [#uses=1]
+  %1 = getelementptr inbounds %struct.S* %0, i32 0, i32 0 ; <i32**> [#uses=1]
+  %2 = getelementptr inbounds %struct.S* %q1, i32 0, i32 0 ; <i32**> [#uses=1]
+  %3 = load i32** %2, align 8                     ; <i32*> [#uses=1]
+  store i32* %3, i32** %1, align 8
+  %4 = load %struct.S** %p, align 8               ; <%struct.S*> [#uses=1]
+  %5 = getelementptr inbounds %struct.S* %4, i32 0, i32 0 ; <i32**> [#uses=1]
+  %6 = getelementptr inbounds %struct.S* %0, i32 0, i32 0 ; <i32**> [#uses=1]
+  %7 = load i32** %6, align 8                     ; <i32*> [#uses=1]
+  store i32* %7, i32** %5, align 8
+  %8 = getelementptr inbounds %struct.S* %s, i32 0, i32 0 ; <i32**> [#uses=1]
+  %9 = load i32** %8, align 8                     ; <i32*> [#uses=1]
+  store i32* %9, i32** %r, align 8
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}





More information about the llvm-commits mailing list