diff options
author | Mark Seaborn <mseaborn@chromium.org> | 2013-06-25 10:25:35 -0700 |
---|---|---|
committer | Mark Seaborn <mseaborn@chromium.org> | 2013-06-25 10:25:35 -0700 |
commit | 8811efb18b978645cf5ef8a88a9b57066c21ff1f (patch) | |
tree | 3dd9198f7416d868a453e65c24a54709c5f58f97 | |
parent | d32f2f27e9bed303ce454ec48608204fba1e1194 (diff) |
PNaCl: Fix removal of dead function prototypes in ABI simplification
The use of StripDeadPrototypes in PNaClABISimplify.cpp wasn't always
having an effect: it doesn't work if there are dead constant
references remaining to a function declaration. ReplacePtrsWithInts
was leaving some of these references behind, so fix it.
BUG=none
TEST=llvm-lit tests
Review URL: https://codereview.chromium.org/17636006
-rw-r--r-- | lib/Transforms/NaCl/ReplacePtrsWithInts.cpp | 3 | ||||
-rw-r--r-- | test/Transforms/NaCl/pnacl-abi-simplify-postopt.ll | 6 |
2 files changed, 9 insertions, 0 deletions
diff --git a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp index 6e8c6915e5..cee574296f 100644 --- a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp +++ b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp @@ -610,6 +610,9 @@ bool ReplacePtrsWithInts::runOnModule(Module &M) { // various casts. for (Module::iterator Func = M.begin(), E = M.end(); Func != E; ++Func) { CleanUpFunction(Func, IntPtrType); + // Delete the now-unused bitcast ConstantExprs that we created so + // that they don't interfere with StripDeadPrototypes. + Func->removeDeadConstantUsers(); } return true; } diff --git a/test/Transforms/NaCl/pnacl-abi-simplify-postopt.ll b/test/Transforms/NaCl/pnacl-abi-simplify-postopt.ll index a1ea6dc0ca..87a4f48dd5 100644 --- a/test/Transforms/NaCl/pnacl-abi-simplify-postopt.ll +++ b/test/Transforms/NaCl/pnacl-abi-simplify-postopt.ll @@ -1,4 +1,6 @@ ; RUN: opt %s -pnacl-abi-simplify-postopt -S | FileCheck %s +; RUN: opt %s -pnacl-abi-simplify-postopt -S \ +; RUN: | FileCheck %s -check-prefix=CLEANUP ; "-pnacl-abi-simplify-postopt" runs various passes which are tested ; thoroughly in other *.ll files. This file is a smoke test to check @@ -14,3 +16,7 @@ define i16 @read_var() { } ; CHECK: = bitcast [4 x i8]* @var ; CHECK-NEXT: load i16* + +; Check that dead prototypes are successfully removed. +declare void @unused_prototype(i8*) +; CLEANUP-NOT: unused_prototype |