-
Notifications
You must be signed in to change notification settings - Fork 18k
AMDGPU: Add support for llvm.trap to handling of intrinsics with !nocallback #175230
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
akadutta
merged 13 commits into
llvm:main
from
akadutta:amdgpu/attributor-no-infer-inputs-missing-nocallback
Jan 30, 2026
Merged
Changes from 10 commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
7cfb107
do not infer implicit args for missing nocallback intrinsics;add trap…
akadutta 798ef42
fix format issue
akadutta 71ac2dc
resolve conflicts with main
akadutta 391e06a
fix incorrect merge
akadutta 40cdc1d
add handling for trap-func-name
akadutta 1a38625
code cleanup
akadutta 1573f46
simplify trap handling
akadutta 8cd6fb9
code cleanup
akadutta 02bb5ed
Merge branch 'main' into amdgpu/attributor-no-infer-inputs-missing-no…
akadutta 2c14764
add nocallback check at callsite.
akadutta 45a4a15
minor reorder of trap check conditions
akadutta 16f57ad
Merge branch 'main' into amdgpu/attributor-no-infer-inputs-missing-no…
akadutta 82d1e02
code format
akadutta File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,65 @@ | ||
| ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-attributes --check-globals all --version 6 | ||
| ; RUN: opt -S -mtriple=amdgcn-amd-amdhsa -mcpu=gfx90a -passes=amdgpu-attributor %s | FileCheck %s | ||
|
|
||
| ; Trap-like intrinsics such as llvm.trap and llvm.debugtrap do not have the | ||
| ; nocallback attribute, so the AMDGPU attributor used to conservatively drop | ||
| ; all implicitly-known inputs and AGPR allocation information. Make sure we | ||
| ; still infer that no implicit inputs are required and that the AGPR allocation | ||
| ; stays at zero. | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Something else has to be going on here, because the report was that a test was "broken". Treating traps overly more conservatively than necessary should not be able to break anything |
||
|
|
||
| declare void @llvm.trap() | ||
|
|
||
| declare void @llvm.debugtrap() | ||
|
|
||
| define amdgpu_kernel void @trap_kernel() { | ||
| ; CHECK-LABEL: define amdgpu_kernel void @trap_kernel( | ||
| ; CHECK-SAME: ) #[[ATTR2:[0-9]+]] { | ||
| ; CHECK-NEXT: call void @llvm.trap() | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| call void @llvm.trap() | ||
| ret void | ||
| } | ||
|
|
||
| define amdgpu_kernel void @trap_kernel_with_handler() { | ||
| ; CHECK-LABEL: define amdgpu_kernel void @trap_kernel_with_handler( | ||
| ; CHECK-SAME: ) #[[ATTR3:[0-9]+]] { | ||
| ; CHECK-NEXT: call void @llvm.trap() #[[ATTR4:[0-9]+]] | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| call void @llvm.trap() #0 | ||
| ret void | ||
| } | ||
|
|
||
| define amdgpu_kernel void @debugtrap_kernel() { | ||
| ; CHECK-LABEL: define amdgpu_kernel void @debugtrap_kernel( | ||
| ; CHECK-SAME: ) #[[ATTR2]] { | ||
| ; CHECK-NEXT: call void @llvm.debugtrap() | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| call void @llvm.debugtrap() | ||
| ret void | ||
| } | ||
|
|
||
| ; Test that a trap with both trap-func-name and nocallback is still safe | ||
| define amdgpu_kernel void @trap_kernel_with_handler_and_nocallback() { | ||
| ; CHECK-LABEL: define amdgpu_kernel void @trap_kernel_with_handler_and_nocallback( | ||
| ; CHECK-SAME: ) #[[ATTR2]] { | ||
| ; CHECK-NEXT: call void @llvm.trap() #[[ATTR5:[0-9]+]] | ||
| ; CHECK-NEXT: ret void | ||
| ; | ||
| call void @llvm.trap() #1 | ||
| ret void | ||
| } | ||
|
|
||
| attributes #0 = { "trap-func-name"="handler" } | ||
| attributes #1 = { nocallback "trap-func-name"="handler" } | ||
|
|
||
| ;. | ||
| ; CHECK: attributes #[[ATTR0:[0-9]+]] = { cold noreturn nounwind memory(inaccessiblemem: write) "target-cpu"="gfx90a" } | ||
| ; CHECK: attributes #[[ATTR1:[0-9]+]] = { nounwind "target-cpu"="gfx90a" } | ||
| ; CHECK: attributes #[[ATTR2]] = { "amdgpu-agpr-alloc"="0" "amdgpu-no-cluster-id-x" "amdgpu-no-cluster-id-y" "amdgpu-no-cluster-id-z" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "target-cpu"="gfx90a" "uniform-work-group-size"="false" } | ||
| ; CHECK: attributes #[[ATTR3]] = { "amdgpu-no-cluster-id-x" "amdgpu-no-cluster-id-y" "amdgpu-no-cluster-id-z" "amdgpu-no-completion-action" "amdgpu-no-default-queue" "amdgpu-no-dispatch-id" "amdgpu-no-dispatch-ptr" "amdgpu-no-flat-scratch-init" "amdgpu-no-heap-ptr" "amdgpu-no-hostcall-ptr" "amdgpu-no-implicitarg-ptr" "amdgpu-no-lds-kernel-id" "amdgpu-no-multigrid-sync-arg" "amdgpu-no-queue-ptr" "amdgpu-no-workgroup-id-x" "amdgpu-no-workgroup-id-y" "amdgpu-no-workgroup-id-z" "amdgpu-no-workitem-id-x" "amdgpu-no-workitem-id-y" "amdgpu-no-workitem-id-z" "target-cpu"="gfx90a" "uniform-work-group-size"="false" } | ||
| ; CHECK: attributes #[[ATTR4]] = { "trap-func-name"="handler" } | ||
| ; CHECK: attributes #[[ATTR5]] = { nocallback "trap-func-name"="handler" } | ||
| ;. | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.