-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[AMDGPU] Skip lowerNonKernelLDSAccesses if function is declaration. #106975
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
@llvm/pr-subscribers-backend-amdgpu Author: Chaitanya (skc7) ChangesThis PR skips lowering non-kernel LDS i.e lowerNonKernelLDSAccesses, when function is a declaration or there are no lds globals to process. Full diff: https://github.com/llvm/llvm-project/pull/106975.diff 1 Files Affected:
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
index b2ab7e9c03e528..b85cc9cbbc02de 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUSwLowerLDS.cpp
@@ -1218,6 +1218,7 @@ bool AMDGPUSwLowerLDS::run() {
for (auto &K : FuncLDSAccessInfo.NonKernelToLDSAccessMap) {
Function *Func = K.first;
DenseSet<GlobalVariable *> &LDSGlobals = K.second;
+ if (Func->isDeclaration() || LDSGlobals.empty()) continue;
SetVector<GlobalVariable *> OrderedLDSGlobals = sortByName(
std::vector<GlobalVariable *>(LDSGlobals.begin(), LDSGlobals.end()));
lowerNonKernelLDSAccesses(Func, OrderedLDSGlobals, NKLDSParams);
@@ -1226,6 +1227,7 @@ bool AMDGPUSwLowerLDS::run() {
auto &K = FuncLDSAccessInfo.NonKernelToLDSAccessMap;
if (K.find(Func) != K.end())
continue;
+ if (Func->isDeclaration()) continue;
SetVector<llvm::GlobalVariable *> Vec;
lowerNonKernelLDSAccesses(Func, Vec, NKLDSParams);
}
|
✅ With the latest revision this PR passed the C/C++ code formatter. |
c035663
to
010b278
Compare
if (Func->isDeclaration()) | ||
continue; |
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.
Do this first before the map lookup
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.
Fixed this in latest commit. Skipped adding function to map if its a declaration.
@@ -1218,6 +1218,8 @@ bool AMDGPUSwLowerLDS::run() { | |||
for (auto &K : FuncLDSAccessInfo.NonKernelToLDSAccessMap) { | |||
Function *Func = K.first; | |||
DenseSet<GlobalVariable *> &LDSGlobals = K.second; | |||
if (Func->isDeclaration() || LDSGlobals.empty()) |
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.
How would a declaration end up in this set to begin with? Does this ever fire?
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.
Fixed this in latest commit. Skipped adding function to map if its a declaration.
if (CalledFunc->isDeclaration()) | ||
continue; |
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.
Can pull this into the previous condition
@@ -300,7 +302,8 @@ void AMDGPUSwLowerLDS::getUsesOfLDSByNonKernels() { | |||
for (User *V : GV->users()) { | |||
if (auto *I = dyn_cast<Instruction>(V)) { | |||
Function *F = I->getFunction(); | |||
if (!isKernelLDS(F) && F->hasFnAttribute(Attribute::SanitizeAddress)) | |||
if (!isKernelLDS(F) && F->hasFnAttribute(Attribute::SanitizeAddress) && | |||
!(F->isDeclaration())) |
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.
extra parentheses
if (!isKernelLDS(F) && F->hasFnAttribute(Attribute::SanitizeAddress) && | ||
!F->isDeclaration()) |
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.
This should be testable
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5 | ||
; RUN: opt < %s -passes=amdgpu-sw-lower-lds -S -mtriple=amdgcn-amd-amdhsa | FileCheck %s | ||
@lds = external addrspace(3) global [5 x i8], align 8 | ||
declare void @kernel_declaration() sanitize_address |
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.
Don't call this kernel_declaration, it's not a kernel
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.
updated in latest commit.
@@ -0,0 +1,97 @@ | |||
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals all --version 5 | |||
; RUN: opt < %s -passes=amdgpu-sw-lower-lds -S -mtriple=amdgcn-amd-amdhsa | FileCheck %s |
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.
< %s to the end
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.
Thanks for feedback. updated in latest commit.
da60e95
to
622a53a
Compare
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/76/builds/2578 Here is the relevant piece of the build log for the reference
|
…lvm#106975) This PR skips lowering non-kernel LDS i.e lowerNonKernelLDSAccesses, when function is a declaration or there are no lds globals to process. Change-Id: I20e4653b0f62fe108e65e55c9e66585ded2a8795
This PR skips lowering non-kernel LDS i.e lowerNonKernelLDSAccesses, when function is a declaration or there are no lds globals to process.