[clang] [llvm] [NVPTX] Change the alloca address space in NVPTXLowerAlloca (PR #154814)
Artem Belevich via llvm-commits
llvm-commits at lists.llvm.org
Thu Aug 28 10:47:58 PDT 2025
================
@@ -502,3 +497,27 @@ void NVPTXPassConfig::addMachineSSAOptimization() {
addPass(&PeepholeOptimizerLegacyID);
printAndVerify("After codegen peephole optimization pass");
}
+
+bool NVPTXTargetMachine::isCompatibleDataLayout(
+ const DataLayout &Candidate) const {
+ // XXX: Should we enforce that the Candidate DataLayout has the same address
+ // space for allocas?
+ if (DL == Candidate)
+ return true;
+
+ auto DLStr = DL.getStringRepresentation();
+ if (!StringRef(DLStr).contains("A"))
+ DLStr = DLStr.empty() ? "A" + std::to_string(ADDRESS_SPACE_LOCAL)
+ : DLStr + "-A" + std::to_string(ADDRESS_SPACE_LOCAL);
+ auto NewDL = DataLayout(DLStr);
+
+ return NewDL == Candidate;
----------------
Artem-B wrote:
So, the idea here is to effectively assume that if `Ax` is not explicitly specified in the data layout, we assume that the layout is compatible with `A5`. This contradicts LLVM spec which states that `A` `Defaults to the default address space of 0.`
I think we may be working around the problem here, instead of addressing the root cause.
https://github.com/llvm/llvm-project/pull/154814
More information about the llvm-commits
mailing list