[PATCH] D19776: [CFLAA] Fix an error which cause cfl-aa to crash the compiler

Jia Chen via llvm-commits llvm-commits at lists.llvm.org
Sun May 1 12:54:33 PDT 2016


grievejia created this revision.
grievejia added reviewers: hfinkel, george.burgess.iv.
grievejia added a subscriber: llvm-commits.

The bug was caused by updating a reference to a stale DenseMap entry after the map has been resized. Grabbing the reference after the resize fixes it.

http://reviews.llvm.org/D19776

Files:
  lib/Analysis/CFLAliasAnalysis.cpp

Index: lib/Analysis/CFLAliasAnalysis.cpp
===================================================================
--- lib/Analysis/CFLAliasAnalysis.cpp
+++ lib/Analysis/CFLAliasAnalysis.cpp
@@ -994,7 +994,12 @@
   assert(InsertPair.second &&
          "Trying to scan a function that has already been cached");
 
-  Cache[Fn] = buildSetsFrom(Fn);
+  // Note that we can't do Cache[Fn] = buildSetsFrom(Fn) here: the function call
+  // may get evaluated after operator[], potentially triggering a DenseMap
+  // resize and invalidating the reference returned by operator[]
+  auto FunInfo = buildSetsFrom(Fn);
+  Cache[Fn] = std::move(FunInfo);
+
   Handles.push_front(FunctionHandle(Fn, this));
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D19776.55754.patch
Type: text/x-patch
Size: 695 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160501/468f66a0/attachment.bin>


More information about the llvm-commits mailing list