Author: Arseniy Obolenskiy Date: 2026-11-19T20:59:29+01:00 New Revision: 7e007dc82889a7f6e7a0794e6af6ca2f3387e7ac
URL: https://github.com/llvm/llvm-project/commit/7e007dc82889a7f6e7a0794e6af6ca2f3387e7ac DIFF: https://github.com/llvm/llvm-project/commit/7e007dc82889a7f6e7a0794e6af6ca2f3387e7ac.diff LOG: [LLVMABI] Treat data member pointers as scalars (#244140) Match Clang, which passes atomic data member pointers directly on x86-64 Required for https://github.com/llvm/llvm-project/pull/223259 Added: clang/test/CodeGen/X86/x86_64-member-pointer-abi.cpp Modified: llvm/lib/ABI/TargetInfo.cpp Removed: ################################################################################ diff --git a/clang/test/CodeGen/X86/x86_64-member-pointer-abi.cpp b/clang/test/CodeGen/X86/x86_64-member-pointer-abi.cpp new file mode 100644 index 00000000000000..6541febce92655 --- /dev/null +++ b/clang/test/CodeGen/X86/x86_64-member-pointer-abi.cpp @@ -0,0 +1,16 @@ +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm %s -o - | FileCheck %s +// RUN: %clang_cc1 -triple x86_64-unknown-linux-gnu -emit-llvm -fexperimental-abi-lowering %s -o - | FileCheck %s + +struct S { int i; }; +typedef int S::*dmp_t; + +// A data member pointer is a scalar, so an atomic one is passed directly as +// its offset. +void take_atomic_dmp(_Atomic(dmp_t) p) {} + +// CHECK-LABEL: define dso_local void @_Z15take_atomic_dmpU7_AtomicM1Si( +// CHECK-SAME: i64 %{{.*}}) + +_Atomic(dmp_t) ret_atomic_dmp() { return nullptr; } + +// CHECK-LABEL: define dso_local i64 @_Z14ret_atomic_dmpv() diff --git a/llvm/lib/ABI/TargetInfo.cpp b/llvm/lib/ABI/TargetInfo.cpp index 14f2e9df738212..3177718e4cdb49 100644 --- a/llvm/lib/ABI/TargetInfo.cpp +++ b/llvm/lib/ABI/TargetInfo.cpp @@ -27,6 +27,10 @@ bool TargetInfo::isAggregateTypeForABI(const Type *Ty) const { Ty->isPointer() || Ty->isVector() || Ty->isTuple()) return false; + // Data member pointers have scalar evaluation kind. + if (const auto *MPT = dyn_cast<MemberPointerType>(Ty)) + return MPT->isFunctionPointer(); + // A matrix type is modeled as an array but lowers to a single flattened // vector and has scalar evaluation kind in classic CodeGen, so it is not an // aggregate for ABI purposes. _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
