From 35db3b9aad1829a1279b9e213ddee36395314a0b Mon Sep 17 00:00:00 2001 From: Gabor Greif Date: Sat, 10 Apr 2010 03:45:50 +0000 Subject: [PATCH] rely even less on CallInst internals git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@100919 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CodeGenModule.cpp | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/lib/CodeGen/CodeGenModule.cpp b/lib/CodeGen/CodeGenModule.cpp index 2dd2d58308..3a59c4cf3d 100644 --- a/lib/CodeGen/CodeGenModule.cpp +++ b/lib/CodeGen/CodeGenModule.cpp @@ -1203,11 +1203,11 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, llvm::SmallVector ArgList; for (llvm::Value::use_iterator UI = OldFn->use_begin(), E = OldFn->use_end(); - UI != E; ) { + UI != E; ++UI) { // 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 || OpNo != 0) continue; + llvm::CallInst *CI = dyn_cast(*UI); + llvm::CallSite CS(CI); + if (!CI || !CS.isCallee(UI)) continue; // If the return types don't match exactly, and if the call isn't dead, then // we can't transform this call. @@ -1221,8 +1221,8 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, bool DontTransform = false; for (llvm::Function::arg_iterator AI = NewFn->arg_begin(), E = NewFn->arg_end(); AI != E; ++AI, ++ArgNo) { - if (CI->getNumOperands()-1 == ArgNo || - CI->getOperand(ArgNo+1)->getType() != AI->getType()) { + if (CS.arg_size() == ArgNo || + CS.getArgument(ArgNo)->getType() != AI->getType()) { DontTransform = true; break; } @@ -1232,7 +1232,6 @@ static void ReplaceUsesOfNonProtoTypeWithRealFunction(llvm::GlobalValue *Old, // Okay, we can transform this. Create the new call instruction and copy // over the required information. - llvm::CallSite CS(CI); ArgList.append(CS.arg_begin(), CS.arg_begin() + ArgNo); llvm::CallInst *NewCall = llvm::CallInst::Create(NewFn, ArgList.begin(), ArgList.end(), "", CI); -- 2.40.0