diff options
author | James Y Knight <jyknight@google.com> | 2019-01-30 02:54:28 +0000 |
---|---|---|
committer | James Y Knight <jyknight@google.com> | 2019-01-30 02:54:28 +0000 |
commit | 3933addd30b4c67795abaabf1cf557152f7738c9 (patch) | |
tree | e9de1b05d84cbca89a4019e3215c60babf4f7979 /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 045bc9a4a6089d97063e373c350ff05a8641c716 (diff) | |
download | bcm5719-llvm-3933addd30b4c67795abaabf1cf557152f7738c9.tar.gz bcm5719-llvm-3933addd30b4c67795abaabf1cf557152f7738c9.zip |
Cleanup: replace uses of CallSite with CallBase.
llvm-svn: 352595
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 43 |
1 files changed, 21 insertions, 22 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 5a1b7cfe4fa..b8004452f83 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -47,7 +47,6 @@ #include "llvm/ADT/StringSwitch.h" #include "llvm/ADT/Triple.h" #include "llvm/Analysis/TargetLibraryInfo.h" -#include "llvm/IR/CallSite.h" #include "llvm/IR/CallingConv.h" #include "llvm/IR/DataLayout.h" #include "llvm/IR/Intrinsics.h" @@ -3897,9 +3896,10 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old, } // Recognize calls to the function. - llvm::CallSite callSite(user); + llvm::CallBase *callSite = dyn_cast<llvm::CallBase>(user); if (!callSite) continue; - if (!callSite.isCallee(&*use)) continue; + if (!callSite->isCallee(&*use)) + continue; // If the return types don't match exactly, then we can't // transform this call unless it's dead. @@ -3908,18 +3908,19 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old, // Get the call site's attribute list. SmallVector<llvm::AttributeSet, 8> newArgAttrs; - llvm::AttributeList oldAttrs = callSite.getAttributes(); + llvm::AttributeList oldAttrs = callSite->getAttributes(); // If the function was passed too few arguments, don't transform. unsigned newNumArgs = newFn->arg_size(); - if (callSite.arg_size() < newNumArgs) continue; + if (callSite->arg_size() < newNumArgs) + continue; // If extra arguments were passed, we silently drop them. // If any of the types mismatch, we don't transform. unsigned argNo = 0; bool dontTransform = false; for (llvm::Argument &A : newFn->args()) { - if (callSite.getArgument(argNo)->getType() != A.getType()) { + if (callSite->getArgOperand(argNo)->getType() != A.getType()) { dontTransform = true; break; } @@ -3933,35 +3934,33 @@ static void replaceUsesOfNonProtoConstant(llvm::Constant *old, // Okay, we can transform this. Create the new call instruction and copy // over the required information. - newArgs.append(callSite.arg_begin(), callSite.arg_begin() + argNo); + newArgs.append(callSite->arg_begin(), callSite->arg_begin() + argNo); // Copy over any operand bundles. - callSite.getOperandBundlesAsDefs(newBundles); + callSite->getOperandBundlesAsDefs(newBundles); - llvm::CallSite newCall; - if (callSite.isCall()) { - newCall = llvm::CallInst::Create(newFn, newArgs, newBundles, "", - callSite.getInstruction()); + llvm::CallBase *newCall; + if (dyn_cast<llvm::CallInst>(callSite)) { + newCall = + llvm::CallInst::Create(newFn, newArgs, newBundles, "", callSite); } else { - auto *oldInvoke = cast<llvm::InvokeInst>(callSite.getInstruction()); - newCall = llvm::InvokeInst::Create(newFn, - oldInvoke->getNormalDest(), - oldInvoke->getUnwindDest(), - newArgs, newBundles, "", - callSite.getInstruction()); + auto *oldInvoke = cast<llvm::InvokeInst>(callSite); + newCall = llvm::InvokeInst::Create(newFn, oldInvoke->getNormalDest(), + oldInvoke->getUnwindDest(), newArgs, + newBundles, "", callSite); } newArgs.clear(); // for the next iteration if (!newCall->getType()->isVoidTy()) - newCall->takeName(callSite.getInstruction()); - newCall.setAttributes(llvm::AttributeList::get( + newCall->takeName(callSite); + newCall->setAttributes(llvm::AttributeList::get( newFn->getContext(), oldAttrs.getFnAttributes(), oldAttrs.getRetAttributes(), newArgAttrs)); - newCall.setCallingConv(callSite.getCallingConv()); + newCall->setCallingConv(callSite->getCallingConv()); // Finally, remove the old call, replacing any uses with the new one. if (!callSite->use_empty()) - callSite->replaceAllUsesWith(newCall.getInstruction()); + callSite->replaceAllUsesWith(newCall); // Copy debug location attached to CI. if (callSite->getDebugLoc()) |