Look through phi nodes and select instructions when
calculating nocapture attributes.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61535 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp
index 1824a71..52be0c9 100644
--- a/lib/Transforms/IPO/FunctionAttrs.cpp
+++ b/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -225,9 +225,14 @@
       continue;
     }
 
-    if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I)) {
-      // Type conversion or calculating an offset.  Does not escape if the new
-      // value doesn't.
+    if (isa<BitCastInst>(I) || isa<GetElementPtrInst>(I) ||
+        isa<PHINode>(I) || isa<SelectInst>(I)) {
+      // Type conversion, calculating an offset, or merging values.
+      // The original value does not escape via this if the new value doesn't.
+      // Note that in the case of a select instruction it is important that
+      // the value not be used as the condition, since otherwise one bit of
+      // information might escape.  It cannot be the condition because it has
+      // the wrong type.
       for (Instruction::use_iterator UI = I->use_begin(), UE = I->use_end();
            UI != UE; ++UI) {
         Use *U = &UI.getUse();