[llvm] [X86] Fix TC_RETURN SDTypeProfile for the x32 ABI (PR #228281)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 4 00:26:04 PDT 2026
================
@@ -90,6 +90,40 @@ void X86SelectionDAGInfo::verifyTargetNode(const SelectionDAG &DAG,
}
SelectionDAGGenTargetInfo::verifyTargetNode(DAG, N);
+
+ switch (N->getOpcode()) {
+ default:
+ break;
+ case X86ISD::TC_RETURN:
+ case X86ISD::TC_RETURN_GLOBALADDR: {
+ // The tail-call target is an integer whose width depends on both the
+ // subtarget and on how the callee is addressed:
+ // * A direct call to a GlobalAddress/ExternalSymbol is i32 on the
+ // x32 ABI (as well as plain 32-bit mode) and i64 under LP64, since
+ // TCRETURNdi/TCRETURNdi64 are selected based on IsLP64/NotLP64.
+ // * Anything else (register, folded load, or TC_RETURN_GLOBALADDR's
+ // RIP-relative CFGuard call) uses the register width the subtarget
+ // executes in, i.e. i64 whenever the subtarget runs in 64-bit mode
+ // (including x32) and i32 otherwise.
+ const X86Subtarget &Subtarget =
+ DAG.getMachineFunction().getSubtarget<X86Subtarget>();
+ SDValue Target = N->getOperand(1);
+ bool IsDirect = Target.getOpcode() == ISD::GlobalAddress ||
+ Target.getOpcode() == ISD::TargetGlobalAddress ||
+ Target.getOpcode() == ISD::ExternalSymbol ||
+ Target.getOpcode() == ISD::TargetExternalSymbol;
----------------
RKSimon wrote:
+1
https://github.com/llvm/llvm-project/pull/228281
More information about the llvm-commits
mailing list