diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -3156,6 +3156,10 @@ } 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(); diff --git a/bolt/test/verify-cfg.test b/bolt/test/verify-cfg.test new file mode 100644 --- /dev/null +++ b/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 {{.*}}