[PATCH] D62126: [CorrelatedValuePropagation] Fix prof branch_weights metadata handling for SwitchInst

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat May 25 10:14:08 PDT 2019


nikic added inline comments.


================
Comment at: llvm/lib/Transforms/Scalar/CorrelatedValuePropagation.cpp:398
     ConstantFoldTerminator(BB, /*DeleteDeadConditions = */ false,
                            /*TLI = */ nullptr, &DTU);
   return Changed;
----------------
I think that something can go wrong here... Consider a case where we have a switch with branch weights, then we remove the first case (so that Changed=true in SwitchInstProfBranchWeightsWrapper), then we find that the second case is always true, such that this constant folding call will erase the switch, leaving behind a dangling reference in SwitchInstProfBranchWeightsWrapper, which will be accessed when the destructor runs at the end of the function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62126





More information about the llvm-commits mailing list