Skip to content

Commit 4c3904b

Browse files
authored
Merge pull request #426 from schweitzpgi/ch-cfgbug
Fixes the CFG bug with explicit (trivially dominating) terminator.
2 parents cf095f5 + e4714f8 commit 4c3904b

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

flang/lib/Lower/Bridge.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -544,14 +544,17 @@ class FirConverter : public Fortran::lower::AbstractConverter {
544544
genFIRConditionalBranch(cond, trueTarget->block, falseTarget->block);
545545
}
546546

547-
//
547+
//===----------------------------------------------------------------------===//
548548
// Termination of symbolically referenced execution units
549-
//
549+
//===----------------------------------------------------------------------===//
550550

551551
/// END of program
552552
///
553553
/// Generate the cleanup block before the program exits
554-
void genExitRoutine() { builder->create<mlir::ReturnOp>(toLocation()); }
554+
void genExitRoutine() {
555+
if (blockIsUnterminated())
556+
builder->create<mlir::ReturnOp>(toLocation());
557+
}
555558
void genFIR(const Fortran::parser::EndProgramStmt &) { genExitRoutine(); }
556559

557560
/// END of procedure-like constructs

0 commit comments

Comments
 (0)