[llvm] r371915 - [Attributor][Fix] Use right type to replace expressions
Johannes Doerfert via llvm-commits
llvm-commits at lists.llvm.org
Fri Sep 13 19:57:51 PDT 2019
Author: jdoerfert
Date: Fri Sep 13 19:57:50 2019
New Revision: 371915
URL: http://llvm.org/viewvc/llvm-project?rev=371915&view=rev
Log:
[Attributor][Fix] Use right type to replace expressions
Summary: This should be obsolete once the functionality in D66967 is integrated.
Reviewers: uenoku, sstefan1
Subscribers: hiraditya, bollu, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D67231
Modified:
llvm/trunk/lib/Transforms/IPO/Attributor.cpp
llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll
Modified: llvm/trunk/lib/Transforms/IPO/Attributor.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/Attributor.cpp?rev=371915&r1=371914&r2=371915&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/Attributor.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/Attributor.cpp Fri Sep 13 19:57:50 2019
@@ -874,12 +874,17 @@ ChangeStatus AAReturnedValuesImpl::manif
if (Function *F = dyn_cast<Function>(&AnchorValue)) {
for (const Use &U : F->uses())
if (CallBase *CB = dyn_cast<CallBase>(U.getUser()))
- if (CB->isCallee(&U))
- Changed = ReplaceCallSiteUsersWith(*CB, *RVC) | Changed;
+ if (CB->isCallee(&U)) {
+ Constant *RVCCast =
+ ConstantExpr::getTruncOrBitCast(RVC, CB->getType());
+ Changed = ReplaceCallSiteUsersWith(*CB, *RVCCast) | Changed;
+ }
} else {
assert(isa<CallBase>(AnchorValue) &&
"Expcected a function or call base anchor!");
- Changed = ReplaceCallSiteUsersWith(cast<CallBase>(AnchorValue), *RVC);
+ Constant *RVCCast =
+ ConstantExpr::getTruncOrBitCast(RVC, AnchorValue.getType());
+ Changed = ReplaceCallSiteUsersWith(cast<CallBase>(AnchorValue), *RVCCast);
}
if (Changed == ChangeStatus::CHANGED)
STATS_DECLTRACK(UniqueConstantReturnValue, FunctionReturn,
Modified: llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll?rev=371915&r1=371914&r2=371915&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll (original)
+++ llvm/trunk/test/Transforms/FunctionAttrs/arg_returned.ll Fri Sep 13 19:57:50 2019
@@ -827,6 +827,17 @@ define i32 @exact(i32* %a) {
ret i32 %add3
}
+ at G = external global i8
+define i32* @ret_const() #0 {
+ %bc = bitcast i8* @G to i32*
+ ret i32* %bc
+}
+define i32* @use_const() #0 {
+ %c = call i32* @ret_const()
+ ; CHECK: ret i32* bitcast (i8* @G to i32*)
+ ret i32* %c
+}
+
attributes #0 = { noinline nounwind uwtable }
; BOTH-NOT: attributes #
More information about the llvm-commits
mailing list