<div dir="auto">I've been working on bug 20811 and have been stuck for some time now. I made the following changes to the GVN.cpp file, but these changes have not been able to fix the issue, i.e., the load is still not replaced with undef<div dir="auto"><br></div><div dir="auto">Added function:</div><div dir="auto"><br></div><div dir="auto"><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)">static bool isLifetimeEnd(const Instruction *Inst) {
  if (const IntrinsicInst* II = dyn_cast<IntrinsicInst>(Inst))
    return II->getIntrinsicID() == Intrinsic::lifetime_end;
  return false;
}

<br></pre><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)">And modified the following line:</pre><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)">

if (isa<AllocaInst>(DepInst) || isMallocLikeFn(DepInst, TLI) ||
    isLifetimeStart(DepInst) || isLifetimeEnd(DepInst)) { <-- added isLifetimeEnd()
  Res = AvailableValue::get(UndefValue::get(LI->getType()));
  return true;
}</pre><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)"><br></pre><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)">Link to the bug: <a href="https://bugs.llvm.org/show_bug.cgi?id=20811">https://bugs.llvm.org/show_bug.cgi?id=20811</a></pre><pre style="font-size:medium;white-space:pre-wrap;width:50em;background-color:rgb(255,255,255)"><br></pre></div></div>