Repository navigation
[FixIrreducible] Use reportFatalUsageError for unsupported terminators - #205244
Conversation
|
Hello @AvhiMaz 👋 Thank you for submitting a Pull Request (PR) to the LLVM Project. Since this is your first PR, here are a few useful links covering our main contribution policies and review practices.
Please reply to this message to confirm that you have read these policies, especially the LLVM AI Tool Use Policy, and that any AI tool usage has been noted in the PR description. Frequently asked questionsHow do I add reviewers? This PR will be automatically labeled, and the relevant teams will be notified. For some parts of the project, reviewers may also be added automatically. You can also add reviewers manually using the Reviewers section on this page. If you cannot use that section, it is probably because you do not have write permissions for the repository. In that case, you can request a review by tagging reviewers in a comment using What if there are no comments? If you have not received any comments on your PR after a week, you can request a review by pinging the PR with a comment such as “Ping”. The common courtesy ping rate is once a week. Please remember that you are asking for volunteer time from other developers. Are any special GitHub settings required to contribute to LLVM? We only require contributors to have a public email address associated with their GitHub commits, see this section of LLVM Developer Policy for details. If you have questions, feel free to leave a comment on this PR, or ask on LLVM Discord or LLVM Discourse. Thank you, |
|
@llvm/pr-subscribers-llvm-transforms Author: Avhi (AvhiMaz) Changes
Fixes #191978 2 Files Affected:
diff --git a/llvm/lib/Transforms/Utils/FixIrreducible.cpp b/llvm/lib/Transforms/Utils/FixIrreducible.cpp
index 8e6425adc2855..2e59787a4adbb 100644
--- a/llvm/lib/Transforms/Utils/FixIrreducible.cpp
+++ b/llvm/lib/Transforms/Utils/FixIrreducible.cpp
@@ -134,6 +134,7 @@
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
+#include "llvm/Support/ErrorHandling.h"
#include "llvm/Transforms/Utils.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ControlFlowUtils.h"
@@ -320,7 +321,7 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
<< printBasicBlock(Succ) << '\n');
}
} else {
- llvm_unreachable("unsupported block terminator");
+ reportFatalUsageError("unsupported block terminator");
}
}
@@ -364,7 +365,7 @@ static bool fixIrreducible(Cycle &C, CycleInfo &CI, DominatorTree &DT,
<< printBasicBlock(Succ) << '\n');
}
} else {
- llvm_unreachable("unsupported block terminator");
+ reportFatalUsageError("unsupported block terminator");
}
}
diff --git a/llvm/test/Transforms/FixIrreducible/unsupported-terminator.ll b/llvm/test/Transforms/FixIrreducible/unsupported-terminator.ll
new file mode 100644
index 0000000000000..a572514b7421b
--- /dev/null
+++ b/llvm/test/Transforms/FixIrreducible/unsupported-terminator.ll
@@ -0,0 +1,19 @@
+; RUN: not opt < %s -passes=fix-irreducible -S 2>&1 | FileCheck %s
+; CHECK: unsupported block terminator
+
+define void @loop_1(i32 %Value, i1 %PredEntry) {
+entry:
+ br i1 %PredEntry, label %A, label %B
+
+A:
+ br label %B
+
+B:
+ switch i32 %Value, label %exit [
+ i32 0, label %A
+ i32 1, label %B
+ ]
+
+exit:
+ ret void
+}
|
Confirming I've read the contribution and AI Tool Use policies. |
a173c0e to
1be321d
Compare
Signed-off-by: AvhiMaz <[email protected]>
1be321d to
e810244
Compare
pektezol
left a comment
There was a problem hiding this comment.
LGTM
I don't have commit access, so this requires an approval from a maintaner.
Thanks for the review! Let's wait for a maintainer's approval. If you're allowed to, could you tag a maintainer? That would probably help. |
|
You are allowed to as well :) People from the issue discussion if it exists, or recent commiters to the specific pass are the people to ask. Make sure not to ping too frequently and/or too many people. Request for review, should be a simple one, I did a first pass of review: @ro-i |
|
@AvhiMaz Congratulations on having your first Pull Request (PR) merged into the LLVM Project! Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR. Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues. How to do this, and the rest of the post-merge process, is covered in detail here. If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again. If you don't get any reports, no action is required from you. Your changes are working as expected, well done! |
llvm#205244) `opt -passes=fix-irreducible` crashed via `llvm_unreachable` on a `switch` terminator incident to an irreducible cycle header. Such terminators must be lowered first (`lower-switch`); replace the `llvm_unreachable` at both sites with `reportFatalUsageError` so the pass fails gracefully instead of crashing. Fixes llvm#191978 Signed-off-by: AvhiMaz <[email protected]>
opt -passes=fix-irreduciblecrashed viallvm_unreachableon aswitchterminator incident to an irreducible cycle header. Suchterminators must be lowered first (
lower-switch); replace thellvm_unreachableat both sites withreportFatalUsageErrorso thepass fails gracefully instead of crashing.
Fixes #191978