summaryrefslogtreecommitdiffstats
path: root/llvm/lib
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2012-02-09 14:26:06 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2012-02-09 14:26:06 +0000
commit487a3962c7ea14a834ab177fd9487e6cc5b9e1de (patch)
treea8c0ff7cbf41b0e428a12ebf7280b24bbbc52128 /llvm/lib
parentc602b6ecafa48a767b14b05e299e17b29e6f57e7 (diff)
downloadbcm5719-llvm-487a3962c7ea14a834ab177fd9487e6cc5b9e1de.tar.gz
bcm5719-llvm-487a3962c7ea14a834ab177fd9487e6cc5b9e1de.zip
GlobalOpt: Be more aggressive about elminating side-effect free static dtors.
GlobalOpt runs early in the pipeline (before inlining) and complex class hierarchies often introduce bitcasts or GEPs which weren't optimized away. Teach it to ignore side-effect free instructions instead of depending on other passes to remove them. llvm-svn: 150174
Diffstat (limited to 'llvm/lib')
-rw-r--r--llvm/lib/Transforms/IPO/GlobalOpt.cpp9
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index 6fa57b4c9b6..788fee0624f 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -2753,7 +2753,8 @@ static Function *FindCXAAtExit(Module &M) {
/// destructor and can therefore be eliminated.
/// Note that we assume that other optimization passes have already simplified
/// the code so we only look for a function with a single basic block, where
-/// the only allowed instructions are 'ret' or 'call' to empty C++ dtor.
+/// the only allowed instructions side-effect free, 'ret' or 'call' to empty
+/// C++ dtor.
static bool cxxDtorIsEmpty(const Function &Fn,
SmallPtrSet<const Function *, 8> &CalledFunctions) {
// FIXME: We could eliminate C++ destructors if they're readonly/readnone and
@@ -2786,9 +2787,9 @@ static bool cxxDtorIsEmpty(const Function &Fn,
if (!cxxDtorIsEmpty(*CalledFn, NewCalledFunctions))
return false;
} else if (isa<ReturnInst>(*I))
- return true;
- else
- return false;
+ return true; // We're done.
+ else if (I->mayHaveSideEffects())
+ return false; // Destructor with side effects, bail.
}
return false;
OpenPOWER on IntegriCloud