diff options
author | Eric Christopher <echristo@gmail.com> | 2018-02-23 22:32:05 +0000 |
---|---|---|
committer | Eric Christopher <echristo@gmail.com> | 2018-02-23 22:32:05 +0000 |
commit | a70ec1308af8c56f7761daebc8be3c417fb2527b (patch) | |
tree | c9b00ab693f633c8f57648ef963f1d90c1f77220 /llvm/lib/Target/X86/X86IndirectBranchTracking.cpp | |
parent | 783a4578c14bd4a98039ae6297fe9173cd1afd51 (diff) | |
download | bcm5719-llvm-a70ec1308af8c56f7761daebc8be3c417fb2527b.tar.gz bcm5719-llvm-a70ec1308af8c56f7761daebc8be3c417fb2527b.zip |
Sink the verification code around the assert where it's handled and wrap in NDEBUG.
This has the advantage of making release only builds more warning
free and there's no need to make this routine a class function if
it isn't using class members anyhow.
llvm-svn: 325967
Diffstat (limited to 'llvm/lib/Target/X86/X86IndirectBranchTracking.cpp')
-rw-r--r-- | llvm/lib/Target/X86/X86IndirectBranchTracking.cpp | 39 |
1 files changed, 14 insertions, 25 deletions
diff --git a/llvm/lib/Target/X86/X86IndirectBranchTracking.cpp b/llvm/lib/Target/X86/X86IndirectBranchTracking.cpp index 1570e7a0b2d..f280d3db6fe 100644 --- a/llvm/lib/Target/X86/X86IndirectBranchTracking.cpp +++ b/llvm/lib/Target/X86/X86IndirectBranchTracking.cpp @@ -55,17 +55,6 @@ private: /// Endbr opcode for the current machine function. unsigned int EndbrOpcode; - /// The function looks for an indirect jump terminator in MBB predecessors. - /// - /// Jump tables are generated when lowering switch-case statements or - /// setjmp/longjump functions. - /// As a result only indirect jumps use jump tables. - /// The function verifies this assumption. - /// - /// \return true if the input \p MBB has a predecessor MBB with indirect - /// branch terminator or false otherwise. - bool verifyIndirectJump(const MachineBasicBlock *MBB) const; - /// Adds a new ENDBR instruction to the begining of the MBB. /// The function will not add it if already exists. /// It will add ENDBR32 or ENDBR64 opcode, depending on the target. @@ -80,16 +69,6 @@ FunctionPass *llvm::createX86IndirectBranchTrackingPass() { return new X86IndirectBranchTrackingPass(); } -bool X86IndirectBranchTrackingPass::verifyIndirectJump( - const MachineBasicBlock *MBB) const { - for (auto &PredMBB : MBB->predecessors()) - for (auto &TermI : PredMBB->terminators()) - if (TermI.isIndirectBranch()) - return true; - - return false; -} - void X86IndirectBranchTrackingPass::addENDBR(MachineBasicBlock &MBB) const { assert(TII && "Target instruction info was not initialized"); assert((X86::ENDBR64 == EndbrOpcode || X86::ENDBR32 == EndbrOpcode) && @@ -148,11 +127,21 @@ bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) { if (MachineJumpTableInfo *JTI = MF.getJumpTableInfo()) { for (const auto &JT : JTI->getJumpTables()) { for (auto *MBB : JT.MBBs) { - // This assert verifies the assumption that this MBB has an indirect - // jump terminator in one of its predecessor. - assert(verifyIndirectJump(MBB) && + // This assert verifies the assumption that this MBB has an indirect + // jump terminator in one of its predecessor. + // Jump tables are generated when lowering switch-case statements or + // setjmp/longjump functions. As a result only indirect jumps use jump + // tables. + #ifndef NDEBUG + bool hasIndirectJumpTerm = false; + for (auto &PredMBB : MBB->predecessors()) + for (auto &TermI : PredMBB->terminators()) + if (TermI.isIndirectBranch()) + hasIndirectJumpTerm = true; + assert(hasIndirectJumpTerm && "The MBB is not the destination of an indirect jump"); - + (void)hasIndirectJumpTerm; + #endif addENDBR(*MBB); Changed = true; } |