[PATCH] LICM: Don't crash when an instruction is used by an unreachable BB

Chandler Carruth chandlerc at gmail.com
Tue Sep 2 01:49:40 PDT 2014


Minor code tweak. Otherwise looks good.

================
Comment at: lib/Transforms/Scalar/LICM.cpp:601
@@ +600,3 @@
+    Instruction *User = I.user_back();
+    if (DT->isReachableFromEntry(User->getParent())) {
+      // The user must be a PHI node.
----------------
I think this would be more clear as:

  if (!DT->isReachableFromEntry(User->getParent())) {
    User->replaceUsesOfWith(...);
    continue;
  }

That localizes the unreachable -> undef logic and reduces the indent for the rest.

http://reviews.llvm.org/D5146






More information about the llvm-commits mailing list