[PATCH] D77417: [BFI][CGP] Add limited support for detecting missed BFI updates and fix one in CodeGenPrepare.

Hiroshi Yamauchi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 8 10:51:42 PDT 2020


yamauchi added inline comments.


================
Comment at: llvm/include/llvm/Analysis/BlockFrequencyInfoImpl.h:1467
+    }
+    for (auto &Entry : OtherValidNodes) {
+      const BlockT* OtherBB = Entry.first;
----------------
davidxl wrote:
> If there is no mismatch detected at this point, the following check is redundant.
If there's a valid block in the Other BFI that's not in this BFI, this code is useful, as the comparison goes both ways?


================
Comment at: llvm/lib/CodeGen/CodeGenPrepare.cpp:2220
+    BFI->setBlockFreq(BB,
+        (BFI->getBlockFreq(BB) - BFI->getBlockFreq(TailCallBB)).getFrequency());
     ModifiedDT = Changed = true;
----------------
davidxl wrote:
> Add assert that BB's frequency >= TailCallBB's freq?
Added one only under this check mode as I think the assert outside this BFI update check mode would be too strong at this point. Note that BlockFrequency avoids an underflow.


```
BlockFrequency &BlockFrequency::operator-=(BlockFrequency Freq) {
  // If underflow, set frequency to 0.
  if (Frequency <= Freq.Frequency)
    Frequency = 0;
  else
    Frequency -= Freq.Frequency;
  return *this;
}
```



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D77417/new/

https://reviews.llvm.org/D77417





More information about the llvm-commits mailing list