summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/IPO
diff options
context:
space:
mode:
authorJohannes Doerfert <johannes@jdoerfert.de>2019-11-01 23:03:35 -0500
committerJohannes Doerfert <johannes@jdoerfert.de>2019-11-02 00:54:00 -0500
commit07d16424f28482a852a35bd817189d4dfb1701ef (patch)
treece6160d790cbb1e6c4bce583a6cc3a3ab4690213 /llvm/lib/Transforms/IPO
parentc7ab19dbb0f1f5c76ff70c7acab9f20c796cafb3 (diff)
downloadbcm5719-llvm-07d16424f28482a852a35bd817189d4dfb1701ef.tar.gz
bcm5719-llvm-07d16424f28482a852a35bd817189d4dfb1701ef.zip
[Attributor][FIX] Do not try to cast if a cast is not required
When we replace constant returns at the call site we did issue a cast in the hopes it would be a no-op if the types are equal. Turns out that is not the case and we have to check it ourselves first. Reused an IPConstantProp test for coverage. No functional change to the test wrt. IPConstantProp.
Diffstat (limited to 'llvm/lib/Transforms/IPO')
-rw-r--r--llvm/lib/Transforms/IPO/Attributor.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/IPO/Attributor.cpp b/llvm/lib/Transforms/IPO/Attributor.cpp
index 448a2d4b6c1..5082aa26dba 100644
--- a/llvm/lib/Transforms/IPO/Attributor.cpp
+++ b/llvm/lib/Transforms/IPO/Attributor.cpp
@@ -998,14 +998,18 @@ ChangeStatus AAReturnedValuesImpl::manifest(Attributor &A) {
if (CallBase *CB = dyn_cast<CallBase>(U.getUser()))
if (CB->isCallee(&U)) {
Constant *RVCCast =
- ConstantExpr::getTruncOrBitCast(RVC, CB->getType());
+ CB->getType() == RVC->getType()
+ ? RVC
+ : ConstantExpr::getTruncOrBitCast(RVC, CB->getType());
Changed = ReplaceCallSiteUsersWith(*CB, *RVCCast) | Changed;
}
} else {
assert(isa<CallBase>(AnchorValue) &&
"Expcected a function or call base anchor!");
Constant *RVCCast =
- ConstantExpr::getTruncOrBitCast(RVC, AnchorValue.getType());
+ AnchorValue.getType() == RVC->getType()
+ ? RVC
+ : ConstantExpr::getTruncOrBitCast(RVC, AnchorValue.getType());
Changed = ReplaceCallSiteUsersWith(cast<CallBase>(AnchorValue), *RVCCast);
}
if (Changed == ChangeStatus::CHANGED)
OpenPOWER on IntegriCloud