diff options
author | Tom Stellard <thomas.stellard@amd.com> | 2013-10-21 20:07:30 +0000 |
---|---|---|
committer | Tom Stellard <thomas.stellard@amd.com> | 2013-10-21 20:07:30 +0000 |
commit | f2089e1dd810236f716c1a45fa1e561dce5074e8 (patch) | |
tree | 371a4c72e429c50d8cbb323d5b145b74cfe060f9 /lib | |
parent | e161dc28a8a58431e5e1df98834aaee72baada85 (diff) | |
download | llvm-f2089e1dd810236f716c1a45fa1e561dce5074e8.tar.gz llvm-f2089e1dd810236f716c1a45fa1e561dce5074e8.tar.bz2 llvm-f2089e1dd810236f716c1a45fa1e561dce5074e8.tar.xz |
SimplifyCFG: Don't duplicate calls to functions marked noduplicate v2
v2:
- Use CI->cannotDuplicate()
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@193115 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Transforms/Utils/SimplifyCFG.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/Transforms/Utils/SimplifyCFG.cpp b/lib/Transforms/Utils/SimplifyCFG.cpp index 083328652f..1398697dc5 100644 --- a/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/lib/Transforms/Utils/SimplifyCFG.cpp @@ -1561,6 +1561,19 @@ static bool SpeculativelyExecuteBB(BranchInst *BI, BasicBlock *ThenBB) { return true; } +/// \returns True if this block contains a CallInst with the NoDuplicate +/// attribute. +static bool HasNoDuplicateCall(const BasicBlock *BB) { + for (BasicBlock::const_iterator I = BB->begin(), E = BB->end(); I != E; ++I) { + const CallInst *CI = dyn_cast<CallInst>(I); + if (!CI) + continue; + if (CI->cannotDuplicate()) + return true; + } + return false; +} + /// BlockIsSimpleEnoughToThreadThrough - Return true if we can thread a branch /// across this block. static bool BlockIsSimpleEnoughToThreadThrough(BasicBlock *BB) { @@ -1608,6 +1621,8 @@ static bool FoldCondBranchOnPHI(BranchInst *BI, const DataLayout *TD) { // Now we know that this block has multiple preds and two succs. if (!BlockIsSimpleEnoughToThreadThrough(BB)) return false; + if (HasNoDuplicateCall(BB)) return false; + // Okay, this is a simple enough basic block. See if any phi values are // constants. for (unsigned i = 0, e = PN->getNumIncomingValues(); i != e; ++i) { |