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 | e1631ddf9363abf7a9ac8f8bc98dbfa6726aa969 (patch) | |
tree | 091982db349b3d6dce344abdbd1811d0db99b391 /llvm/lib/Transforms/Utils | |
parent | d65ef14df3cdfeb58251c261c20e23165c202dc6 (diff) | |
download | bcm5719-llvm-e1631ddf9363abf7a9ac8f8bc98dbfa6726aa969.tar.gz bcm5719-llvm-e1631ddf9363abf7a9ac8f8bc98dbfa6726aa969.zip |
SimplifyCFG: Don't duplicate calls to functions marked noduplicate v2
v2:
- Use CI->cannotDuplicate()
llvm-svn: 193115
Diffstat (limited to 'llvm/lib/Transforms/Utils')
-rw-r--r-- | llvm/lib/Transforms/Utils/SimplifyCFG.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp b/llvm/lib/Transforms/Utils/SimplifyCFG.cpp index 083328652fd..1398697dc55 100644 --- a/llvm/lib/Transforms/Utils/SimplifyCFG.cpp +++ b/llvm/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) { |