[clang] [Clang][CodeGen][X86] don't coerce int128 into `{i64,i64}` for SysV-like ABIs (PR #135230)
Eli Friedman via cfe-commits
cfe-commits at lists.llvm.org
Tue Jun 3 15:47:55 PDT 2025
================
@@ -2595,6 +2595,14 @@ GetX86_64ByValArgumentPair(llvm::Type *Lo, llvm::Type *Hi,
ABIArgInfo X86_64ABIInfo::
classifyReturnType(QualType RetTy) const {
+ // return int128 as i128
+ if (const BuiltinType *BT = RetTy->getAs<BuiltinType>()) {
+ BuiltinType::Kind k = BT->getKind();
+ if (k == BuiltinType::Int128 || k == BuiltinType::UInt128) {
+ return ABIArgInfo::getDirect();
+ }
+ }
+
// AMD64-ABI 3.2.3p4: Rule 1. Classify the return type with the
// classification algorithm.
X86_64ABIInfo::Class Lo, Hi;
----------------
efriedma-quic wrote:
Sorry about the delay here.
I think this does the right thing, but in a pretty unintuitive way; I had to read through the code multiple times to convince myself this actually works the way it's supposed to.
I'd rather not have GetINTEGERTypeAtOffset return nullptr; instead, the callers of GetINTEGERTypeAtOffset should explicitly check for an i128 return type, and return early. And assert `Hi == Integer`.
https://github.com/llvm/llvm-project/pull/135230
More information about the cfe-commits
mailing list