Fix PR2411, where ip constant prop would propagate the
result of a weak function.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52137 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/IPO/IPConstantPropagation.cpp b/lib/Transforms/IPO/IPConstantPropagation.cpp
index 792fa98..4ebdaf3 100644
--- a/lib/Transforms/IPO/IPConstantPropagation.cpp
+++ b/lib/Transforms/IPO/IPConstantPropagation.cpp
@@ -147,6 +147,11 @@
   if (F.getReturnType() == Type::VoidTy)
     return false; // No return value.
 
+  // If this function could be overridden later in the link stage, we can't
+  // propagate information about its results into callers.
+  if (F.hasLinkOnceLinkage() || F.hasWeakLinkage())
+    return false;
+  
   // Check to see if this function returns a constant.
   SmallVector<Value *,4> RetVals;
   const StructType *STy = dyn_cast<StructType>(F.getReturnType());