aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Transforms/NaCl/PNaClABISimplify.cpp2
-rw-r--r--lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp5
-rw-r--r--test/Transforms/NaCl/rewrite-longjmp-no-store.ll5
-rw-r--r--test/Transforms/NaCl/rewrite-setlongjmp-calls.ll4
4 files changed, 14 insertions, 2 deletions
diff --git a/lib/Transforms/NaCl/PNaClABISimplify.cpp b/lib/Transforms/NaCl/PNaClABISimplify.cpp
index 74a9f0730e..684be734c2 100644
--- a/lib/Transforms/NaCl/PNaClABISimplify.cpp
+++ b/lib/Transforms/NaCl/PNaClABISimplify.cpp
@@ -42,6 +42,8 @@ void llvm::PNaClABISimplifyAddPreOptPasses(PassManager &PM) {
}
void llvm::PNaClABISimplifyAddPostOptPasses(PassManager &PM) {
+ PM.add(createRewritePNaClLibraryCallsPass());
+
// We place ExpandByVal after optimization passes because some byval
// arguments can be expanded away by the ArgPromotion pass. Leaving
// in "byval" during optimization also allows some dead stores to be
diff --git a/lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp b/lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp
index 2373343f59..ea50457070 100644
--- a/lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp
+++ b/lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp
@@ -86,6 +86,7 @@ bool RewritePNaClLibraryCalls::runOnModule(Module &M) {
report_fatal_error("Taking the address of setjmp is invalid");
}
}
+ SetjmpFunc->eraseFromParent();
}
// For longjmp things are a little more complicated, since longjmp's address
@@ -109,7 +110,9 @@ bool RewritePNaClLibraryCalls::runOnModule(Module &M) {
}
// If additional uses remain, these aren't calls; populate the wrapper.
- if (!LongjmpFunc->use_empty()) {
+ if (LongjmpFunc->use_empty()) {
+ LongjmpFunc->eraseFromParent();
+ } else {
populateLongjmpWrapper(LongjmpFunc);
Changed = true;
}
diff --git a/test/Transforms/NaCl/rewrite-longjmp-no-store.ll b/test/Transforms/NaCl/rewrite-longjmp-no-store.ll
index fa2cd3b620..134593ad39 100644
--- a/test/Transforms/NaCl/rewrite-longjmp-no-store.ll
+++ b/test/Transforms/NaCl/rewrite-longjmp-no-store.ll
@@ -1,9 +1,12 @@
; RUN: opt < %s -rewrite-pnacl-library-calls -S | FileCheck %s
+; RUN: opt < %s -rewrite-pnacl-library-calls -S | FileCheck %s -check-prefix=CLEANED
; Test that when there are no uses other than calls to longjmp,
; no function body is generated.
declare void @longjmp(i64*, i32)
-; CHECK-NOT: define{{.*}}@longjmp(i64* %env, i32 %val) {
+
+; No declaration or definition of longjmp() should remain.
+; CLEANED-NOT: @longjmp
define void @call_longjmp(i64* %arg, i32 %num) {
call void @longjmp(i64* %arg, i32 %num)
diff --git a/test/Transforms/NaCl/rewrite-setlongjmp-calls.ll b/test/Transforms/NaCl/rewrite-setlongjmp-calls.ll
index 6ce3294244..f34f004d7f 100644
--- a/test/Transforms/NaCl/rewrite-setlongjmp-calls.ll
+++ b/test/Transforms/NaCl/rewrite-setlongjmp-calls.ll
@@ -1,9 +1,13 @@
; RUN: opt < %s -rewrite-pnacl-library-calls -S | FileCheck %s
+; RUN: opt < %s -rewrite-pnacl-library-calls -S | FileCheck %s -check-prefix=CLEANED
; Test the RewritePNaClLibraryCalls pass
declare i32 @setjmp(i64*)
declare void @longjmp(i64*, i32)
+; No declaration or definition of setjmp() should remain.
+; CLEANED-NOT: @setjmp
+
; Since the address of longjmp is being taken here, a body is generated
; for it, which does a cast and calls an intrinsic