forked from OSchip/llvm-project
[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 llvm-svn: 371915
This commit is contained in:
parent
2f519d7072
commit
e7c6f97039
|
@ -874,12 +874,17 @@ ChangeStatus AAReturnedValuesImpl::manifest(Attributor &A) {
|
||||||
if (Function *F = dyn_cast<Function>(&AnchorValue)) {
|
if (Function *F = dyn_cast<Function>(&AnchorValue)) {
|
||||||
for (const Use &U : F->uses())
|
for (const Use &U : F->uses())
|
||||||
if (CallBase *CB = dyn_cast<CallBase>(U.getUser()))
|
if (CallBase *CB = dyn_cast<CallBase>(U.getUser()))
|
||||||
if (CB->isCallee(&U))
|
if (CB->isCallee(&U)) {
|
||||||
Changed = ReplaceCallSiteUsersWith(*CB, *RVC) | Changed;
|
Constant *RVCCast =
|
||||||
|
ConstantExpr::getTruncOrBitCast(RVC, CB->getType());
|
||||||
|
Changed = ReplaceCallSiteUsersWith(*CB, *RVCCast) | Changed;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
assert(isa<CallBase>(AnchorValue) &&
|
assert(isa<CallBase>(AnchorValue) &&
|
||||||
"Expcected a function or call base anchor!");
|
"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)
|
if (Changed == ChangeStatus::CHANGED)
|
||||||
STATS_DECLTRACK(UniqueConstantReturnValue, FunctionReturn,
|
STATS_DECLTRACK(UniqueConstantReturnValue, FunctionReturn,
|
||||||
|
|
|
@ -827,6 +827,17 @@ define i32 @exact(i32* %a) {
|
||||||
ret i32 %add3
|
ret i32 %add3
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@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 }
|
attributes #0 = { noinline nounwind uwtable }
|
||||||
|
|
||||||
; BOTH-NOT: attributes #
|
; BOTH-NOT: attributes #
|
||||||
|
|
Loading…
Reference in New Issue