[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 14 13:27:41 PDT 2020
arsenm updated this revision to Diff 298230.
arsenm added a comment.
Remove requires, and change FunctionCount
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.
@@ -53,8 +59,12 @@
errs() << "----------------------------\n";
errs() << "Function Index Reference:\n";
int FunctionCount = 0;
- for (auto &F : *Program)
- errs() << "\t" << ++FunctionCount << ": " << F.getName() << "\n";
+ for (auto &F : *Program) {
+ if (F.isIntrinsic())
+ continue;
+
+ errs() << '\t' << ++FunctionCount << ": " << F.getName() << '\n';
+ }
errs() << "----------------------------\n";
return FunctionCount;
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,24 @@
+; 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.298230.patch
Type: text/x-patch
Size: 2686 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201014/9a324266/attachment.bin>
More information about the llvm-commits
mailing list