[llvm] [Inline][Cloning] Drop incompatible attributes from `NewFunc` before `instSimplify` (PR #90489)
Antonio Frighetto via llvm-commits
llvm-commits at lists.llvm.org
Tue Apr 30 03:46:54 PDT 2024
================
@@ -700,6 +697,16 @@ void llvm::CloneAndPruneIntoFromInst(Function *NewFunc, const Function *OldFunc,
}
}
+ // Drop all incompatible return attributes that cannot be applied to NewFunc
+ // during cloning, so as to allow instruction simplification later to reason
+ // on the old state of the function. The original attributes are restored
+ // before returning.
+ AttributeMask IncompatibleAttrs =
+ AttributeFuncs::typeIncompatible(OldFunc->getReturnType());
+ AttrBuilder RetAttrs(NewFunc->getContext(),
+ NewFunc->getAttributes().getRetAttrs());
+ NewFunc->removeRetAttrs(IncompatibleAttrs);
----------------
antoniofrighetto wrote:
Perhaps we should drop args attribute as well, for coherence?
https://github.com/llvm/llvm-project/pull/90489
More information about the llvm-commits
mailing list