Skip to content

IR: Make llvm.fake.use a DefaultAttrsIntrinsic #131743

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 2 commits into from
Mar 19, 2025

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Mar 18, 2025

This shouldn't be special and is just an ordinary sideeffect.

@arsenm arsenm requested review from jmorse and SLTozer March 18, 2025 06:55
Copy link
Contributor Author

arsenm commented Mar 18, 2025

This stack of pull requests is managed by Graphite. Learn more about stacking.

@arsenm arsenm marked this pull request as ready for review March 18, 2025 06:55
@llvmbot
Copy link
Member

llvmbot commented Mar 18, 2025

@llvm/pr-subscribers-clang
@llvm/pr-subscribers-llvm-ir

@llvm/pr-subscribers-backend-amdgpu

Author: Matt Arsenault (arsenm)

Changes

This shouldn't be special and is just an ordinary sideeffect.


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

2 Files Affected:

  • (modified) llvm/include/llvm/IR/Intrinsics.td (+2-1)
  • (modified) llvm/test/CodeGen/AMDGPU/lower-kernargs.ll (+2-2)
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 62239ca705b9e..e3049144b132e 100644
--- a/llvm/include/llvm/IR/Intrinsics.td
+++ b/llvm/include/llvm/IR/Intrinsics.td
@@ -1881,7 +1881,8 @@ def int_is_constant : DefaultAttrsIntrinsic<[llvm_i1_ty], [llvm_any_ty],
                                 "llvm.is.constant">;
 
 // Introduce a use of the argument without generating any code.
-def int_fake_use : Intrinsic<[], [llvm_vararg_ty]>;
+def int_fake_use : DefaultAttrsIntrinsic<[], [llvm_vararg_ty],
+  [IntrHasSideEffects, IntrInaccessibleMemOnly, IntrWillReturn]>;
 
 // Intrinsic to mask out bits of a pointer.
 // First argument must be pointer or vector of pointer. This is checked by the
diff --git a/llvm/test/CodeGen/AMDGPU/lower-kernargs.ll b/llvm/test/CodeGen/AMDGPU/lower-kernargs.ll
index f6ee2090221c5..119beb958f1bd 100644
--- a/llvm/test/CodeGen/AMDGPU/lower-kernargs.ll
+++ b/llvm/test/CodeGen/AMDGPU/lower-kernargs.ll
@@ -1837,13 +1837,13 @@ attributes #2 = { nounwind "target-cpu"="tahiti" }
 !llvm.module.flags = !{!0}
 !0 = !{i32 1, !"amdhsa_code_object_version", i32 500}
 ;.
-; HSA: attributes #[[ATTR0:[0-9]+]] = { nounwind }
+; HSA: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
 ; HSA: attributes #[[ATTR1:[0-9]+]] = { nounwind "target-cpu"="kaveri" }
 ; HSA: attributes #[[ATTR2:[0-9]+]] = { nounwind "amdgpu-implicitarg-num-bytes"="40" "target-cpu"="kaveri" }
 ; HSA: attributes #[[ATTR3:[0-9]+]] = { nounwind "target-cpu"="tahiti" }
 ; HSA: attributes #[[ATTR4:[0-9]+]] = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
 ;.
-; MESA: attributes #[[ATTR0:[0-9]+]] = { nounwind }
+; MESA: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
 ; MESA: attributes #[[ATTR1:[0-9]+]] = { nounwind "target-cpu"="kaveri" }
 ; MESA: attributes #[[ATTR2:[0-9]+]] = { nounwind "amdgpu-implicitarg-num-bytes"="40" "target-cpu"="kaveri" }
 ; MESA: attributes #[[ATTR3:[0-9]+]] = { nounwind "target-cpu"="tahiti" }

Copy link
Contributor

@SLTozer SLTozer left a comment

Choose a reason for hiding this comment

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

Besides the failing test (looks like it's just a matter of the fake.use attribute index shifting in fake-use-determinism.c), this LGTM. Just as a small check for posterity, is there a reason to use IntrInaccessibleMemOnly over IntrNoMem when we've also set IntrHasSideEffects?

@arsenm
Copy link
Contributor Author

arsenm commented Mar 18, 2025

Besides the failing test (looks like it's just a matter of the fake.use attribute index shifting in fake-use-determinism.c), this LGTM. Just as a small check for posterity, is there a reason to use IntrInaccessibleMemOnly over IntrNoMem when we've also set IntrHasSideEffects?

I don't think so, I copied from something else. I'll fix it to IntrNoMem

@arsenm arsenm force-pushed the users/arsenm/intrinsics/fake-use-default-attrs-intrinsic branch from 3ebeba2 to 6b3a82b Compare March 18, 2025 17:15
@llvmbot llvmbot added the clang Clang issues not falling into any other category label Mar 18, 2025
Copy link
Contributor

@SLTozer SLTozer left a comment

Choose a reason for hiding this comment

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

Some minor comments, LGTM once addressed.

@@ -1837,13 +1837,13 @@ attributes #2 = { nounwind "target-cpu"="tahiti" }
!llvm.module.flags = !{!0}
!0 = !{i32 1, !"amdhsa_code_object_version", i32 500}
;.
; HSA: attributes #[[ATTR0:[0-9]+]] = { nounwind }
; HSA: attributes #[[ATTR0:[0-9]+]] = { nocallback nofree nosync nounwind willreturn memory(inaccessiblemem: readwrite) }
Copy link
Contributor

Choose a reason for hiding this comment

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

Do these attributes (and the ones below) need updating with the change to use IntrNoMem?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh right, the IR still doesn't have a representation of "side effects without memory" without memory. This just loses the attribute, and why I left as inaccessiblememonly. I guess I'll put it back

arsenm added 2 commits March 19, 2025 07:11
This shouldn't be special and is just an ordinary sideeffect.
@arsenm arsenm force-pushed the users/arsenm/intrinsics/fake-use-default-attrs-intrinsic branch from 6b3a82b to 72f4801 Compare March 19, 2025 00:17
Copy link
Contributor Author

arsenm commented Mar 19, 2025

Merge activity

  • Mar 18, 9:27 PM EDT: A user started a stack merge that includes this pull request via Graphite.
  • Mar 18, 9:29 PM EDT: A user merged this pull request with Graphite.

@arsenm arsenm merged commit 6f44be9 into main Mar 19, 2025
8 of 10 checks passed
@arsenm arsenm deleted the users/arsenm/intrinsics/fake-use-default-attrs-intrinsic branch March 19, 2025 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:AMDGPU clang Clang issues not falling into any other category llvm:ir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants