[PATCH] D148903: [PGO] Avoid potential const_cast UB (NFC)

Christian Ulmann via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 24 23:54:30 PDT 2023


Dinistro added a comment.

Added a comment to the critical UB causing part. Again, while there might be a way to keep constness, it requires extended changes. Fixing UB should be done first, afterwards, we can think about refactorings that allow us to keep constness where possible.



================
Comment at: llvm/lib/Transforms/Instrumentation/PGOInstrumentation.cpp:840
   BasicBlock *InstrBB =
       isa<IndirectBrInst>(TI) ? nullptr : SplitCriticalEdge(TI, SuccNum);
   if (!InstrBB) {
----------------
This full function is shared between the instrumentation and the use pass. Keeping const will always result in UB, as the SplitCriticalEdge function will be called with `TI`, which should be of type `const Instruction *`.
I fail to see how a templated edge class would help in resolving this issue, could you elaborate @xur ?

I believe that splitting the logic between instrument and usage might help to reduce the complexity and push const in some places, but that requires extended changes to the algorithms. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D148903



More information about the llvm-commits mailing list