diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-04 17:18:01 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-04 17:18:01 -0700 |
commit | 51c0650c7bb78fed8ce0aba537312aea17f58d7d (patch) | |
tree | 1d19c01c79b858427a95b37862d47c393de3fbf6 /lib | |
parent | a4dba98995121b623698f1b8951da71e17ec634d (diff) |
PNaCl: Enable RewritePNaClLibraryCalls and fix it to remove unused decls
Removing the unused declarations of setjmp()/longjmp() will be
necessary for future ABI checks which will reject these external
function declarations because they are not intrinsics.
StripDeadPrototypes is supposed to remove these declarations, but it
fails to do so because there are dead ConstantExprs referencing the
declarations. I suspect these are left behind by ReplacePtrsWithInts.
We could fix this by adding calls to removeDeadConstantUsers() to
StripDeadPrototypes or to ReplacePtrsWithInts, but for now it seems
cleaner to fix RewritePNaClLibraryCalls.
BUG=https://code.google.com/p/nativeclient/issues/detail?id=3429
TEST=*.ll tests + tested along with an ABI check
Review URL: https://codereview.chromium.org/15931009
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/NaCl/PNaClABISimplify.cpp | 2 | ||||
-rw-r--r-- | lib/Transforms/NaCl/RewritePNaClLibraryCalls.cpp | 5 |
2 files changed, 6 insertions, 1 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; } |