Skip to content

[AMDGPU] Enable "amdgpu-sw-lower-lds" pass in pipeline. #89206

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

Merged
merged 1 commit into from
Aug 26, 2024

Conversation

skc7
Copy link
Contributor

@skc7 skc7 commented Apr 18, 2024

This PR enables "amdgpu-sw-lower-lds" pass in the pipeline.
Also introduces "amdgpu-enable-sw-lower-lds" cmd line flag to enbale/disable the pass.

This PR will be merged once PR #87265 is merged.

@llvmbot
Copy link
Member

llvmbot commented Apr 18, 2024

@llvm/pr-subscribers-backend-amdgpu

Author: Chaitanya (skc7)

Changes

If AddressSanitizer feature is enabled,
"amdgpu-sw-lower-lds" pass will be enabled in the pipeline,
"amdgpu-lower-module-lds" pass will be disabled with this PR.


Full diff: https://github.com/llvm/llvm-project/pull/89206.diff

1 Files Affected:

  • (modified) llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp (+5)
diff --git a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
index 305a6c8c3b9262..7684cf8f15b59c 100644
--- a/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
+++ b/llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
@@ -676,6 +676,11 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(
 
         if (EarlyInlineAll && !EnableFunctionCalls)
           PM.addPass(AMDGPUAlwaysInlinePass());
+
+#if __has_feature(address_sanitizer)
+        EnableLowerModuleLDS = false;
+        PM.addPass(AMDGPUSwLowerLDSPass());
+#endif
       });
 
   PB.registerPeepholeEPCallback(

@@ -676,6 +676,11 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(

if (EarlyInlineAll && !EnableFunctionCalls)
PM.addPass(AMDGPUAlwaysInlinePass());

#if __has_feature(address_sanitizer)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The host compiler cannot matter here.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have made changes to #87265 pass to process only functions which have "sanitize_address" attribute. Will be remove this __has_feature check.

@@ -676,6 +676,11 @@ void AMDGPUTargetMachine::registerPassBuilderCallbacks(

if (EarlyInlineAll && !EnableFunctionCalls)
PM.addPass(AMDGPUAlwaysInlinePass());

#if __has_feature(address_sanitizer)
EnableLowerModuleLDS = false;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should not be changing the values of global options

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With ASAN enabled, #87265 will now lower the LDS. I want to disable "lower-module-lds" pass when lowering is done by the new pass.
Could you please suggest any other way of disabling the "lower-module-lds" pass instead of setting EnableLowerModuleLDS to false?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you run the asan lowering, the LDS variables cease to exist. LowerModuleLDS can then run after and naturally no-op. You shouldn't need to disable anything

@skc7 skc7 force-pushed the skc7/enable_sw_lower_lds branch 2 times, most recently from 1ec0c19 to 4647b8a Compare June 7, 2024 05:46
@skc7 skc7 force-pushed the skc7/enable_sw_lower_lds branch from 4647b8a to 8389b23 Compare July 15, 2024 06:09
Comment on lines 340 to 342
static cl::opt<bool> EnableSwLowerLDS("amdgpu-enable-sw-lower-lds",
cl::desc("Enable sw lower lds pass"),
cl::init(true), cl::Hidden);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The name is misleading now that it's not a software lowering pass. At least the description should mention sanitizers?

@skc7 skc7 force-pushed the skc7/enable_sw_lower_lds branch from 8389b23 to 616df88 Compare August 16, 2024 16:31
@skc7 skc7 force-pushed the skc7/enable_sw_lower_lds branch from 616df88 to c6bf7ac Compare August 26, 2024 04:47
@skc7 skc7 merged commit 1f02be2 into llvm:main Aug 26, 2024
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants