aboutsummaryrefslogtreecommitdiff
path: root/test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll
diff options
context:
space:
mode:
authorMark Seaborn <mseaborn@chromium.org>2013-09-09 10:06:19 -0700
committerMark Seaborn <mseaborn@chromium.org>2013-09-09 10:06:19 -0700
commit1c0cea6c1fc807794f0d785392e05b19d0c70210 (patch)
tree46f959c795c6b5314d723e3264ccab02f359e5df /test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll
parent9ca910d4038b63e416311f7c4122de25c15cc5b0 (diff)
PNaCl bitcode: Change FORWARDTYPEREF to never use pointer types
Before, FORWARDTYPEREFs used i8* type rather than i32 if they referenced an "alloca" instruction. Clean this up so that FORWARDTYPEREFs use i32 instead in this case. Note that this means that a forward-referenced "alloca" can be used via an ptrtoint+inttoptr, rather than a bitcast, but that's no problem. This is a step towards removing TYPE_CODE_POINTER from the types table, to simplify the PNaCl bitcode format. Rename NormalizeParamType() to NormalizeScalarType() to reflect that it's used in more cases; make it public. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3671 TEST=test/NaCl/Bitcode/*.ll Review URL: https://codereview.chromium.org/23719016
Diffstat (limited to 'test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll')
-rw-r--r--test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll46
1 files changed, 46 insertions, 0 deletions
diff --git a/test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll b/test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll
new file mode 100644
index 0000000000..b6f8124a6f
--- /dev/null
+++ b/test/NaCl/Bitcode/forward-ref-pointer-intrinsic.ll
@@ -0,0 +1,46 @@
+; Test forward reference of a pointer-typed intrinsic result.
+
+; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=1 | pnacl-thaw \
+; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD1
+
+; RUN: llvm-as < %s | pnacl-freeze --pnacl-version=2 | pnacl-thaw \
+; RUN: | llvm-dis - | FileCheck %s -check-prefix=TD2
+
+
+declare i8* @llvm.nacl.read.tp()
+
+define i32 @forward_ref() {
+ br label %block1
+
+block2:
+ %1 = load i8* %3
+ %2 = ptrtoint i8* %3 to i32
+ ret i32 %2
+
+block1:
+ %3 = call i8* @llvm.nacl.read.tp()
+ br label %block2
+}
+
+; TD1: define i32 @forward_ref() {
+; TD1-NEXT: br label %block1
+; TD1: block2:
+; TD1-NEXT: %1 = load i8* %3
+; TD1-NEXT: %2 = ptrtoint i8* %3 to i32
+; TD1-NEXT: ret i32 %2
+; TD1: block1:
+; TD1-NEXT: %3 = call i8* @llvm.nacl.read.tp()
+; TD1-NEXT: br label %block2
+; TD1-NEXT: }
+
+; TD2: define i32 @forward_ref() {
+; TD2-NEXT: br label %block1
+; TD2: block2:
+; TD2-NEXT: %1 = inttoptr i32 %4 to i8*
+; TD2-NEXT: %2 = load i8* %1
+; TD2-NEXT: ret i32 %4
+; TD2: block1:
+; TD2-NEXT: %3 = call i8* @llvm.nacl.read.tp()
+; TD2-NEXT: %4 = ptrtoint i8* %3 to i32
+; TD2-NEXT: br label %block2
+; TD2-NEXT: }