[llvm] [AMDGPU] Fix DynLDS causing crash when LowerLDS is run at fullLTO pipeline (PR #96038)
Vigneshwar Jayakumar via llvm-commits
llvm-commits at lists.llvm.org
Wed Jun 19 01:07:48 PDT 2024
https://github.com/VigneshwarJ created https://github.com/llvm/llvm-project/pull/96038
Direct mapped dynamic LDS is not lowered in the LowerLDSModule pass. Hence
it is not marked with absolute symbol. When lowerLDS pass is rerun in LTO,
compilation fails with assert "cannot mix abs and non-abs LDVs". This patch
adds fix to check if all GVs are absolute or if its non absolute,then
whether it is direct mapped dynLDS, if not fails with the same assert.
Fixes SWDEV-454281
>From 93982470d8eee13e886f9a9a4c54bc043d421e71 Mon Sep 17 00:00:00 2001
From: Vigneshwar Jayakumar <vjayakum at amd.com>
Date: Wed, 19 Jun 2024 02:19:12 -0500
Subject: [PATCH] [AMDGPU] Fix DynLDS causing crash when LowerLDS is run at
fullLTO pipeline
Direct mapped dynamic LDS is not lowered in the LowerLDSModule pass. Hence
it is not marked with absolute symbol. When lowerLDS pass is rerun in LTO,
compilation fails with assert "cannot mix abs and non-abs LDVs". This patch
adds fix to check if all GVs are absolute or if its non absolute,then
whether it is direct mapped dynLDS, if not fails with the same assert.
Fixes SWDEV-454281
---
llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp | 9 +++++++--
llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll | 3 ++-
2 files changed, 9 insertions(+), 3 deletions(-)
diff --git a/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp b/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp
index 04c6e940e6ed6..68f4f6ed101ed 100644
--- a/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp
+++ b/llvm/lib/Target/AMDGPU/Utils/AMDGPUMemoryUtils.cpp
@@ -207,7 +207,9 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
}
// Verify that we fall into one of 2 cases:
- // - All variables are absolute: this is a re-run of the pass
+ // - All variables are either absolute
+ // or direct mapped dynamic LDS that is not lowered.
+ // this is a re-run of the pass
// so we don't have anything to do.
// - No variables are absolute.
std::optional<bool> HasAbsoluteGVs;
@@ -215,8 +217,11 @@ LDSUsesInfoTy getTransitiveUsesOfLDS(const CallGraph &CG, Module &M) {
for (auto &[Fn, GVs] : Map) {
for (auto *GV : GVs) {
bool IsAbsolute = GV->isAbsoluteSymbolRef();
+ bool IsDirectMapDynLDSGV = AMDGPU::isDynamicLDS(*GV) && DirectMapKernel.contains(Fn);
if (HasAbsoluteGVs.has_value()) {
- if (*HasAbsoluteGVs != IsAbsolute) {
+ if (*HasAbsoluteGVs != IsAbsolute ) {
+ if(IsDirectMapDynLDSGV)
+ continue;
report_fatal_error(
"Module cannot mix absolute and non-absolute LDS GVs");
}
diff --git a/llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll b/llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll
index f1d946376afe0..c9f4303dfdde3 100644
--- a/llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll
+++ b/llvm/test/CodeGen/AMDGPU/lto-lower-module-lds.ll
@@ -39,9 +39,10 @@
; CHECK: Lower uses of LDS variables from non-kernel functions
@lds = internal unnamed_addr addrspace(3) global i32 poison, align 4
-
+ at dynlds = external addrspace(3) global [0 x i32]
define amdgpu_kernel void @test() {
entry:
store i32 1, ptr addrspace(3) @lds
+ store i32 0, ptr addrspace(3) @dynlds
ret void
}
More information about the llvm-commits
mailing list