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

via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 13 19:21:28 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");
----------------
gulfemsavrun wrote:

`CreateICmpNE` sounds more intuitive to me in this case. Is there an advantage of using `CreateIsNotNull` over `CreateICmpNE`?

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


More information about the llvm-commits mailing list