[llvm-commits] [poolalloc] r113342 - in /poolalloc/trunk/test/dsa/types: ./ union.c union.ll union1.c union1.ll union2.c union2.ll union3.c union3.ll union4.c union4.ll union_arrays.c union_arrays.ll

Arushi Aggarwal aggarwa4 at illinois.edu
Tue Sep 7 21:09:46 PDT 2010


Author: aggarwa4
Date: Tue Sep  7 23:09:46 2010
New Revision: 113342

URL: http://llvm.org/viewvc/llvm-project?rev=113342&view=rev
Log:
test for types

Added:
    poolalloc/trunk/test/dsa/types/
    poolalloc/trunk/test/dsa/types/union.c
    poolalloc/trunk/test/dsa/types/union.ll
    poolalloc/trunk/test/dsa/types/union1.c
    poolalloc/trunk/test/dsa/types/union1.ll
    poolalloc/trunk/test/dsa/types/union2.c
    poolalloc/trunk/test/dsa/types/union2.ll
    poolalloc/trunk/test/dsa/types/union3.c
    poolalloc/trunk/test/dsa/types/union3.ll
    poolalloc/trunk/test/dsa/types/union4.c
    poolalloc/trunk/test/dsa/types/union4.ll
    poolalloc/trunk/test/dsa/types/union_arrays.c
    poolalloc/trunk/test/dsa/types/union_arrays.ll

Added: poolalloc/trunk/test/dsa/types/union.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union.c (added)
+++ poolalloc/trunk/test/dsa/types/union.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,35 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct StructType {
+
+  float a;
+  int *b;
+};
+union UnionType {
+
+  int a;
+  int *b;
+  int c[100];
+  struct StructType obj;  
+  
+};
+
+void func() {
+
+  int *tmp = (int*) malloc(sizeof(int));
+  union UnionType s1;
+  
+  s1.b = tmp;
+
+  int *c = s1.b;
+  int d = s1.a;
+  int arr = s1.c[0];
+  struct StructType x = s1.obj;
+  float y = x.a;
+}
+

Added: poolalloc/trunk/test/dsa/types/union.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union.ll (added)
+++ poolalloc/trunk/test/dsa/types/union.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,61 @@
+; ModuleID = 'union.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"
+
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:tmp:0,func:c:0,func:s1:0
+;RUN: dsaopt %s -dsa-local -analyze -check-same-node=func:s1:8,func:x:8
+;RUN: dsaopt %s -dsa-local -analyze -check-type=func:s1,0:float|i32|i32*::8:i32*
+;RUN: dsaopt %s -dsa-local -analyze -check-type=func:x,0:float::8:i32*
+
+%struct.StructType = type { float, i32* }
+%union.UnionType = type { %struct.StructType, [96 x i32] }
+
+define void @func() nounwind {
+entry:
+  %tmp = alloca i32*                              ; <i32**> [#uses=2]
+  %s1 = alloca %union.UnionType                   ; <%union.UnionType*> [#uses=5]
+  %c = alloca i32*                                ; <i32**> [#uses=1]
+  %d = alloca i32                                 ; <i32*> [#uses=1]
+  %arr = alloca i32                               ; <i32*> [#uses=1]
+  %x = alloca %struct.StructType                  ; <%struct.StructType*> [#uses=3]
+  %y = alloca float                               ; <float*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %0 = call noalias i8* @malloc(i64 4) nounwind   ; <i8*> [#uses=1]
+  %1 = bitcast i8* %0 to i32*                     ; <i32*> [#uses=1]
+  store i32* %1, i32** %tmp, align 8
+  %2 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %3 = bitcast %struct.StructType* %2 to i32**    ; <i32**> [#uses=1]
+  %4 = load i32** %tmp, align 8                   ; <i32*> [#uses=1]
+  store i32* %4, i32** %3, align 8
+  %5 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %6 = bitcast %struct.StructType* %5 to i32**    ; <i32**> [#uses=1]
+  %7 = load i32** %6, align 8                     ; <i32*> [#uses=1]
+  store i32* %7, i32** %c, align 8
+  %8 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %9 = bitcast %struct.StructType* %8 to i32*     ; <i32*> [#uses=1]
+  %10 = load i32* %9, align 8                     ; <i32> [#uses=1]
+  store i32 %10, i32* %d, align 4
+  %11 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %12 = bitcast %struct.StructType* %11 to [100 x i32]* ; <[100 x i32]*> [#uses=1]
+  %13 = getelementptr inbounds [100 x i32]* %12, i64 0, i64 0 ; <i32*> [#uses=1]
+  %14 = load i32* %13, align 4                    ; <i32> [#uses=1]
+  store i32 %14, i32* %arr, align 4
+  %15 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=2]
+  %16 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; <float*> [#uses=1]
+  %17 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 0 ; <float*> [#uses=1]
+  %18 = load float* %17, align 8                  ; <float> [#uses=1]
+  store float %18, float* %16, align 8
+  %19 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 1 ; <i32**> [#uses=1]
+  %20 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 1 ; <i32**> [#uses=1]
+  %21 = load i32** %20, align 8                   ; <i32*> [#uses=1]
+  store i32* %21, i32** %19, align 8
+  %22 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; <float*> [#uses=1]
+  %23 = load float* %22, align 8                  ; <float> [#uses=1]
+  store float %23, float* %y, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}
+
+declare noalias i8* @malloc(i64) nounwind

Added: poolalloc/trunk/test/dsa/types/union1.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union1.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union1.c (added)
+++ poolalloc/trunk/test/dsa/types/union1.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,41 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct NestedStructType {
+
+  float a1;
+  int *b1;
+};
+struct StructType {
+
+  float a2;
+  int *b2;
+  struct NestedStructType ns2;
+};
+union UnionType {
+
+  int a;
+  int *b;
+  int c[100];
+  struct StructType obj;  
+  
+};
+
+void func() {
+
+  int *tmp = (int*) malloc(sizeof(int));
+  union UnionType s1;
+  
+  s1.b = tmp;
+
+  int *c = s1.b;
+  int d = s1.a;
+  int arr = s1.c[0];
+  struct StructType x = s1.obj;
+  float y = x.a2;
+}
+

Added: poolalloc/trunk/test/dsa/types/union1.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union1.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union1.ll (added)
+++ poolalloc/trunk/test/dsa/types/union1.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,67 @@
+; ModuleID = 'union1.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.NestedStructType = type { float, i32* }
+%struct.StructType = type { float, i32*, %struct.NestedStructType }
+%union.UnionType = type { %struct.StructType, [92 x i32] }
+
+define void @func() nounwind {
+entry:
+  %tmp = alloca i32*                              ; <i32**> [#uses=2]
+  %s1 = alloca %union.UnionType                   ; <%union.UnionType*> [#uses=5]
+  %c = alloca i32*                                ; <i32**> [#uses=1]
+  %d = alloca i32                                 ; <i32*> [#uses=1]
+  %arr = alloca i32                               ; <i32*> [#uses=1]
+  %x = alloca %struct.StructType                  ; <%struct.StructType*> [#uses=4]
+  %y = alloca float                               ; <float*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %0 = call noalias i8* @malloc(i64 4) nounwind   ; <i8*> [#uses=1]
+  %1 = bitcast i8* %0 to i32*                     ; <i32*> [#uses=1]
+  store i32* %1, i32** %tmp, align 8
+  %2 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %3 = bitcast %struct.StructType* %2 to i32**    ; <i32**> [#uses=1]
+  %4 = load i32** %tmp, align 8                   ; <i32*> [#uses=1]
+  store i32* %4, i32** %3, align 8
+  %5 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %6 = bitcast %struct.StructType* %5 to i32**    ; <i32**> [#uses=1]
+  %7 = load i32** %6, align 8                     ; <i32*> [#uses=1]
+  store i32* %7, i32** %c, align 8
+  %8 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %9 = bitcast %struct.StructType* %8 to i32*     ; <i32*> [#uses=1]
+  %10 = load i32* %9, align 8                     ; <i32> [#uses=1]
+  store i32 %10, i32* %d, align 4
+  %11 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=1]
+  %12 = bitcast %struct.StructType* %11 to [100 x i32]* ; <[100 x i32]*> [#uses=1]
+  %13 = getelementptr inbounds [100 x i32]* %12, i64 0, i64 0 ; <i32*> [#uses=1]
+  %14 = load i32* %13, align 4                    ; <i32> [#uses=1]
+  store i32 %14, i32* %arr, align 4
+  %15 = getelementptr inbounds %union.UnionType* %s1, i32 0, i32 0 ; <%struct.StructType*> [#uses=3]
+  %16 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; <float*> [#uses=1]
+  %17 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 0 ; <float*> [#uses=1]
+  %18 = load float* %17, align 8                  ; <float> [#uses=1]
+  store float %18, float* %16, align 8
+  %19 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 1 ; <i32**> [#uses=1]
+  %20 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 1 ; <i32**> [#uses=1]
+  %21 = load i32** %20, align 8                   ; <i32*> [#uses=1]
+  store i32* %21, i32** %19, align 8
+  %22 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 2 ; <%struct.NestedStructType*> [#uses=2]
+  %23 = getelementptr inbounds %struct.StructType* %15, i32 0, i32 2 ; <%struct.NestedStructType*> [#uses=2]
+  %24 = getelementptr inbounds %struct.NestedStructType* %22, i32 0, i32 0 ; <float*> [#uses=1]
+  %25 = getelementptr inbounds %struct.NestedStructType* %23, i32 0, i32 0 ; <float*> [#uses=1]
+  %26 = load float* %25, align 8                  ; <float> [#uses=1]
+  store float %26, float* %24, align 8
+  %27 = getelementptr inbounds %struct.NestedStructType* %22, i32 0, i32 1 ; <i32**> [#uses=1]
+  %28 = getelementptr inbounds %struct.NestedStructType* %23, i32 0, i32 1 ; <i32**> [#uses=1]
+  %29 = load i32** %28, align 8                   ; <i32*> [#uses=1]
+  store i32* %29, i32** %27, align 8
+  %30 = getelementptr inbounds %struct.StructType* %x, i32 0, i32 0 ; <float*> [#uses=1]
+  %31 = load float* %30, align 8                  ; <float> [#uses=1]
+  store float %31, float* %y, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}
+
+declare noalias i8* @malloc(i64) nounwind

Added: poolalloc/trunk/test/dsa/types/union2.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union2.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union2.c (added)
+++ poolalloc/trunk/test/dsa/types/union2.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,39 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct StructType1 {
+
+  int a1;
+  int b1;
+  int c1;
+};
+struct StructType2 {
+
+  int a2;
+  short b2;
+  int c2;
+};
+
+union UnionType {
+  struct StructType1 s1;  
+  struct StructType2 s2;  
+};
+
+void func() {
+
+  union UnionType obj;
+  
+  obj.s1.a1 = 2l;
+  obj.s1.b1 = 33;
+  obj.s1.c1 = 22;
+  
+  struct StructType2 s = obj.s2;
+
+  int t = obj.s2.c2;
+  int t1 = obj.s1.c1;
+}
+

Added: poolalloc/trunk/test/dsa/types/union2.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union2.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union2.ll (added)
+++ poolalloc/trunk/test/dsa/types/union2.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,52 @@
+; ModuleID = 'union2.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.StructType1 = type { i32, i32, i32 }
+%struct.StructType2 = type { i32, i16, i32 }
+%union.UnionType = type { %struct.StructType1 }
+
+define void @func() nounwind {
+entry:
+  %obj = alloca %union.UnionType                  ; <%union.UnionType*> [#uses=6]
+  %s = alloca %struct.StructType2                 ; <%struct.StructType2*> [#uses=3]
+  %t = alloca i32                                 ; <i32*> [#uses=1]
+  %t1 = alloca i32                                ; <i32*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %0 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %1 = getelementptr inbounds %struct.StructType1* %0, i32 0, i32 0 ; <i32*> [#uses=1]
+  store i32 2, i32* %1, align 4
+  %2 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %3 = getelementptr inbounds %struct.StructType1* %2, i32 0, i32 1 ; <i32*> [#uses=1]
+  store i32 33, i32* %3, align 4
+  %4 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %5 = getelementptr inbounds %struct.StructType1* %4, i32 0, i32 2 ; <i32*> [#uses=1]
+  store i32 22, i32* %5, align 4
+  %6 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %7 = bitcast %struct.StructType1* %6 to %struct.StructType2* ; <%struct.StructType2*> [#uses=3]
+  %8 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 0 ; <i32*> [#uses=1]
+  %9 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 0 ; <i32*> [#uses=1]
+  %10 = load i32* %9, align 4                     ; <i32> [#uses=1]
+  store i32 %10, i32* %8, align 4
+  %11 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 1 ; <i16*> [#uses=1]
+  %12 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 1 ; <i16*> [#uses=1]
+  %13 = load i16* %12, align 4                    ; <i16> [#uses=1]
+  store i16 %13, i16* %11, align 4
+  %14 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 2 ; <i32*> [#uses=1]
+  %15 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 2 ; <i32*> [#uses=1]
+  %16 = load i32* %15, align 4                    ; <i32> [#uses=1]
+  store i32 %16, i32* %14, align 4
+  %17 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %18 = bitcast %struct.StructType1* %17 to %struct.StructType2* ; <%struct.StructType2*> [#uses=1]
+  %19 = getelementptr inbounds %struct.StructType2* %18, i32 0, i32 2 ; <i32*> [#uses=1]
+  %20 = load i32* %19, align 4                    ; <i32> [#uses=1]
+  store i32 %20, i32* %t, align 4
+  %21 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %22 = getelementptr inbounds %struct.StructType1* %21, i32 0, i32 2 ; <i32*> [#uses=1]
+  %23 = load i32* %22, align 4                    ; <i32> [#uses=1]
+  store i32 %23, i32* %t1, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}

Added: poolalloc/trunk/test/dsa/types/union3.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union3.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union3.c (added)
+++ poolalloc/trunk/test/dsa/types/union3.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,37 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct StructType1 {
+
+  int a1;
+  int b1;
+  int c1;
+};
+struct StructType2 {
+
+  int a2;
+  short b2;
+  short c3;
+  int c2;
+};
+
+union UnionType {
+  struct StructType1 s1;  
+  struct StructType2 s2;  
+};
+
+void func() {
+
+  union UnionType obj;
+  
+  obj.s1.a1 = 2l;
+  obj.s1.b1 = 33;
+  obj.s1.c1 = 22;
+  
+  struct StructType2 s = obj.s2;
+}
+

Added: poolalloc/trunk/test/dsa/types/union3.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union3.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union3.ll (added)
+++ poolalloc/trunk/test/dsa/types/union3.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,45 @@
+; ModuleID = 'union3.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.StructType1 = type { i32, i32, i32 }
+%struct.StructType2 = type { i32, i16, i16, i32 }
+%union.UnionType = type { %struct.StructType1 }
+
+define void @func() nounwind {
+entry:
+  %obj = alloca %union.UnionType                  ; <%union.UnionType*> [#uses=4]
+  %s = alloca %struct.StructType2                 ; <%struct.StructType2*> [#uses=4]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %0 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %1 = getelementptr inbounds %struct.StructType1* %0, i32 0, i32 0 ; <i32*> [#uses=1]
+  store i32 2, i32* %1, align 4
+  %2 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %3 = getelementptr inbounds %struct.StructType1* %2, i32 0, i32 1 ; <i32*> [#uses=1]
+  store i32 33, i32* %3, align 4
+  %4 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %5 = getelementptr inbounds %struct.StructType1* %4, i32 0, i32 2 ; <i32*> [#uses=1]
+  store i32 22, i32* %5, align 4
+  %6 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %7 = bitcast %struct.StructType1* %6 to %struct.StructType2* ; <%struct.StructType2*> [#uses=4]
+  %8 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 0 ; <i32*> [#uses=1]
+  %9 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 0 ; <i32*> [#uses=1]
+  %10 = load i32* %9, align 4                     ; <i32> [#uses=1]
+  store i32 %10, i32* %8, align 4
+  %11 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 1 ; <i16*> [#uses=1]
+  %12 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 1 ; <i16*> [#uses=1]
+  %13 = load i16* %12, align 4                    ; <i16> [#uses=1]
+  store i16 %13, i16* %11, align 4
+  %14 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 2 ; <i16*> [#uses=1]
+  %15 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 2 ; <i16*> [#uses=1]
+  %16 = load i16* %15, align 2                    ; <i16> [#uses=1]
+  store i16 %16, i16* %14, align 2
+  %17 = getelementptr inbounds %struct.StructType2* %s, i32 0, i32 3 ; <i32*> [#uses=1]
+  %18 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 3 ; <i32*> [#uses=1]
+  %19 = load i32* %18, align 4                    ; <i32> [#uses=1]
+  store i32 %19, i32* %17, align 4
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}

Added: poolalloc/trunk/test/dsa/types/union4.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union4.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union4.c (added)
+++ poolalloc/trunk/test/dsa/types/union4.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,38 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct StructType1 {
+
+  int a1;
+  int b1;
+  int c1;
+};
+struct StructType2 {
+
+  int a2;
+  short b2;
+  short c3;
+  int c2;
+};
+
+union UnionType {
+  struct StructType1 s1;  
+  struct StructType2 s2;  
+};
+
+void func() {
+
+  union UnionType obj;
+  
+  obj.s1.a1 = 2l;
+  obj.s1.b1 = 33;
+  obj.s1.c1 = 22;
+  
+  short x = obj.s2.b2;
+  short y = obj.s2.c3;
+}
+

Added: poolalloc/trunk/test/dsa/types/union4.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union4.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union4.ll (added)
+++ poolalloc/trunk/test/dsa/types/union4.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,38 @@
+; ModuleID = 'union4.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.StructType1 = type { i32, i32, i32 }
+%struct.StructType2 = type { i32, i16, i16, i32 }
+%union.UnionType = type { %struct.StructType1 }
+
+define void @func() nounwind {
+entry:
+  %obj = alloca %union.UnionType                  ; <%union.UnionType*> [#uses=5]
+  %x = alloca i16                                 ; <i16*> [#uses=1]
+  %y = alloca i16                                 ; <i16*> [#uses=1]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  %0 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %1 = getelementptr inbounds %struct.StructType1* %0, i32 0, i32 0 ; <i32*> [#uses=1]
+  store i32 2, i32* %1, align 4
+  %2 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %3 = getelementptr inbounds %struct.StructType1* %2, i32 0, i32 1 ; <i32*> [#uses=1]
+  store i32 33, i32* %3, align 4
+  %4 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %5 = getelementptr inbounds %struct.StructType1* %4, i32 0, i32 2 ; <i32*> [#uses=1]
+  store i32 22, i32* %5, align 4
+  %6 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %7 = bitcast %struct.StructType1* %6 to %struct.StructType2* ; <%struct.StructType2*> [#uses=1]
+  %8 = getelementptr inbounds %struct.StructType2* %7, i32 0, i32 1 ; <i16*> [#uses=1]
+  %9 = load i16* %8, align 4                      ; <i16> [#uses=1]
+  store i16 %9, i16* %x, align 2
+  %10 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType1*> [#uses=1]
+  %11 = bitcast %struct.StructType1* %10 to %struct.StructType2* ; <%struct.StructType2*> [#uses=1]
+  %12 = getelementptr inbounds %struct.StructType2* %11, i32 0, i32 2 ; <i16*> [#uses=1]
+  %13 = load i16* %12, align 2                    ; <i16> [#uses=1]
+  store i16 %13, i16* %y, align 2
+  br label %return
+
+return:                                           ; preds = %entry
+  ret void
+}

Added: poolalloc/trunk/test/dsa/types/union_arrays.c
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union_arrays.c?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union_arrays.c (added)
+++ poolalloc/trunk/test/dsa/types/union_arrays.c Tue Sep  7 23:09:46 2010
@@ -0,0 +1,39 @@
+
+//--Make sure we can run DSA on it! 
+//RUN: llvm-gcc %s -c --emit-llvm -o - |  \
+//RUN: dsaopt -dsa-bu -dsa-td -disable-output
+
+
+#include <stdlib.h>
+struct StructType1 {
+  int a1[10];
+  short b1[10];
+  int c1[10];
+};
+struct StructType2 {
+  int a2[10];
+  int b2[10];
+  int c2[10];
+};
+union UnionType {
+  struct StructType1 s1;  
+  struct StructType2 s2;  
+};
+
+void func() {
+
+  union UnionType obj;
+  union UnionType obj_copy;
+  int i;
+  for(i=0;i<10;i++) {
+    obj.s1.a1[i] = i + 10;
+    obj.s1.b1[i] = i + 32;
+    obj.s1.c1[i] = i + 64;
+  }  
+  for(i=0;i<10;i++) {
+    obj_copy.s2.a2[i] = obj.s1.a1[i];
+    obj_copy.s2.b2[i] = obj.s1.b1[i];
+    obj_copy.s2.c2[i] = obj.s1.c1[i];
+  }  
+}
+

Added: poolalloc/trunk/test/dsa/types/union_arrays.ll
URL: http://llvm.org/viewvc/llvm-project/poolalloc/trunk/test/dsa/types/union_arrays.ll?rev=113342&view=auto
==============================================================================
--- poolalloc/trunk/test/dsa/types/union_arrays.ll (added)
+++ poolalloc/trunk/test/dsa/types/union_arrays.ll Tue Sep  7 23:09:46 2010
@@ -0,0 +1,117 @@
+; ModuleID = 'union_arrays.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.StructType1 = type { [10 x i32], [10 x i16], [10 x i32] }
+%struct.StructType2 = type { [10 x i32], [10 x i32], [10 x i32] }
+%union.UnionType = type { %struct.StructType2 }
+
+define void @func() nounwind {
+entry:
+  %obj = alloca %union.UnionType                  ; <%union.UnionType*> [#uses=6]
+  %obj_copy = alloca %union.UnionType             ; <%union.UnionType*> [#uses=3]
+  %i = alloca i32                                 ; <i32*> [#uses=20]
+  %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
+  store i32 0, i32* %i, align 4
+  br label %bb1
+
+bb:                                               ; preds = %bb1
+  %0 = load i32* %i, align 4                      ; <i32> [#uses=1]
+  %1 = load i32* %i, align 4                      ; <i32> [#uses=1]
+  %2 = add nsw i32 %1, 10                         ; <i32> [#uses=1]
+  %3 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %4 = bitcast %struct.StructType2* %3 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %5 = getelementptr inbounds %struct.StructType1* %4, i32 0, i32 0 ; <[10 x i32]*> [#uses=1]
+  %6 = sext i32 %0 to i64                         ; <i64> [#uses=1]
+  %7 = getelementptr inbounds [10 x i32]* %5, i64 0, i64 %6 ; <i32*> [#uses=1]
+  store i32 %2, i32* %7, align 4
+  %8 = load i32* %i, align 4                      ; <i32> [#uses=1]
+  %9 = load i32* %i, align 4                      ; <i32> [#uses=1]
+  %10 = trunc i32 %9 to i16                       ; <i16> [#uses=1]
+  %11 = add i16 %10, 32                           ; <i16> [#uses=1]
+  %12 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %13 = bitcast %struct.StructType2* %12 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %14 = getelementptr inbounds %struct.StructType1* %13, i32 0, i32 1 ; <[10 x i16]*> [#uses=1]
+  %15 = sext i32 %8 to i64                        ; <i64> [#uses=1]
+  %16 = getelementptr inbounds [10 x i16]* %14, i64 0, i64 %15 ; <i16*> [#uses=1]
+  store i16 %11, i16* %16, align 2
+  %17 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %18 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %19 = add nsw i32 %18, 64                       ; <i32> [#uses=1]
+  %20 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %21 = bitcast %struct.StructType2* %20 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %22 = getelementptr inbounds %struct.StructType1* %21, i32 0, i32 2 ; <[10 x i32]*> [#uses=1]
+  %23 = sext i32 %17 to i64                       ; <i64> [#uses=1]
+  %24 = getelementptr inbounds [10 x i32]* %22, i64 0, i64 %23 ; <i32*> [#uses=1]
+  store i32 %19, i32* %24, align 4
+  %25 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %26 = add nsw i32 %25, 1                        ; <i32> [#uses=1]
+  store i32 %26, i32* %i, align 4
+  br label %bb1
+
+bb1:                                              ; preds = %bb, %entry
+  %27 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %28 = icmp sle i32 %27, 9                       ; <i1> [#uses=1]
+  br i1 %28, label %bb, label %bb2
+
+bb2:                                              ; preds = %bb1
+  store i32 0, i32* %i, align 4
+  br label %bb4
+
+bb3:                                              ; preds = %bb4
+  %29 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %30 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %31 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %32 = bitcast %struct.StructType2* %31 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %33 = getelementptr inbounds %struct.StructType1* %32, i32 0, i32 0 ; <[10 x i32]*> [#uses=1]
+  %34 = sext i32 %30 to i64                       ; <i64> [#uses=1]
+  %35 = getelementptr inbounds [10 x i32]* %33, i64 0, i64 %34 ; <i32*> [#uses=1]
+  %36 = load i32* %35, align 4                    ; <i32> [#uses=1]
+  %37 = getelementptr inbounds %union.UnionType* %obj_copy, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %38 = getelementptr inbounds %struct.StructType2* %37, i32 0, i32 0 ; <[10 x i32]*> [#uses=1]
+  %39 = sext i32 %29 to i64                       ; <i64> [#uses=1]
+  %40 = getelementptr inbounds [10 x i32]* %38, i64 0, i64 %39 ; <i32*> [#uses=1]
+  store i32 %36, i32* %40, align 4
+  %41 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %42 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %43 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %44 = bitcast %struct.StructType2* %43 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %45 = getelementptr inbounds %struct.StructType1* %44, i32 0, i32 1 ; <[10 x i16]*> [#uses=1]
+  %46 = sext i32 %42 to i64                       ; <i64> [#uses=1]
+  %47 = getelementptr inbounds [10 x i16]* %45, i64 0, i64 %46 ; <i16*> [#uses=1]
+  %48 = load i16* %47, align 2                    ; <i16> [#uses=1]
+  %49 = sext i16 %48 to i32                       ; <i32> [#uses=1]
+  %50 = getelementptr inbounds %union.UnionType* %obj_copy, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %51 = getelementptr inbounds %struct.StructType2* %50, i32 0, i32 1 ; <[10 x i32]*> [#uses=1]
+  %52 = sext i32 %41 to i64                       ; <i64> [#uses=1]
+  %53 = getelementptr inbounds [10 x i32]* %51, i64 0, i64 %52 ; <i32*> [#uses=1]
+  store i32 %49, i32* %53, align 4
+  %54 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %55 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %56 = getelementptr inbounds %union.UnionType* %obj, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %57 = bitcast %struct.StructType2* %56 to %struct.StructType1* ; <%struct.StructType1*> [#uses=1]
+  %58 = getelementptr inbounds %struct.StructType1* %57, i32 0, i32 2 ; <[10 x i32]*> [#uses=1]
+  %59 = sext i32 %55 to i64                       ; <i64> [#uses=1]
+  %60 = getelementptr inbounds [10 x i32]* %58, i64 0, i64 %59 ; <i32*> [#uses=1]
+  %61 = load i32* %60, align 4                    ; <i32> [#uses=1]
+  %62 = getelementptr inbounds %union.UnionType* %obj_copy, i32 0, i32 0 ; <%struct.StructType2*> [#uses=1]
+  %63 = getelementptr inbounds %struct.StructType2* %62, i32 0, i32 2 ; <[10 x i32]*> [#uses=1]
+  %64 = sext i32 %54 to i64                       ; <i64> [#uses=1]
+  %65 = getelementptr inbounds [10 x i32]* %63, i64 0, i64 %64 ; <i32*> [#uses=1]
+  store i32 %61, i32* %65, align 4
+  %66 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %67 = add nsw i32 %66, 1                        ; <i32> [#uses=1]
+  store i32 %67, i32* %i, align 4
+  br label %bb4
+
+bb4:                                              ; preds = %bb3, %bb2
+  %68 = load i32* %i, align 4                     ; <i32> [#uses=1]
+  %69 = icmp sle i32 %68, 9                       ; <i1> [#uses=1]
+  br i1 %69, label %bb3, label %bb5
+
+bb5:                                              ; preds = %bb4
+  br label %return
+
+return:                                           ; preds = %bb5
+  ret void
+}





More information about the llvm-commits mailing list