diff options
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Utils/MisExpect.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/Transforms/Utils/MisExpect.cpp b/llvm/lib/Transforms/Utils/MisExpect.cpp index aef9d82..7592893 100644 --- a/llvm/lib/Transforms/Utils/MisExpect.cpp +++ b/llvm/lib/Transforms/Utils/MisExpect.cpp @@ -151,9 +151,15 @@ void verifyMisExpect(Instruction &I, ArrayRef<uint32_t> RealWeights, uint64_t TotalBranchWeight = LikelyBranchWeight + (UnlikelyBranchWeight * NumUnlikelyTargets); - // Failing this assert means that we have corrupted metadata. - assert((TotalBranchWeight >= LikelyBranchWeight) && (TotalBranchWeight > 0) && - "TotalBranchWeight is less than the Likely branch weight"); + // FIXME: When we've addressed sample profiling, restore the assertion + // + // We cannot calculate branch probability if either of these invariants aren't + // met. However, MisExpect diagnostics should not prevent code from compiling, + // so we simply forgo emitting diagnostics here, and return early. + // assert((TotalBranchWeight >= LikelyBranchWeight) && (TotalBranchWeight > 0) + // && "TotalBranchWeight is less than the Likely branch weight"); + if ((TotalBranchWeight == 0) || (TotalBranchWeight <= LikelyBranchWeight)) + return; // To determine our threshold value we need to obtain the branch probability // for the weights added by llvm.expect and use that proportion to calculate @@ -180,13 +186,6 @@ void verifyMisExpect(Instruction &I, ArrayRef<uint32_t> RealWeights, void checkBackendInstrumentation(Instruction &I, const ArrayRef<uint32_t> RealWeights) { - // Backend checking assumes any existing weight comes from an `llvm.expect` - // intrinsic. However, SampleProfiling + ThinLTO add branch weights multiple - // times, leading to an invalid assumption in our checking. Backend checks - // should only operate on branch weights that carry the "!expected" field, - // since they are guaranteed to be added by the LowerExpectIntrinsic pass. - if (!hasBranchWeightOrigin(I)) - return; SmallVector<uint32_t> ExpectedWeights; if (!extractBranchWeights(I, ExpectedWeights)) return; |