[PATCH] D131026: stop llvm-reduce's ReduceBasicBlocks delta pass from creating invalid IR
John Regehr via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 2 15:18:37 PDT 2022
regehr created this revision.
regehr added reviewers: aeubanks, fhahn.
Herald added a project: All.
regehr requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
When the basic block delta pass removes the first basic block in a function, that function becomes illegal if the second block has extra predecessors. The function below is an example of one that triggers this issue. While we could think of various clever ways to fix this issue, the patch here simply makes the entry block ineligible for removal.
define void @aeDeleteEventLoop(ptr %0) {
%2 = alloca ptr, i32 0, align 8
%3 = alloca ptr, i32 0, align 8
call void @zfree()
br label %4
4: ; preds = %6, %1
%5 = icmp ne ptr %0, null
br i1 %5, label %6, label %7
6: ; preds = %4
store ptr null, ptr null, align 8
br label %4
7: ; preds = %4
ret void
}
https://reviews.llvm.org/D131026
Files:
llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
Index: llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
===================================================================
--- llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
+++ llvm/tools/llvm-reduce/deltas/ReduceBasicBlocks.cpp
@@ -110,7 +110,7 @@
SmallVector<BasicBlock *> BBsToDelete;
for (auto &F : Program) {
for (auto &BB : F) {
- if (O.shouldKeep())
+ if (BB.isEntryBlock() || O.shouldKeep())
BBsToKeep.insert(&BB);
else {
BBsToDelete.push_back(&BB);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131026.449455.patch
Type: text/x-patch
Size: 514 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220802/899b1351/attachment.bin>
More information about the llvm-commits
mailing list