================
@@ -664,6 +668,26 @@ convertABIArgInfo(const llvm::abi::ArgInfo &info,
MLIRContext *ctx,
// than emit a read of the wrong bytes.
if (offset && coerceIsRegisterTuple)
return std::nullopt;
+ // A pointer moved to another address space keeps its pointee, which
+ // abiTypeToCIR cannot recover.
+ if (auto origPtr = dyn_cast_if_present<cir::PointerType>(origTy)) {
+ if (const auto *coercePtr =
+ dyn_cast_if_present<llvm::abi::PointerType>(coerceAbi)) {
+ auto origAS = dyn_cast_if_present<cir::TargetAddressSpaceAttr>(
+ origPtr.getAddrSpace());
+ unsigned origASValue = origAS ? origAS.getValue() : 0;
+ if (!offset && coercePtr->getAddrSpace() != origASValue) {
----------------
skc7 wrote:
A plain pointer has no attribute and explicit `address_space(0)` keeps
`target_address_space(0)`. Comparing the attributes would wrongly coerce the
second form (`CIR/CodeGen/address-space.c` failed with attr comparision). So
kept the numeric check and added a comment.
https://github.com/llvm/llvm-project/pull/220197
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits