[Attributor][FIX] Remove reference into map that might dangle
authorJohannes Doerfert <johannes@jdoerfert.de>
Thu, 17 Mar 2022 22:37:15 +0000 (17:37 -0500)
committerJohannes Doerfert <johannes@jdoerfert.de>
Thu, 17 Mar 2022 22:42:32 +0000 (17:42 -0500)
The reference was taken and the map was modified after. This can (and
did) lead to dangling pointers and all sorts of problems afterwards.

llvm/lib/Transforms/IPO/AttributorAttributes.cpp

index e9257ad28039ba4a6c19d76649b79ec514ab21fa..a2d50093aeb8621d364db0b3e61d76da686dba40 100644 (file)
@@ -1344,7 +1344,7 @@ struct AAPointerInfoFloating : public AAPointerInfoImpl {
     DenseMap<Value *, OffsetInfo> OffsetInfoMap;
     OffsetInfoMap[&AssociatedValue] = OffsetInfo{0};
 
-    auto HandlePassthroughUser = [&](Value *Usr, OffsetInfo &PtrOI,
+    auto HandlePassthroughUser = [&](Value *Usr, OffsetInfo PtrOI,
                                      bool &Follow) {
       OffsetInfo &UsrOI = OffsetInfoMap[Usr];
       UsrOI = PtrOI;