diff options
author | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-10-30 23:52:56 +0000 |
---|---|---|
committer | Sanjoy Das <sanjoy@playingwithpointers.com> | 2016-10-30 23:52:56 +0000 |
commit | 299e67291c49cf28cf42e77b2ecdce1485a60ceb (patch) | |
tree | c7ba5e83ab8fa65dfc54ebe1538c463750fb2d93 /llvm/lib/Analysis | |
parent | b4830a84b96eb852ad4e97ad0cc22a1ea93da637 (diff) | |
download | bcm5719-llvm-299e67291c49cf28cf42e77b2ecdce1485a60ceb.tar.gz bcm5719-llvm-299e67291c49cf28cf42e77b2ecdce1485a60ceb.zip |
[SCEV] In CompareValueComplexity, order global values by their name
llvm-svn: 285529
Diffstat (limited to 'llvm/lib/Analysis')
-rw-r--r-- | llvm/lib/Analysis/ScalarEvolution.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/ScalarEvolution.cpp b/llvm/lib/Analysis/ScalarEvolution.cpp index fd8cec54826..aad57dc8f70 100644 --- a/llvm/lib/Analysis/ScalarEvolution.cpp +++ b/llvm/lib/Analysis/ScalarEvolution.cpp @@ -477,6 +477,21 @@ static int CompareValueComplexity(const LoopInfo *const LI, Value *LV, return (int)LArgNo - (int)RArgNo; } + if (const auto *LGV = dyn_cast<GlobalValue>(LV)) { + const auto *RGV = cast<GlobalValue>(RV); + + const auto IsGVNameSemantic = [&](const GlobalValue *GV) { + auto LT = GV->getLinkage(); + return !(GlobalValue::isPrivateLinkage(LT) || + GlobalValue::isInternalLinkage(LT)); + }; + + // Use the names to distinguish the two values, but only if the + // names are semantically important. + if (IsGVNameSemantic(LGV) && IsGVNameSemantic(RGV)) + return LGV->getName().compare(RGV->getName()); + } + // For instructions, compare their loop depth, and their operand count. This // is pretty loose. if (const auto *LInst = dyn_cast<Instruction>(LV)) { |