|
40 | 40 | #include "llvm/IR/Instruction.h" |
41 | 41 | #include "llvm/IR/Instructions.h" |
42 | 42 | #include "llvm/IR/IntrinsicInst.h" |
| 43 | +#include "llvm/IR/MDBuilder.h" |
43 | 44 | #include "llvm/IR/Module.h" |
44 | 45 | #include "llvm/IR/PatternMatch.h" |
45 | 46 | #include "llvm/IR/ProfDataUtils.h" |
@@ -2831,9 +2832,14 @@ static BranchInst *turnGuardIntoBranch(IntrinsicInst *GI, Loop &L, |
2831 | 2832 | MSSAU->getMemorySSA()->verifyMemorySSA(); |
2832 | 2833 |
|
2833 | 2834 | DomTreeUpdater DTU(DT, DomTreeUpdater::UpdateStrategy::Eager); |
2834 | | - Instruction *DeoptBlockTerm = |
2835 | | - SplitBlockAndInsertIfThen(GI->getArgOperand(0), GI, true, |
2836 | | - GI->getMetadata(LLVMContext::MD_prof), &DTU, &LI); |
| 2835 | + // llvm.experimental.guard doesn't have branch weights. We can assume, |
| 2836 | + // however, that the deopt path is unlikely. |
| 2837 | + Instruction *DeoptBlockTerm = SplitBlockAndInsertIfThen( |
| 2838 | + GI->getArgOperand(0), GI, true, |
| 2839 | + !ProfcheckDisableMetadataFixes && EstimateProfile |
| 2840 | + ? MDBuilder(GI->getContext()).createUnlikelyBranchWeights() |
| 2841 | + : nullptr, |
| 2842 | + &DTU, &LI); |
2837 | 2843 | BranchInst *CheckBI = cast<BranchInst>(CheckBB->getTerminator()); |
2838 | 2844 | // SplitBlockAndInsertIfThen inserts control flow that branches to |
2839 | 2845 | // DeoptBlockTerm if the condition is true. We want the opposite. |
|
0 commit comments