diff options
author | Wu Yingcong <yingcong.wu@intel.com> | 2024-11-21 14:13:08 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-11-21 14:13:08 +0800 |
commit | 42775a44c9a6ba8dc03ad4c88fa9321e78ebd434 (patch) | |
tree | dc48f365c876d5c05de1f648c98286ac7263fee4 /llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | |
parent | 32913724acf9e02beed46999fee1424086b8c884 (diff) | |
download | llvm-42775a44c9a6ba8dc03ad4c88fa9321e78ebd434.zip llvm-42775a44c9a6ba8dc03ad4c88fa9321e78ebd434.tar.gz llvm-42775a44c9a6ba8dc03ad4c88fa9321e78ebd434.tar.bz2 |
[ControlHeightReduction] Add assert to avoid underflow (#116339)
`NumCHRedBranches - 1` is used later, we should add an assertion to make
sure it will not underflow.
Diffstat (limited to 'llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp')
-rw-r--r-- | llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp index c8ee933..b3883cd 100644 --- a/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp +++ b/llvm/lib/Transforms/Instrumentation/ControlHeightReduction.cpp @@ -1862,6 +1862,7 @@ void CHR::fixupBranchesAndSelects(CHRScope *Scope, ++NumCHRedBranches; } } + assert(NumCHRedBranches > 0); Stats.NumBranchesDelta += NumCHRedBranches - 1; Stats.WeightedNumBranchesDelta += (NumCHRedBranches - 1) * ProfileCount; ORE.emit([&]() { |