[clang] [llvm] IR: Make llvm.fake.use a DefaultAttrsIntrinsic (PR #131743)
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 18 10:15:51 PDT 2025
https://github.com/arsenm updated https://github.com/llvm/llvm-project/pull/131743
>From 6b3a82b7191ab6ef0f30077adc980f5c5bfbd63f Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Tue, 18 Mar 2025 13:06:59 +0700
Subject: [PATCH] IR: Make llvm.fake.use a DefaultAttrsIntrinsic
This shouldn't be special and is just an ordinary sideeffect.
---
clang/test/CodeGen/fake-use-determinism.c | 6 +++---
llvm/include/llvm/IR/Intrinsics.td | 3 ++-
llvm/test/CodeGen/AMDGPU/lower-kernargs.ll | 4 ++--
llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp | 2 ++
4 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/clang/test/CodeGen/fake-use-determinism.c b/clang/test/CodeGen/fake-use-determinism.c
index 039d8de692431..29f72aa0cc512 100644
--- a/clang/test/CodeGen/fake-use-determinism.c
+++ b/clang/test/CodeGen/fake-use-determinism.c
@@ -5,11 +5,11 @@
// but that it remains the same between different test runs.
// CHECK: [[K_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %k.addr
-// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[K_FAKE_USE]]) #2
+// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[K_FAKE_USE]])
// CHECK-NEXT: [[J_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %j.addr
-// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[J_FAKE_USE]]) #2
+// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[J_FAKE_USE]])
// CHECK-NEXT: [[I_FAKE_USE:%[a-zA-Z0-9\.]+]] = load i32, ptr %i.addr
-// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[I_FAKE_USE]]) #2
+// CHECK-NEXT: call void (...) @llvm.fake.use(i32 [[I_FAKE_USE]])
void bar();
void foo(int i, int j, int k)
diff --git a/llvm/include/llvm/IR/Intrinsics.td b/llvm/include/llvm/IR/Intrinsics.td
index 62239ca705b9e..a1e2e120013f6 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, IntrNoMem, 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" }
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
index a04f35498d7aa..406710ed96fae 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceOperandsToArgs.cpp
@@ -113,6 +113,8 @@ static void substituteOperandWithArgument(Function *OldF,
for (Use *Op : OpsToReplace)
UniqueValues.insert(Op->get());
+ // TODO: Preserve range metadata with ranges
+
// Determine the new function's signature.
SmallVector<Type *> NewArgTypes;
llvm::append_range(NewArgTypes, OldF->getFunctionType()->params());
More information about the llvm-commits
mailing list