[PATCH] D62624: [InstCombine] Avoid use after free in DenseMap, when built with GCC

Martin Storsjö via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 30 13:53:18 PDT 2019


This revision was automatically updated to reflect the committed changes.
Closed by commit rL362150: [InstCombine] Avoid use after free in DenseMap, when built with GCC (authored by mstorsjo, committed by ).

Changed prior to commit:
  https://reviews.llvm.org/D62624?vs=202039&id=202296#toc

Repository:
  rL LLVM

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

https://reviews.llvm.org/D62624

Files:
  llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp


Index: llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
===================================================================
--- llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
+++ llvm/trunk/lib/Transforms/InstCombine/InstCombineCompares.cpp
@@ -703,7 +703,10 @@
       continue;
 
     if (auto *CI = dyn_cast<CastInst>(Val)) {
-      NewInsts[CI] = NewInsts[CI->getOperand(0)];
+      // Don't get rid of the intermediate variable here; the store can grow
+      // the map which will invalidate the reference to the input value.
+      Value *V = NewInsts[CI->getOperand(0)];
+      NewInsts[CI] = V;
       continue;
     }
     if (auto *GEP = dyn_cast<GEPOperator>(Val)) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62624.202296.patch
Type: text/x-patch
Size: 706 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/be6ae725/attachment.bin>


More information about the llvm-commits mailing list