Author: Matt Arsenault Date: 2025-05-09T14:15:56+02:00 New Revision: 416cdcf3aa75ea6a6dd4fe6f76a8d7251e06e0b3
URL: https://github.com/llvm/llvm-project/commit/416cdcf3aa75ea6a6dd4fe6f76a8d7251e06e0b3 DIFF: https://github.com/llvm/llvm-project/commit/416cdcf3aa75ea6a6dd4fe6f76a8d7251e06e0b3.diff LOG: clang/OpenCL: Fix special casing OpenCL in call emission (#138864) This essentially reverts 1bf1a156d673. OpenCL's handling of address spaces has always been a mess, but it's better than it used to be so this hack appears to be unnecessary now. None of the code here should really depend on the language or language address space. The ABI address space to use is already explicit in the ABIArgInfo, so use that instead of guessing it has anything to do with LangAS::Default or getASTAllocaAddressSpace. The below usage of LangAS::Default and getASTAllocaAddressSpace are also suspect, but appears to be a more involved and separate fix. Added: Modified: clang/lib/CodeGen/CGCall.cpp Removed: ################################################################################ diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 9dfd25f9a8d43..76f3dafc8b2bd 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -5369,7 +5369,6 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, NeedCopy = true; } else if (I->hasLValue()) { auto LV = I->getKnownLValue(); - auto AS = LV.getAddressSpace(); bool isByValOrRef = ArgInfo.isIndirectAliased() || ArgInfo.getIndirectByVal(); @@ -5378,17 +5377,9 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, (LV.getAlignment() < getContext().getTypeAlignInChars(I->Ty))) { NeedCopy = true; } - if (!getLangOpts().OpenCL) { - if ((isByValOrRef && (AS != LangAS::Default && - AS != CGM.getASTAllocaAddressSpace()))) { - NeedCopy = true; - } - } - // For OpenCL even if RV is located in default or alloca address space - // we don't want to perform address space cast for it. - else if ((isByValOrRef && Addr.getType()->getAddressSpace() != - IRFuncTy->getParamType(FirstIRArg) - ->getPointerAddressSpace())) { + + if (isByValOrRef && Addr.getType()->getAddressSpace() != + ArgInfo.getIndirectAddrSpace()) { NeedCopy = true; } } @@ -5399,6 +5390,10 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, auto *T = llvm::PointerType::get( CGM.getLLVMContext(), CGM.getDataLayout().getAllocaAddrSpace()); + // FIXME: This should not depend on the language address spaces, and + // only the contextual values. If the address space mismatches, see if + // we can look through a cast to a compatible address space value, + // otherwise emit a copy. llvm::Value *Val = getTargetHooks().performAddrSpaceCast( *this, V, LangAS::Default, CGM.getASTAllocaAddressSpace(), T, true); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits