Index: bolt/lib/Core/BinaryFunction.cpp =================================================================== --- bolt/lib/Core/BinaryFunction.cpp +++ bolt/lib/Core/BinaryFunction.cpp @@ -3156,6 +3156,11 @@ } bool BinaryFunction::validateCFG() const { + // Skip the validation of CFG after it is finalized + if (CurrentState == State::CFG_Finalized) { + return true; + } + bool Valid = true; for (BinaryBasicBlock *BB : BasicBlocks) Valid &= BB->validateSuccessorInvariants(); Index: bolt/test/verify-cfg.test =================================================================== --- /dev/null +++ bolt/test/verify-cfg.test @@ -0,0 +1,8 @@ +# Verify if the `--verify-cfg` option might produce incorrect alerts. + +REQUIRES: system-linux + +RUN: %clang %cflags %p/Inputs/hello.c -o %t -Wl,-q +RUN: llvm-bolt %t -o %t.bolt --verify-cfg 2>&1 | FileCheck %s + +CHECK-NOT: BOLT-ERROR: Invalid CFG detected after pass {{.*}}