diff options
| author | Eli Bendersky <eliben@chromium.org> | 2013-05-28 11:23:28 -0700 |
|---|---|---|
| committer | Eli Bendersky <eliben@chromium.org> | 2013-05-28 11:23:28 -0700 |
| commit | ffc13bcb40d4257202295fc0ffe25b38bdf64263 (patch) | |
| tree | e3269675fec1127c195d6b3c248a6a47376b32f0 /test/Transforms | |
| parent | a7b1caf4ea69d2cc6ff207fcef7085494bbc686a (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/Transforms')
| -rw-r--r-- | test/Transforms/NaCl/add-pnacl-external-decls.ll | 6 | ||||
| -rw-r--r-- | test/Transforms/NaCl/resolve-pnacl-intrinsics.ll | 25 |
2 files changed, 31 insertions, 0 deletions
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 +} |
