[llvm] [InstrProf] Support conditional counter updates (PR #102542)

NAKAMURA Takumi via llvm-commits llvm-commits at lists.llvm.org
Mon Sep 30 23:20:22 PDT 2024


================
@@ -1213,6 +1218,17 @@ Value *InstrLowerer::getBitmapAddress(InstrProfMCDCTVBitmapUpdate *I) {
 void InstrLowerer::lowerCover(InstrProfCoverInst *CoverInstruction) {
   auto *Addr = getCounterAddress(CoverInstruction);
   IRBuilder<> Builder(CoverInstruction);
+  if (ConditionalCounterUpdate) {
+    Instruction *SplitBefore = CoverInstruction->getNextNode();
+    auto &Ctx = CoverInstruction->getParent()->getContext();
+    auto *Int8Ty = llvm::Type::getInt8Ty(Ctx);
+    Value *Load = Builder.CreateLoad(Int8Ty, Addr, "pgocount");
+    Value *Cmp = Builder.CreateIsNotNull(Load, "pgocount.ifnonzero");
+    Instruction *ThenBranch =
+        SplitBlockAndInsertIfThen(Cmp, SplitBefore, false);
----------------
chapuni wrote:

@ellishg Can we create an additional block here? I remember the past discussion. https://github.com/llvm/llvm-project/pull/95585#issuecomment-2176679946

https://github.com/llvm/llvm-project/pull/102542


More information about the llvm-commits mailing list