[BOLT] Skip the validation of CFG after it is finalized

When current state is `CFG_Finalized`, function `validateCFG()` should return true directly.

Reviewed By: maksfb, yota9, Kepontry

Differential Revision: https://reviews.llvm.org/D159410
This commit is contained in:
zhoujiapeng 2023-09-17 00:07:14 +08:00 committed by hezuoqiang
parent 5e4e2a5aae
commit 16fd879980
2 changed files with 12 additions and 0 deletions

View File

@ -3156,6 +3156,10 @@ void BinaryFunction::dumpGraphToFile(std::string Filename) const {
} }
bool BinaryFunction::validateCFG() const { bool BinaryFunction::validateCFG() const {
// Skip the validation of CFG after it is finalized
if (CurrentState == State::CFG_Finalized)
return true;
bool Valid = true; bool Valid = true;
for (BinaryBasicBlock *BB : BasicBlocks) for (BinaryBasicBlock *BB : BasicBlocks)
Valid &= BB->validateSuccessorInvariants(); Valid &= BB->validateSuccessorInvariants();

View File

@ -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 {{.*}}