mirror of
https://github.com/RPCSX/llvm.git
synced 2024-11-27 05:30:49 +00:00
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
This commit is contained in:
parent
93ee81e5b9
commit
18d73c206e
@ -147,6 +147,11 @@ bool IPCP::PropagateConstantReturn(Function &F) {
|
||||
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());
|
||||
|
15
test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll
Normal file
15
test/Transforms/IPConstantProp/2008-06-09-WeakProp.ll
Normal file
@ -0,0 +1,15 @@
|
||||
; RUN: llvm-as < %s | opt -ipconstprop | llvm-dis | grep {ret i32 %r}
|
||||
; Should not propagate the result of a weak function.
|
||||
; PR2411
|
||||
|
||||
define weak i32 @foo() nounwind {
|
||||
entry:
|
||||
ret i32 1
|
||||
}
|
||||
|
||||
define i32 @main() nounwind {
|
||||
entry:
|
||||
%r = call i32 @foo( ) nounwind
|
||||
ret i32 %r
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user