Index: tests_lit/reader_tests/alloc.ll |
diff --git a/tests_lit/reader_tests/alloc.ll b/tests_lit/reader_tests/alloc.ll |
new file mode 100644 |
index 0000000000000000000000000000000000000000..f3db361bc38a1128df257045a0d474b949e20728 |
--- /dev/null |
+++ b/tests_lit/reader_tests/alloc.ll |
@@ -0,0 +1,66 @@ |
+; Test if we can read alloca instructions. |
+ |
+; RUN: llvm-as < %s | pnacl-freeze \ |
+; RUN: | %llvm2ice -notranslate -verbose=inst -build-on-read \ |
+; RUN: -allow-pnacl-reader-error-recovery \ |
+; RUN: | FileCheck %s |
+ |
Karl
2014/09/08 21:16:23
Added case of alignment == 0, since it is allowed.
|
+define i32 @AllocaA1(i32 %n) { |
+ %array = alloca i8, i32 %n, align 1 |
+ %addr = ptrtoint i8* %array to i32 |
+ ret i32 %addr |
+} |
+ |
+; CHECK: define i32 @AllocaA1(i32 %__0) { |
+; CHECK-NEXT: __0: |
+; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 1 |
+; CHECK-NEXT: ret i32 %__1 |
+; CHECK-NEXT: } |
+ |
+define i32 @AllocaA2(i32 %n) { |
+ %array = alloca i8, i32 %n, align 2 |
+ %addr = ptrtoint i8* %array to i32 |
+ ret i32 %addr |
+} |
+ |
+; CHECK-NEXT: define i32 @AllocaA2(i32 %__0) { |
+; CHECK-NEXT: __0: |
+; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 2 |
+; CHECK-NEXT: ret i32 %__1 |
+; CHECK-NEXT: } |
+ |
+define i32 @AllocaA4(i32 %n) { |
+ %array = alloca i8, i32 %n, align 4 |
+ %addr = ptrtoint i8* %array to i32 |
+ ret i32 %addr |
+} |
+ |
+; CHECK-NEXT: define i32 @AllocaA4(i32 %__0) { |
+; CHECK-NEXT: __0: |
+; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 4 |
+; CHECK-NEXT: ret i32 %__1 |
+; CHECK-NEXT: } |
+ |
+define i32 @AllocaA8(i32 %n) { |
+ %array = alloca i8, i32 %n, align 8 |
+ %addr = ptrtoint i8* %array to i32 |
+ ret i32 %addr |
+} |
+ |
+; CHECK-NEXT: define i32 @AllocaA8(i32 %__0) { |
+; CHECK-NEXT: __0: |
+; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 8 |
+; CHECK-NEXT: ret i32 %__1 |
+; CHECK-NEXT: } |
+ |
+define i32 @AllocaA16(i32 %n) { |
+ %array = alloca i8, i32 %n, align 16 |
jvoung (off chromium)
2014/09/05 16:55:04
Once you have the constants block would be good to
Karl
2014/09/08 21:16:23
Done.
|
+ %addr = ptrtoint i8* %array to i32 |
+ ret i32 %addr |
+} |
+ |
+; CHECK-NEXT: define i32 @AllocaA16(i32 %__0) { |
+; CHECK-NEXT: __0: |
+; CHECK-NEXT: %__1 = alloca i8, i32 %__0, align 16 |
+; CHECK-NEXT: ret i32 %__1 |
+; CHECK-NEXT: } |