Skip to content

Commit aa0776d

Browse files
committed
Revert "[Pipelines] Do not run CoroSplit and CoroCleanup in LTO pre-link pipeline (#90310)" and related patches
This change is incorrect when thinlto and asan are enabled, and this can be observed by adding `-fsanitize=address` to the provided coro-elide-thinlto.cpp test. It results in the error "Coroutines cannot handle non static allocas yet", and ASan introduces a dynamic alloca. In other words, we must preserve the invariant that CoroSplit runs before ASan. If we move CoroSplit to the post post-link compile stage, ASan has to be moved to the post-link compile stage first. It would also be correct to make CoroSplit handle dynamic allocas so the pass ordering doesn't matter, but sanitizer instrumentation really ought to be last, after coroutine splitting. This reverts commit bafc5f4. This reverts commit b1b1bfa. This reverts commit 0232b77. This reverts commit fb2d305. This reverts commit 1cb3371. This reverts commit cd68d7b.
1 parent 666c686 commit aa0776d

File tree

5 files changed

+10
-85
lines changed

5 files changed

+10
-85
lines changed

clang/test/CodeGenCoroutines/coro-elide-thinlto.cpp

Lines changed: 0 additions & 78 deletions
This file was deleted.

llvm/lib/Passes/PassBuilderPipelines.cpp

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -968,8 +968,7 @@ PassBuilder::buildInlinerPipeline(OptimizationLevel Level,
968968
MainCGPipeline.addPass(createCGSCCToFunctionPassAdaptor(
969969
RequireAnalysisPass<ShouldNotRunFunctionPassesAnalysis, Function>()));
970970

971-
if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
972-
MainCGPipeline.addPass(CoroSplitPass(Level != OptimizationLevel::O0));
971+
MainCGPipeline.addPass(CoroSplitPass(Level != OptimizationLevel::O0));
973972

974973
// Make sure we don't affect potential future NoRerun CGSCC adaptors.
975974
MIWP.addLateModulePass(createModuleToFunctionPassAdaptor(
@@ -1011,9 +1010,8 @@ PassBuilder::buildModuleInlinerPipeline(OptimizationLevel Level,
10111010
buildFunctionSimplificationPipeline(Level, Phase),
10121011
PTO.EagerlyInvalidateAnalyses));
10131012

1014-
if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
1015-
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
1016-
CoroSplitPass(Level != OptimizationLevel::O0)));
1013+
MPM.addPass(createModuleToPostOrderCGSCCPassAdaptor(
1014+
CoroSplitPass(Level != OptimizationLevel::O0)));
10171015

10181016
return MPM;
10191017
}
@@ -1190,8 +1188,7 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
11901188
// and argument promotion.
11911189
MPM.addPass(DeadArgumentEliminationPass());
11921190

1193-
if (Phase != ThinOrFullLTOPhase::ThinLTOPreLink)
1194-
MPM.addPass(CoroCleanupPass());
1191+
MPM.addPass(CoroCleanupPass());
11951192

11961193
// Optimize globals now that functions are fully simplified.
11971194
MPM.addPass(GlobalOptPass());

llvm/test/Other/new-pm-thinlto-prelink-defaults.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,10 +183,12 @@
183183
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
184184
; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
185185
; CHECK-O-NEXT: Running analysis: ShouldNotRunFunctionPassesAnalysis
186+
; CHECK-O-NEXT: Running pass: CoroSplitPass
186187
; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
187188
; CHECK-O-NEXT: Invalidating analysis: ShouldNotRunFunctionPassesAnalysis
188189
; CHECK-O-NEXT: Invalidating analysis: InlineAdvisorAnalysis
189190
; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
191+
; CHECK-O-NEXT: Running pass: CoroCleanupPass
190192
; CHECK-O-NEXT: Running pass: GlobalOptPass
191193
; CHECK-O-NEXT: Running pass: GlobalDCEPass
192194
; CHECK-EXT: Running pass: {{.*}}::Bye

llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,10 +182,12 @@
182182
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
183183
; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
184184
; CHECK-O-NEXT: Running analysis: ShouldNotRunFunctionPassesAnalysis
185+
; CHECK-O-NEXT: Running pass: CoroSplitPass
185186
; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
186187
; CHECK-O-NEXT: Invalidating analysis: ShouldNotRunFunctionPassesAnalysis
187188
; CHECK-O-NEXT: Invalidating analysis: InlineAdvisorAnalysis
188189
; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
190+
; CHECK-O-NEXT: Running pass: CoroCleanupPass
189191
; CHECK-O-NEXT: Running pass: GlobalOptPass
190192
; CHECK-O-NEXT: Running analysis: TargetLibraryAnalysis on bar
191193
; CHECK-O-NEXT: Running pass: GlobalDCEPass

llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,12 @@
147147
; CHECK-O-NEXT: Running pass: PostOrderFunctionAttrsPass
148148
; CHECK-O-NEXT: Running pass: RequireAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
149149
; CHECK-O-NEXT: Running analysis: ShouldNotRunFunctionPassesAnalysis
150+
; CHECK-O-NEXT: Running pass: CoroSplitPass
150151
; CHECK-O-NEXT: Running pass: InvalidateAnalysisPass<{{.*}}ShouldNotRunFunctionPassesAnalysis
151152
; CHECK-O-NEXT: Invalidating analysis: ShouldNotRunFunctionPassesAnalysis
152153
; CHECK-O-NEXT: Invalidating analysis: InlineAdvisorAnalysis
153154
; CHECK-O-NEXT: Running pass: DeadArgumentEliminationPass
155+
; CHECK-O-NEXT: Running pass: CoroCleanupPass
154156
; CHECK-O-NEXT: Running pass: GlobalOptPass
155157
; CHECK-O-NEXT: Running pass: GlobalDCEPass
156158
; CHECK-O-NEXT: Running pass: AnnotationRemarksPass on foo

0 commit comments

Comments
 (0)