[PassManager] Mark Loop RequireAnalysis as OptionalPassInfoMixin#196345
Conversation
\llvm#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM. Restore the old behavior of just not marking the pass as required as it seems reasonable enough.
|
@llvm/pr-subscribers-llvm-transforms Author: Aiden Grossman (boomanaiden154) Changes#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM. Restore the old behavior of just not marking the pass as required as it seems reasonable enough. Full diff: https://github.com/llvm/llvm-project/pull/196345.diff 2 Files Affected:
diff --git a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
index de9e63c125f5e..973d8a3cb1008 100644
--- a/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
+++ b/llvm/include/llvm/Transforms/Scalar/LoopPassManager.h
@@ -184,7 +184,7 @@ typedef PassManager<Loop, LoopAnalysisManager, LoopStandardAnalysisResults &,
template <typename AnalysisT>
struct RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>
- : RequiredPassInfoMixin<
+ : OptionalPassInfoMixin<
RequireAnalysisPass<AnalysisT, Loop, LoopAnalysisManager,
LoopStandardAnalysisResults &, LPMUpdater &>> {
PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM,
diff --git a/llvm/test/Other/lpm-require-analysis-optnone.ll b/llvm/test/Other/lpm-require-analysis-optnone.ll
new file mode 100644
index 0000000000000..4e3c406852565
--- /dev/null
+++ b/llvm/test/Other/lpm-require-analysis-optnone.ll
@@ -0,0 +1,29 @@
+; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --version 6
+; RUN: opt < %s -passes="require<no-op-loop>" -S | FileCheck %s
+
+;; Test that if we have a loop out of LCSSA in an optnone function, we do not
+;; assert when we require a loop analysis.
+
+define i32 @foo() #0 {
+; CHECK-LABEL: define i32 @foo(
+; CHECK-SAME: ) #[[ATTR0:[0-9]+]] {
+; CHECK-NEXT: [[ENTRY:.*:]]
+; CHECK-NEXT: br label %[[FOR_COND:.*]]
+; CHECK: [[FOR_COND]]:
+; CHECK-NEXT: [[TMP0:%.*]] = add i16 0, 0
+; CHECK-NEXT: br i1 false, label %[[FOR_COND]], label %[[HANDLER_POINTER_OVERFLOW:.*]]
+; CHECK: [[HANDLER_POINTER_OVERFLOW]]:
+; CHECK-NEXT: [[TMP1:%.*]] = zext i16 [[TMP0]] to i32
+; CHECK-NEXT: ret i32 [[TMP1]]
+;
+entry:
+ br label %for.cond
+for.cond:
+ %0 = add i16 0, 0
+ br i1 false, label %for.cond, label %handler.pointer_overflow
+handler.pointer_overflow:
+ %1 = zext i16 %0 to i32
+ ret i32 %1
+}
+
+attributes #0 = { noinline optnone }
|
|
LLVM Buildbot has detected a new failure on builder Full details are available at: https://lab.llvm.org/buildbot/#/builders/67/builds/4290 Here is the relevant piece of the build log for the reference |
|
feels like if we can run arbitrary loop analyses in required loop passes, we should ensure the loop is in LCSSA form. so I'd suggest instead making LCSSA required |
I don't think there are any required loop passes which is why this wasn't an issue before. Making LCSSA required I think would transforms loops in |
ah I was thinking that we didn't have any loop passes in the -O0 pipeline but yeah we will be running -O3 on optnone functions, so I guess this is fine |
…m#196345) \llvm#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM. Restore the old behavior of just not marking the pass as required as it seems reasonable enough.
…m#196345) \llvm#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM. Restore the old behavior of just not marking the pass as required as it seems reasonable enough.
…m#196345) \llvm#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM. Restore the old behavior of just not marking the pass as required as it seems reasonable enough.
#192120 marked this as RequiredPassInfoMixin, deviating from previous behavior. This is probably fine for Function/Module analyses, but doesn't work well for loop analyses in the case that we have a loop in an optnone function that is not in LCSSA. The LCSSA pass will not run because it is optional, the analysis will get computed, and then we assert because the loop is out of LCSSA at the end of the LPM.
Restore the old behavior of just not marking the pass as required as it seems reasonable enough.