From 0261e5c960730d894d83d6b3f16e4580189bb3ee Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Thu, 4 Jun 2009 16:47:43 +0000 Subject: [PATCH] Make ReplaceUsesOfNonProtoTypeWithRealFunction verify that a call is *to* the function of interest, not an operand of it. llvm-svn: 72869 --- clang/lib/CodeGen/CodeGenModule.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index b69301ed5893..6e8440a17738 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -891,8 +891,9 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, for (llvm::Value::use_iterator UI = OldFn->use_begin(), E = OldFn->use_end(); UI != E; ) { // TODO: Do invokes ever occur in C code? If so, we should handle them too. + unsigned OpNo = UI.getOperandNo(); llvm::CallInst *CI = dyn_cast(*UI++); - if (!CI) continue; + if (!CI || OpNo != 0) continue; // If the return types don't match exactly, and if the call isn't dead, then // we can't transform this call.