diff options
author | James Molloy <james.molloy@arm.com> | 2015-11-16 10:16:22 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2015-11-16 10:16:22 +0000 |
commit | d4d2357f266ef563e6609ad00d2524ec7de91826 (patch) | |
tree | db081bb06bf9a0eec4e11864038306907a0f16be /llvm/lib/Transforms | |
parent | 156aac0bb618722bfc65e2d75ceb7126377e747d (diff) | |
download | bcm5719-llvm-d4d2357f266ef563e6609ad00d2524ec7de91826.tar.gz bcm5719-llvm-d4d2357f266ef563e6609ad00d2524ec7de91826.zip |
[GlobalOpt] Address post-commit review comments on r253168
Address Duncan Exon Smith's comments on D14148, which was added after the patch had been LGTM'd and committed:
* clang-format one area where whitespace diffs occurred.
* Add a threshold to limit the store/load dominance checks as they are quadratic.
llvm-svn: 253192
Diffstat (limited to 'llvm/lib/Transforms')
-rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 20 |
1 files changed, 17 insertions, 3 deletions
diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index ddfc52273ca..812ee243738 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -87,9 +87,10 @@ namespace { bool ProcessInternalGlobal(GlobalVariable *GV,Module::global_iterator &GVI, const GlobalStatus &GS); bool OptimizeEmptyGlobalCXXDtors(Function *CXAAtExitFn); - - bool isPointerValueDeadOnEntryToFunction(const Function *F, GlobalValue *GV); - + + bool isPointerValueDeadOnEntryToFunction(const Function *F, + GlobalValue *GV); + TargetLibraryInfo *TLI; SmallSet<const Comdat *, 8> NotDiscardableComdats; }; @@ -1770,6 +1771,19 @@ bool GlobalOpt::isPointerValueDeadOnEntryToFunction(const Function *F, GlobalVal auto &DT = getAnalysis<DominatorTreeWrapperPass>(*const_cast<Function *>(F)) .getDomTree(); + // The below check is quadratic. Check we're not going to do too many tests. + // FIXME: Even though this will always have worst-case quadratic time, we + // could put effort into minimizing the average time by putting stores that + // have been shown to dominate at least one load at the beginning of the + // Stores array, making subsequent dominance checks more likely to succeed + // early. + // + // The threshold here is fairly large because global->local demotion is a + // very powerful optimization should it fire. + const unsigned Threshold = 100; + if (Loads.size() * Stores.size() > Threshold) + return false; + for (auto *L : Loads) { auto *LTy = L->getType(); if (!std::any_of(Stores.begin(), Stores.end(), [&](StoreInst *S) { |