[PATCH] D47067: Update NRVO logic to support early return

Richard Smith - zygoloid via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed May 30 12:36:35 PDT 2018


rsmith added a comment.

Based on the ASan output, it looks like the miscompile is probably happening in `SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getValueState(LatticeKey)` at around include/llvm/Analysis/SparsePropagation.h:240:

  template <class LatticeKey, class LatticeVal, class KeyInfo>
  LatticeVal
  SparseSolver<LatticeKey, LatticeVal, KeyInfo>::getValueState(LatticeKey Key) {
    auto I = ValueState.find(Key);
    if (I != ValueState.end())
      return I->second; // Common case, in the map
  
    if (LatticeFunc->IsUntrackedValue(Key))
      return LatticeFunc->getUntrackedVal();
    LatticeVal LV = LatticeFunc->ComputeLatticeVal(Key);
  
    // If this value is untracked, don't add it to the map.
    if (LV == LatticeFunc->getUntrackedVal())
      return LV;
    return ValueState[Key] = LV;
  }

I'm guessing we somehow get confused about whether `LV` is an NRVO variable during template instantiation, and apply NRVO to it despite there being a return of something else in its scope.


Repository:
  rC Clang

https://reviews.llvm.org/D47067





More information about the cfe-commits mailing list