[PATCH] D88684: llvm-reduce: Don't replace intrinsic calls with undef
Matt Arsenault via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 18:02:24 PDT 2020
arsenm updated this revision to Diff 296840.
arsenm added a comment.
Add comment
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D88684/new/
https://reviews.llvm.org/D88684
Files:
llvm/test/Reduce/no-replace-intrinsic-callee-with-undef.ll
llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
Index: llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
@@ -30,7 +30,13 @@
// Record all out-of-chunk functions.
std::vector<std::reference_wrapper<Function>> FuncsToRemove;
copy_if(Program->functions(), std::back_inserter(FuncsToRemove),
- [&O](auto &unused) { return !O.shouldKeep(); });
+ [&O](Function &F) {
+ // Intrinsics don't have function bodies that are useful to
+ // reduce. Additionally, intrinsics may have additional operand
+ // constraints, and changing to an arbitrary call may radically
+ // change codegen.
+ return !F.isIntrinsic() && !O.shouldKeep();
+ });
// Then, drop body of each of them. We want to batch this and do nothing else
// here so that minimal number of remaining exteranal uses will remain.
Index: llvm/test/Reduce/no-replace-intrinsic-callee-with-undef.ll
===================================================================
--- /dev/null
+++ llvm/test/Reduce/no-replace-intrinsic-callee-with-undef.ll
@@ -0,0 +1,26 @@
+; REQUIRES: amdgpu-registered-target
+
+; It's invalid to have a non-intrinsic call with a metadata argument,
+; so it's unproductive to replace the users of the intrinsic
+; declaration with undef.
+
+; RUN: llvm-reduce --test FileCheck --test-arg --check-prefixes=CHECK-ALL,CHECK-INTERESTINGNESS --test-arg %s --test-arg --input-file %s -o %t 2> %t.log
+; RUN: FileCheck -check-prefix=STDERR %s < %t.log
+; RUN: cat %t | FileCheck -implicit-check-not=uninteresting --check-prefixes=CHECK-ALL,CHECK-FINAL %s
+
+; STDERR-NOT: Function has metadata parameter but isn't an intrinsic
+
+declare i32 @llvm.amdgcn.reloc.constant(metadata)
+declare void @uninteresting()
+
+define i32 @interesting() {
+entry:
+ ; CHECK-INTERESTINGNESS-LABEL: define i32 @interesting(
+ ; CHECK-INTERESTINGNESS: call
+
+ ; CHECK-FINAL: %call = call i32 @llvm.amdgcn.reloc.constant(metadata !"arst")
+ ; CHECK-FINAL-NEXT: ret i32 %call
+ %call = call i32 @llvm.amdgcn.reloc.constant(metadata !"arst")
+ call void @uninteresting()
+ ret i32 %call
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D88684.296840.patch
Type: text/x-patch
Size: 2266 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201008/b58e4211/attachment.bin>
More information about the llvm-commits
mailing list