-
Notifications
You must be signed in to change notification settings - Fork 13.6k
[AMDGPU] Fix DynLDS causing crash when LowerLDS is run at fullLTO pipeline #96038
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
…eline 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
Thank you for submitting a Pull Request (PR) to the LLVM Project! This PR will be automatically labeled and the relevant teams will be If you wish to, you can add reviewers by using the "Reviewers" section on this page. If this is not working for you, it is probably because you do not have write If you have received no comments on your PR for a week, you can request a review If you have further questions, they may be answered by the LLVM GitHub User Guide. You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums. |
@llvm/pr-subscribers-backend-amdgpu Author: Vigneshwar Jayakumar (VigneshwarJ) ChangesDirect mapped dynamic LDS is not lowered in the LowerLDSModule pass. Hence Fixes SWDEV-454281 Full diff: https://github.com/llvm/llvm-project/pull/96038.diff 2 Files Affected:
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
-
+@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
}
|
if (*HasAbsoluteGVs != IsAbsolute ) { | ||
if(IsDirectMapDynLDSGV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if (*HasAbsoluteGVs != IsAbsolute ) { | |
if(IsDirectMapDynLDSGV) | |
if (*HasAbsoluteGVs != IsAbsolute) { | |
if (IsDirectMapDynLDSGV) |
run clang-format
@@ -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 | |||
|
|||
@dynlds = external addrspace(3) global [0 x i32] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs another test where the variable is seen first, see previous comment
if (*HasAbsoluteGVs != IsAbsolute ) { | ||
if(IsDirectMapDynLDSGV) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think you should just continue
on these at the start of the loop, otherwise I assume IsAbsolute
could be set the first time by a dynlds variable, then trigger a similar scenario ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@VigneshwarJ Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested Please check whether problems have been caused by your change specifically, as How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/929 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/154/builds/679 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/23/builds/474 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/35/builds/490 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/25/builds/412 Here is the relevant piece of the build log for the reference:
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/161/builds/193 Here is the relevant piece of the build log for the reference:
|
…eline (llvm#96038) Direct mapped dynamic LDS is not lowered in the LowerLDSModule pass. Hence it is not marked with an absolute symbol. When the LowerLDS pass is rerun in LTO, compilation fails with an assert "cannot mix abs and non-abs LDVs". This patch adds an additional check for direct mapped dynLDS to skip the assert. Fixes SWDEV-454281
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