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

Juan Manuel Martinez CaamaƱo via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 12 04:46:27 PDT 2024


================
@@ -1213,6 +1218,18 @@ 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.CreateICmpNE(Load, ConstantInt::get(Int8Ty, 0),
+                                      "pgocount.ifnonzero");
----------------
jmmartinez wrote:

What do you think about using `IRBuilderBase::CreateIsNotNull` ?

```suggestion
    Value *Cmp = Builder.CreateIsNotNull(Load, "pgocount.ifnonzero");
```

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


More information about the llvm-commits mailing list