[llvm] [InstrProf] Support conditional counter updates (PR #102542)
Alan Zhao via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 9 10:26:42 PDT 2024
================
@@ -1213,8 +1213,20 @@ Value *InstrLowerer::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
void InstrLowerer::lowerCover(InstrProfCoverInst *CoverInstruction) {
auto *Addr = getCounterAddress(CoverInstruction);
IRBuilder<> Builder(CoverInstruction);
- // We store zero to represent that this block is covered.
- Builder.CreateStore(Builder.getInt8(0), Addr);
+ if (ConditionalCounterUpdate) {
+ auto &Ctx = CoverInstruction->getParent()->getContext();
+ auto *Int8Ty = llvm::Type::getInt8Ty(Ctx);
+ Value *Load = Builder.CreateLoad(Int8Ty, Addr, "pgocount");
+ Value *Cmp = Builder.CreateICmpNE(Load, ConstantInt::get(Int8Ty, 0),
+ "pgocount.ifnonzero");
+ Value *Sel =
+ Builder.CreateSelect(Cmp, Builder.getInt8(0), Load, "pgocount.select");
----------------
alanzhao1 wrote:
I think the `break` is no longer necessary after https://github.com/llvm/llvm-project/pull/69535 since that code is no longer in the for loop iterating through the basic blocks.
https://github.com/llvm/llvm-project/pull/102542
More information about the llvm-commits
mailing list