aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
diff options
context:
space:
mode:
authorPierre van Houtryve <pierre.vanhoutryve@amd.com>2024-03-11 09:20:01 +0100
committerGitHub <noreply@github.com>2024-03-11 09:20:01 +0100
commitd4569d42b5cb8ba076f0115d3d21d89f68e6ce9d (patch)
treed3d83a569bdc977247996f5fa5eab7e505ea67fc /llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
parent3093d731dff93df02899dcc62f5e7ba02461ff2a (diff)
downloadllvm-d4569d42b5cb8ba076f0115d3d21d89f68e6ce9d.zip
llvm-d4569d42b5cb8ba076f0115d3d21d89f68e6ce9d.tar.gz
llvm-d4569d42b5cb8ba076f0115d3d21d89f68e6ce9d.tar.bz2
[AMDGPU] Let LowerModuleLDS run twice on the same module (#81729)
If all variables in the module are absolute, this means we're running the pass again on an already lowered module, and that works. If none of them are absolute, lowering can proceed as usual. Only diagnose cases where we have a mix of absolute/non-absolute GVs, which means we added LDS GVs after lowering, which is broken. See #81491 Split from #75333
Diffstat (limited to 'llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp')
-rw-r--r--llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
index 5762f19..b85cb26 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -340,15 +340,25 @@ public:
// Get uses from the current function, excluding uses by called functions
// Two output variables to avoid walking the globals list twice
+ std::optional<bool> HasAbsoluteGVs;
for (auto &GV : M.globals()) {
if (!AMDGPU::isLDSVariableToLower(GV)) {
continue;
}
- if (GV.isAbsoluteSymbolRef()) {
- report_fatal_error(
- "LDS variables with absolute addresses are unimplemented.");
- }
+ // Check if the module is consistent: either all GVs are absolute (happens
+ // when we run the pass more than once), or none are.
+ const bool IsAbsolute = GV.isAbsoluteSymbolRef();
+ if (HasAbsoluteGVs.has_value()) {
+ if (*HasAbsoluteGVs != IsAbsolute) {
+ report_fatal_error(
+ "Module cannot mix absolute and non-absolute LDS GVs");
+ }
+ } else
+ HasAbsoluteGVs = IsAbsolute;
+
+ if (IsAbsolute)
+ continue;
for (User *V : GV.users()) {
if (auto *I = dyn_cast<Instruction>(V)) {