aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorEli Bendersky <eliben@chromium.org>2013-05-28 11:23:28 -0700
committerEli Bendersky <eliben@chromium.org>2013-05-28 11:23:28 -0700
commitffc13bcb40d4257202295fc0ffe25b38bdf64263 (patch)
treee3269675fec1127c195d6b3c248a6a47376b32f0 /test
parenta7b1caf4ea69d2cc6ff207fcef7085494bbc686a (diff)
Add two passes that implement conversions from PNaCl's specific intrinsics
to external function calls during the translation stage (llc). One of the passes is a ModulePass that adds the appropriate function declarations to the module. The other is a FunctionPass that performs the actual call replacement. This split exists because of bitcode streaming. Initially the passes handle the llvm.nacl.{set|long}jmp intrinsics. In the future they may handle additional intrinsics that are part of the PNaCl stable bitcode ABI. This CL also removes the previous approach to handling this conversion (in SelectionDAGBuilder.cpp). That ended up not working - more details in issue 3429. BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429 R=mseaborn@chromium.org Review URL: https://codereview.chromium.org/16047002
Diffstat (limited to 'test')
-rw-r--r--test/NaCl/ARM/nacl-setlongjmp-intrinsics.ll2
-rw-r--r--test/NaCl/X86/nacl-setlongjmp-intrinsics.ll2
-rw-r--r--test/Transforms/NaCl/add-pnacl-external-decls.ll6
-rw-r--r--test/Transforms/NaCl/resolve-pnacl-intrinsics.ll25
4 files changed, 33 insertions, 2 deletions
diff --git a/test/NaCl/ARM/nacl-setlongjmp-intrinsics.ll b/test/NaCl/ARM/nacl-setlongjmp-intrinsics.ll
index 73251d10f3..e0854db4ff 100644
--- a/test/NaCl/ARM/nacl-setlongjmp-intrinsics.ll
+++ b/test/NaCl/ARM/nacl-setlongjmp-intrinsics.ll
@@ -10,7 +10,7 @@ define void @foo(i8* %arg) {
%num = call i32 @llvm.nacl.setjmp(i8* %arg)
; ARM: bl setjmp
- call void @llvm.nacl.longjmp(i8* %arg, i32 %num)
+ call void @llvm.nacl.longjmp(i8* %arg, i32 %num)
; ARM: bl longjmp
ret void
diff --git a/test/NaCl/X86/nacl-setlongjmp-intrinsics.ll b/test/NaCl/X86/nacl-setlongjmp-intrinsics.ll
index fa827a2758..ac595d613a 100644
--- a/test/NaCl/X86/nacl-setlongjmp-intrinsics.ll
+++ b/test/NaCl/X86/nacl-setlongjmp-intrinsics.ll
@@ -10,7 +10,7 @@ define void @foo(i8* %arg) {
%num = call i32 @llvm.nacl.setjmp(i8* %arg)
; X86: naclcall setjmp
- call void @llvm.nacl.longjmp(i8* %arg, i32 %num)
+ call void @llvm.nacl.longjmp(i8* %arg, i32 %num)
; X86: naclcall longjmp
ret void
diff --git a/test/Transforms/NaCl/add-pnacl-external-decls.ll b/test/Transforms/NaCl/add-pnacl-external-decls.ll
new file mode 100644
index 0000000000..1f525a9268
--- /dev/null
+++ b/test/Transforms/NaCl/add-pnacl-external-decls.ll
@@ -0,0 +1,6 @@
+; RUN: opt < %s -add-pnacl-external-decls -S | FileCheck %s
+
+declare void @foobar(i32)
+
+; CHECK: declare i32 @setjmp(i8*)
+; CHECK: declare void @longjmp(i8*, i32)
diff --git a/test/Transforms/NaCl/resolve-pnacl-intrinsics.ll b/test/Transforms/NaCl/resolve-pnacl-intrinsics.ll
new file mode 100644
index 0000000000..3aa263fa9a
--- /dev/null
+++ b/test/Transforms/NaCl/resolve-pnacl-intrinsics.ll
@@ -0,0 +1,25 @@
+; RUN: opt < %s -resolve-pnacl-intrinsics -S | FileCheck %s
+
+declare i32 @llvm.nacl.setjmp(i8*)
+declare void @llvm.nacl.longjmp(i8*, i32)
+
+; These declarations must be here because the function pass expects
+; to find them. In real life they're inserted by the translator
+; before the function pass runs.
+declare i32 @setjmp(i8*)
+declare void @longjmp(i8*, i32)
+
+; CHECK-NOT: call i32 @llvm.nacl.setjmp
+; CHECK-NOT: call void @llvm.nacl.longjmp
+
+define i32 @call_setjmp(i8* %arg) {
+ %val = call i32 @llvm.nacl.setjmp(i8* %arg)
+; CHECK: %val = call i32 @setjmp(i8* %arg)
+ ret i32 %val
+}
+
+define void @call_longjmp(i8* %arg, i32 %num) {
+ call void @llvm.nacl.longjmp(i8* %arg, i32 %num)
+; CHECK: call void @longjmp(i8* %arg, i32 %num)
+ ret void
+}