[llvm] [DeadArgElim] fix verifier failure when changing musttail's function signature (PR #127366)
Reid Kleckner via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 9 06:35:42 PDT 2025
================
@@ -522,29 +517,25 @@ void DeadArgumentEliminationPass::surveyFunction(const Function &F) {
// MaybeLive. Initialized to a list of RetCount empty lists.
RetUses MaybeLiveRetUses(RetCount);
- bool HasMustTailCalls = false;
for (const BasicBlock &BB : F) {
- // If we have any returns of `musttail` results - the signature can't
- // change
- if (const auto *TC = BB.getTerminatingMustTailCall()) {
- HasMustTailCalls = true;
- // In addition, if the called function is not locally defined (or unknown,
- // if this is an indirect call), we can't change the callsite and thus
- // can't change this function's signature either.
- if (!isMustTailCalleeAnalyzable(*TC)) {
- markLive(F);
+ if (BB.getTerminatingMustTailCall()) {
+ LLVM_DEBUG(dbgs() << "DeadArgumentEliminationPass - " << F.getName()
+ << " has musttail calls\n");
+ // If the calling convention is not swifttailcc or tailcc, the caller and
+ // callee of musttail must have exactly the same signature. Otherwise we
+ // only needs to guarantee they have the same return type.
+ if (F.getCallingConv() != CallingConv::SwiftTail ||
----------------
rnk wrote:
Please create a helper method that takes `F` and freezes the whole prototype or just the return type based on the calling convention, since you do this in two places and the logic looks the same.
https://github.com/llvm/llvm-project/pull/127366
More information about the llvm-commits
mailing list