[PATCH] D43758: [CGP] Fix the remove of matched phis in complex addressing mode

John Brawn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 6 08:11:10 PST 2018


john.brawn added inline comments.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:2952
         for (auto MV : Matched) {
+          auto AlreadyMatched = DoneMatched.find(MV.first);
+          if (AlreadyMatched != DoneMatched.end()) {
----------------
MV.first has already been deleted by this point, and using the value of a deleted pointer is undefined behaviour (even if you're not dereferencing it). I think this can be solved by splitting this into two loops: one which just builds up DoneMatched (which would probably be clearer if you named it something like MatchedPHINodeMapping), and then a second which iterates over DoneMatched and does the actual replacing and erasing.


================
Comment at: lib/CodeGen/CodeGenPrepare.cpp:2955
+            // We have phi node which matches to different
+            // but identiacal phis. So make a simplification then.
+            MV.first = MV.second;
----------------
> identiacal
identical


https://reviews.llvm.org/D43758





More information about the llvm-commits mailing list