diff options
| author | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-09 14:26:06 +0000 |
|---|---|---|
| committer | Benjamin Kramer <benny.kra@googlemail.com> | 2012-02-09 14:26:06 +0000 |
| commit | d4692747439aac1fbc2064e11b53e3e6ea5ad463 (patch) | |
| tree | c23eb536941b06a60c06a0af6e13d4db31fdc2a2 /lib/Transforms/IPO | |
| parent | 2c6ae095b8a944c8355377498b9ad11bb94af2d5 (diff) | |
| download | external_llvm-d4692747439aac1fbc2064e11b53e3e6ea5ad463.zip external_llvm-d4692747439aac1fbc2064e11b53e3e6ea5ad463.tar.gz external_llvm-d4692747439aac1fbc2064e11b53e3e6ea5ad463.tar.bz2 | |
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.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@150174 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/IPO')
| -rw-r--r-- | lib/Transforms/IPO/GlobalOpt.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/Transforms/IPO/GlobalOpt.cpp b/lib/Transforms/IPO/GlobalOpt.cpp index 6fa57b4..788fee0 100644 --- a/lib/Transforms/IPO/GlobalOpt.cpp +++ b/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; |
