File tree Expand file tree Collapse file tree 2 files changed +16
-4
lines changed
test/Transforms/Attributor Expand file tree Collapse file tree 2 files changed +16
-4
lines changed Original file line number Diff line number Diff line change @@ -906,10 +906,13 @@ ChangeStatus AAReturnedValuesImpl::manifest(Attributor &A) {
906906
907907 // If the assumed unique return value is an argument, annotate it.
908908 if (auto *UniqueRVArg = dyn_cast<Argument>(UniqueRV.getValue ())) {
909- // TODO: This should be handled differently!
910- this ->AnchorVal = UniqueRVArg;
911- this ->KindOrArgNo = UniqueRVArg->getArgNo ();
912- Changed = IRAttribute::manifest (A);
909+ if (UniqueRVArg->getType ()->canLosslesslyBitCastTo (
910+ getAssociatedFunction ()->getReturnType ())) {
911+ // TODO: This should be handled differently!
912+ this ->AnchorVal = UniqueRVArg;
913+ this ->KindOrArgNo = UniqueRVArg->getArgNo ();
914+ Changed = IRAttribute::manifest (A);
915+ }
913916 } else if (auto *RVC = dyn_cast<Constant>(UniqueRV.getValue ())) {
914917 // We can replace the returned value with the unique returned constant.
915918 Value &AnchorValue = getAnchorValue ();
Original file line number Diff line number Diff line change 1+ ; RUN: opt -attributor -S %s | FileCheck %s
2+ ; RUN: opt -passes=attributor -S %s | FileCheck %s
3+ ;
4+ ; CHECK: define i32 addrspace(1)* @foo(i32 addrspace(4)* nofree readnone %arg)
5+ define i32 addrspace (1 )* @foo (i32 addrspace (4 )* %arg ) {
6+ entry:
7+ %0 = addrspacecast i32 addrspace (4 )* %arg to i32 addrspace (1 )*
8+ ret i32 addrspace (1 )* %0
9+ }
You can’t perform that action at this time.
0 commit comments