mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-25 20:23:11 +01:00
[CallSite removal] Move the rest of IR implementation code away from
`CallSite`. With this change, the remaining `CallSite` usages are just for implementing the wrapper type itself. This does update the C API but leaves the names of that API alone and only updates their implementation. Differential Revision: https://reviews.llvm.org/D56184 llvm-svn: 350509
This commit is contained in:
parent
5954d00ef2
commit
3a843e4591
@ -1185,6 +1185,14 @@ public:
|
|||||||
/// Return true if the callsite is an indirect call.
|
/// Return true if the callsite is an indirect call.
|
||||||
bool isIndirectCall() const;
|
bool isIndirectCall() const;
|
||||||
|
|
||||||
|
/// Determine whether the passed iterator points to the callee operand's Use.
|
||||||
|
bool isCallee(Value::const_user_iterator UI) const {
|
||||||
|
return isCallee(&UI.getUse());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Determine whether this Use is the callee operand's Use.
|
||||||
|
bool isCallee(const Use *U) const { return &getCalledOperandUse() == U; }
|
||||||
|
|
||||||
/// Helper to get the caller (the parent function).
|
/// Helper to get the caller (the parent function).
|
||||||
Function *getCaller();
|
Function *getCaller();
|
||||||
const Function *getCaller() const {
|
const Function *getCaller() const {
|
||||||
|
@ -31,7 +31,6 @@
|
|||||||
|
|
||||||
#include "llvm/ADT/APFloat.h"
|
#include "llvm/ADT/APFloat.h"
|
||||||
#include "llvm/ADT/APInt.h"
|
#include "llvm/ADT/APInt.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
|
||||||
#include "llvm/IR/Constant.h"
|
#include "llvm/IR/Constant.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/InstrTypes.h"
|
#include "llvm/IR/InstrTypes.h"
|
||||||
@ -1486,8 +1485,10 @@ template <typename Opnd_t> struct Argument_match {
|
|||||||
Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
|
Argument_match(unsigned OpIdx, const Opnd_t &V) : OpI(OpIdx), Val(V) {}
|
||||||
|
|
||||||
template <typename OpTy> bool match(OpTy *V) {
|
template <typename OpTy> bool match(OpTy *V) {
|
||||||
CallSite CS(V);
|
// FIXME: Should likely be switched to use `CallBase`.
|
||||||
return CS.isCall() && Val.match(CS.getArgument(OpI));
|
if (const auto *CI = dyn_cast<CallInst>(V))
|
||||||
|
return Val.match(CI->getArgOperand(OpI));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -36,7 +36,6 @@
|
|||||||
#include "llvm/IR/Attributes.h"
|
#include "llvm/IR/Attributes.h"
|
||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
#include "llvm/IR/CFG.h"
|
#include "llvm/IR/CFG.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
|
||||||
#include "llvm/IR/CallingConv.h"
|
#include "llvm/IR/CallingConv.h"
|
||||||
#include "llvm/IR/Comdat.h"
|
#include "llvm/IR/Comdat.h"
|
||||||
#include "llvm/IR/Constant.h"
|
#include "llvm/IR/Constant.h"
|
||||||
@ -998,9 +997,9 @@ void SlotTracker::processFunction() {
|
|||||||
|
|
||||||
// We allow direct calls to any llvm.foo function here, because the
|
// We allow direct calls to any llvm.foo function here, because the
|
||||||
// target may not be linked into the optimizer.
|
// target may not be linked into the optimizer.
|
||||||
if (auto CS = ImmutableCallSite(&I)) {
|
if (const auto *Call = dyn_cast<CallBase>(&I)) {
|
||||||
// Add all the call attributes to the table.
|
// Add all the call attributes to the table.
|
||||||
AttributeSet Attrs = CS.getAttributes().getFnAttributes();
|
AttributeSet Attrs = Call->getAttributes().getFnAttributes();
|
||||||
if (Attrs.hasAttributes())
|
if (Attrs.hasAttributes())
|
||||||
CreateAttributeSetSlot(Attrs);
|
CreateAttributeSetSlot(Attrs);
|
||||||
}
|
}
|
||||||
@ -2359,7 +2358,7 @@ public:
|
|||||||
|
|
||||||
void writeOperand(const Value *Op, bool PrintType);
|
void writeOperand(const Value *Op, bool PrintType);
|
||||||
void writeParamOperand(const Value *Operand, AttributeSet Attrs);
|
void writeParamOperand(const Value *Operand, AttributeSet Attrs);
|
||||||
void writeOperandBundles(ImmutableCallSite CS);
|
void writeOperandBundles(const CallBase *Call);
|
||||||
void writeSyncScope(const LLVMContext &Context,
|
void writeSyncScope(const LLVMContext &Context,
|
||||||
SyncScope::ID SSID);
|
SyncScope::ID SSID);
|
||||||
void writeAtomic(const LLVMContext &Context,
|
void writeAtomic(const LLVMContext &Context,
|
||||||
@ -2510,15 +2509,15 @@ void AssemblyWriter::writeParamOperand(const Value *Operand,
|
|||||||
WriteAsOperandInternal(Out, Operand, &TypePrinter, &Machine, TheModule);
|
WriteAsOperandInternal(Out, Operand, &TypePrinter, &Machine, TheModule);
|
||||||
}
|
}
|
||||||
|
|
||||||
void AssemblyWriter::writeOperandBundles(ImmutableCallSite CS) {
|
void AssemblyWriter::writeOperandBundles(const CallBase *Call) {
|
||||||
if (!CS.hasOperandBundles())
|
if (!Call->hasOperandBundles())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
Out << " [ ";
|
Out << " [ ";
|
||||||
|
|
||||||
bool FirstBundle = true;
|
bool FirstBundle = true;
|
||||||
for (unsigned i = 0, e = CS.getNumOperandBundles(); i != e; ++i) {
|
for (unsigned i = 0, e = Call->getNumOperandBundles(); i != e; ++i) {
|
||||||
OperandBundleUse BU = CS.getOperandBundleAt(i);
|
OperandBundleUse BU = Call->getOperandBundleAt(i);
|
||||||
|
|
||||||
if (!FirstBundle)
|
if (!FirstBundle)
|
||||||
Out << ", ";
|
Out << ", ";
|
||||||
|
@ -15,7 +15,6 @@
|
|||||||
#include "llvm-c/Core.h"
|
#include "llvm-c/Core.h"
|
||||||
#include "llvm/ADT/StringSwitch.h"
|
#include "llvm/ADT/StringSwitch.h"
|
||||||
#include "llvm/IR/Attributes.h"
|
#include "llvm/IR/Attributes.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DebugInfoMetadata.h"
|
#include "llvm/IR/DebugInfoMetadata.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
@ -2656,43 +2655,43 @@ unsigned LLVMGetNumArgOperands(LLVMValueRef Instr) {
|
|||||||
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
|
if (FuncletPadInst *FPI = dyn_cast<FuncletPadInst>(unwrap(Instr))) {
|
||||||
return FPI->getNumArgOperands();
|
return FPI->getNumArgOperands();
|
||||||
}
|
}
|
||||||
return CallSite(unwrap<Instruction>(Instr)).getNumArgOperands();
|
return unwrap<CallBase>(Instr)->getNumArgOperands();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--.. Call and invoke instructions ........................................--*/
|
/*--.. Call and invoke instructions ........................................--*/
|
||||||
|
|
||||||
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {
|
unsigned LLVMGetInstructionCallConv(LLVMValueRef Instr) {
|
||||||
return CallSite(unwrap<Instruction>(Instr)).getCallingConv();
|
return unwrap<CallBase>(Instr)->getCallingConv();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
|
void LLVMSetInstructionCallConv(LLVMValueRef Instr, unsigned CC) {
|
||||||
return CallSite(unwrap<Instruction>(Instr))
|
return unwrap<CallBase>(Instr)->setCallingConv(
|
||||||
.setCallingConv(static_cast<CallingConv::ID>(CC));
|
static_cast<CallingConv::ID>(CC));
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
void LLVMSetInstrParamAlignment(LLVMValueRef Instr, unsigned index,
|
||||||
unsigned align) {
|
unsigned align) {
|
||||||
CallSite Call = CallSite(unwrap<Instruction>(Instr));
|
auto *Call = unwrap<CallBase>(Instr);
|
||||||
Attribute AlignAttr = Attribute::getWithAlignment(Call->getContext(), align);
|
Attribute AlignAttr = Attribute::getWithAlignment(Call->getContext(), align);
|
||||||
Call.addAttribute(index, AlignAttr);
|
Call->addAttribute(index, AlignAttr);
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
void LLVMAddCallSiteAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
||||||
LLVMAttributeRef A) {
|
LLVMAttributeRef A) {
|
||||||
CallSite(unwrap<Instruction>(C)).addAttribute(Idx, unwrap(A));
|
unwrap<CallBase>(C)->addAttribute(Idx, unwrap(A));
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
|
unsigned LLVMGetCallSiteAttributeCount(LLVMValueRef C,
|
||||||
LLVMAttributeIndex Idx) {
|
LLVMAttributeIndex Idx) {
|
||||||
auto CS = CallSite(unwrap<Instruction>(C));
|
auto *Call = unwrap<CallBase>(C);
|
||||||
auto AS = CS.getAttributes().getAttributes(Idx);
|
auto AS = Call->getAttributes().getAttributes(Idx);
|
||||||
return AS.getNumAttributes();
|
return AS.getNumAttributes();
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
|
void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
|
||||||
LLVMAttributeRef *Attrs) {
|
LLVMAttributeRef *Attrs) {
|
||||||
auto CS = CallSite(unwrap<Instruction>(C));
|
auto *Call = unwrap<CallBase>(C);
|
||||||
auto AS = CS.getAttributes().getAttributes(Idx);
|
auto AS = Call->getAttributes().getAttributes(Idx);
|
||||||
for (auto A : AS)
|
for (auto A : AS)
|
||||||
*Attrs++ = wrap(A);
|
*Attrs++ = wrap(A);
|
||||||
}
|
}
|
||||||
@ -2700,30 +2699,28 @@ void LLVMGetCallSiteAttributes(LLVMValueRef C, LLVMAttributeIndex Idx,
|
|||||||
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
|
LLVMAttributeRef LLVMGetCallSiteEnumAttribute(LLVMValueRef C,
|
||||||
LLVMAttributeIndex Idx,
|
LLVMAttributeIndex Idx,
|
||||||
unsigned KindID) {
|
unsigned KindID) {
|
||||||
return wrap(CallSite(unwrap<Instruction>(C))
|
return wrap(
|
||||||
.getAttribute(Idx, (Attribute::AttrKind)KindID));
|
unwrap<CallBase>(C)->getAttribute(Idx, (Attribute::AttrKind)KindID));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
|
LLVMAttributeRef LLVMGetCallSiteStringAttribute(LLVMValueRef C,
|
||||||
LLVMAttributeIndex Idx,
|
LLVMAttributeIndex Idx,
|
||||||
const char *K, unsigned KLen) {
|
const char *K, unsigned KLen) {
|
||||||
return wrap(CallSite(unwrap<Instruction>(C))
|
return wrap(unwrap<CallBase>(C)->getAttribute(Idx, StringRef(K, KLen)));
|
||||||
.getAttribute(Idx, StringRef(K, KLen)));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
void LLVMRemoveCallSiteEnumAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
||||||
unsigned KindID) {
|
unsigned KindID) {
|
||||||
CallSite(unwrap<Instruction>(C))
|
unwrap<CallBase>(C)->removeAttribute(Idx, (Attribute::AttrKind)KindID);
|
||||||
.removeAttribute(Idx, (Attribute::AttrKind)KindID);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
void LLVMRemoveCallSiteStringAttribute(LLVMValueRef C, LLVMAttributeIndex Idx,
|
||||||
const char *K, unsigned KLen) {
|
const char *K, unsigned KLen) {
|
||||||
CallSite(unwrap<Instruction>(C)).removeAttribute(Idx, StringRef(K, KLen));
|
unwrap<CallBase>(C)->removeAttribute(Idx, StringRef(K, KLen));
|
||||||
}
|
}
|
||||||
|
|
||||||
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr) {
|
LLVMValueRef LLVMGetCalledValue(LLVMValueRef Instr) {
|
||||||
return wrap(CallSite(unwrap<Instruction>(Instr)).getCalledValue());
|
return wrap(unwrap<CallBase>(Instr)->getCalledValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*--.. Operations on call instructions (only) ..............................--*/
|
/*--.. Operations on call instructions (only) ..............................--*/
|
||||||
|
@ -24,7 +24,6 @@
|
|||||||
#include "llvm/IR/Argument.h"
|
#include "llvm/IR/Argument.h"
|
||||||
#include "llvm/IR/Attributes.h"
|
#include "llvm/IR/Attributes.h"
|
||||||
#include "llvm/IR/BasicBlock.h"
|
#include "llvm/IR/BasicBlock.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
|
||||||
#include "llvm/IR/Constant.h"
|
#include "llvm/IR/Constant.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DerivedTypes.h"
|
#include "llvm/IR/DerivedTypes.h"
|
||||||
@ -1257,13 +1256,13 @@ bool Function::hasAddressTaken(const User* *PutOffender) const {
|
|||||||
const User *FU = U.getUser();
|
const User *FU = U.getUser();
|
||||||
if (isa<BlockAddress>(FU))
|
if (isa<BlockAddress>(FU))
|
||||||
continue;
|
continue;
|
||||||
if (!isa<CallInst>(FU) && !isa<InvokeInst>(FU)) {
|
const auto *Call = dyn_cast<CallBase>(FU);
|
||||||
|
if (!Call) {
|
||||||
if (PutOffender)
|
if (PutOffender)
|
||||||
*PutOffender = FU;
|
*PutOffender = FU;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
ImmutableCallSite CS(cast<Instruction>(FU));
|
if (!Call->isCallee(&U)) {
|
||||||
if (!CS.isCallee(&U)) {
|
|
||||||
if (PutOffender)
|
if (PutOffender)
|
||||||
*PutOffender = FU;
|
*PutOffender = FU;
|
||||||
return true;
|
return true;
|
||||||
@ -1289,12 +1288,10 @@ bool Function::isDefTriviallyDead() const {
|
|||||||
/// callsFunctionThatReturnsTwice - Return true if the function has a call to
|
/// callsFunctionThatReturnsTwice - Return true if the function has a call to
|
||||||
/// setjmp or other function that gcc recognizes as "returning twice".
|
/// setjmp or other function that gcc recognizes as "returning twice".
|
||||||
bool Function::callsFunctionThatReturnsTwice() const {
|
bool Function::callsFunctionThatReturnsTwice() const {
|
||||||
for (const_inst_iterator
|
for (const Instruction &I : instructions(this))
|
||||||
I = inst_begin(this), E = inst_end(this); I != E; ++I) {
|
if (const auto *Call = dyn_cast<CallBase>(&I))
|
||||||
ImmutableCallSite CS(&*I);
|
if (Call->hasFnAttr(Attribute::ReturnsTwice))
|
||||||
if (CS && CS.hasFnAttr(Attribute::ReturnsTwice))
|
return true;
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,6 @@
|
|||||||
#include "llvm/ADT/DenseMap.h"
|
#include "llvm/ADT/DenseMap.h"
|
||||||
#include "llvm/ADT/SmallString.h"
|
#include "llvm/ADT/SmallString.h"
|
||||||
#include "llvm/ADT/SetVector.h"
|
#include "llvm/ADT/SetVector.h"
|
||||||
#include "llvm/IR/CallSite.h"
|
|
||||||
#include "llvm/IR/Constant.h"
|
#include "llvm/IR/Constant.h"
|
||||||
#include "llvm/IR/Constants.h"
|
#include "llvm/IR/Constants.h"
|
||||||
#include "llvm/IR/DataLayout.h"
|
#include "llvm/IR/DataLayout.h"
|
||||||
@ -503,8 +502,8 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) {
|
|||||||
return V;
|
return V;
|
||||||
V = GA->getAliasee();
|
V = GA->getAliasee();
|
||||||
} else {
|
} else {
|
||||||
if (auto CS = ImmutableCallSite(V)) {
|
if (const auto *Call = dyn_cast<CallBase>(V)) {
|
||||||
if (const Value *RV = CS.getReturnedArgOperand()) {
|
if (const Value *RV = Call->getReturnedArgOperand()) {
|
||||||
V = RV;
|
V = RV;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -512,9 +511,9 @@ static const Value *stripPointerCastsAndOffsets(const Value *V) {
|
|||||||
// but it can't be marked with returned attribute, that's why it needs
|
// but it can't be marked with returned attribute, that's why it needs
|
||||||
// special case.
|
// special case.
|
||||||
if (StripKind == PSK_ZeroIndicesAndAliasesAndInvariantGroups &&
|
if (StripKind == PSK_ZeroIndicesAndAliasesAndInvariantGroups &&
|
||||||
(CS.getIntrinsicID() == Intrinsic::launder_invariant_group ||
|
(Call->getIntrinsicID() == Intrinsic::launder_invariant_group ||
|
||||||
CS.getIntrinsicID() == Intrinsic::strip_invariant_group)) {
|
Call->getIntrinsicID() == Intrinsic::strip_invariant_group)) {
|
||||||
V = CS.getArgOperand(0);
|
V = Call->getArgOperand(0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -573,8 +572,8 @@ Value::stripAndAccumulateInBoundsConstantOffsets(const DataLayout &DL,
|
|||||||
} else if (auto *GA = dyn_cast<GlobalAlias>(V)) {
|
} else if (auto *GA = dyn_cast<GlobalAlias>(V)) {
|
||||||
V = GA->getAliasee();
|
V = GA->getAliasee();
|
||||||
} else {
|
} else {
|
||||||
if (auto CS = ImmutableCallSite(V))
|
if (const auto *Call = dyn_cast<CallBase>(V))
|
||||||
if (const Value *RV = CS.getReturnedArgOperand()) {
|
if (const Value *RV = Call->getReturnedArgOperand()) {
|
||||||
V = RV;
|
V = RV;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -608,10 +607,11 @@ uint64_t Value::getPointerDereferenceableBytes(const DataLayout &DL,
|
|||||||
DerefBytes = A->getDereferenceableOrNullBytes();
|
DerefBytes = A->getDereferenceableOrNullBytes();
|
||||||
CanBeNull = true;
|
CanBeNull = true;
|
||||||
}
|
}
|
||||||
} else if (auto CS = ImmutableCallSite(this)) {
|
} else if (const auto *Call = dyn_cast<CallBase>(this)) {
|
||||||
DerefBytes = CS.getDereferenceableBytes(AttributeList::ReturnIndex);
|
DerefBytes = Call->getDereferenceableBytes(AttributeList::ReturnIndex);
|
||||||
if (DerefBytes == 0) {
|
if (DerefBytes == 0) {
|
||||||
DerefBytes = CS.getDereferenceableOrNullBytes(AttributeList::ReturnIndex);
|
DerefBytes =
|
||||||
|
Call->getDereferenceableOrNullBytes(AttributeList::ReturnIndex);
|
||||||
CanBeNull = true;
|
CanBeNull = true;
|
||||||
}
|
}
|
||||||
} else if (const LoadInst *LI = dyn_cast<LoadInst>(this)) {
|
} else if (const LoadInst *LI = dyn_cast<LoadInst>(this)) {
|
||||||
@ -683,8 +683,8 @@ unsigned Value::getPointerAlignment(const DataLayout &DL) const {
|
|||||||
if (AllocatedType->isSized())
|
if (AllocatedType->isSized())
|
||||||
Align = DL.getPrefTypeAlignment(AllocatedType);
|
Align = DL.getPrefTypeAlignment(AllocatedType);
|
||||||
}
|
}
|
||||||
} else if (auto CS = ImmutableCallSite(this))
|
} else if (const auto *Call = dyn_cast<CallBase>(this))
|
||||||
Align = CS.getAttributes().getRetAlignment();
|
Align = Call->getAttributes().getRetAlignment();
|
||||||
else if (const LoadInst *LI = dyn_cast<LoadInst>(this))
|
else if (const LoadInst *LI = dyn_cast<LoadInst>(this))
|
||||||
if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
|
if (MDNode *MD = LI->getMetadata(LLVMContext::MD_align)) {
|
||||||
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
|
ConstantInt *CI = mdconst::extract<ConstantInt>(MD->getOperand(0));
|
||||||
|
Loading…
Reference in New Issue
Block a user