forked from OSchip/llvm-project
[opaque pointer types] More trivial changes to pass FunctionType to CallInst.
Change various functions to use FunctionCallee or Function*. Pass function type through __builtin_dump_struct's dumpRecord helper. llvm-svn: 353199
This commit is contained in:
parent
b0afc69435
commit
76f787424d
|
@ -1331,8 +1331,8 @@ EmitCheckedMixedSignMultiply(CodeGenFunction &CGF, const clang::Expr *Op1,
|
||||||
}
|
}
|
||||||
|
|
||||||
static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
|
static llvm::Value *dumpRecord(CodeGenFunction &CGF, QualType RType,
|
||||||
Value *&RecordPtr, CharUnits Align, Value *Func,
|
Value *&RecordPtr, CharUnits Align,
|
||||||
int Lvl) {
|
llvm::FunctionCallee Func, int Lvl) {
|
||||||
const auto *RT = RType->getAs<RecordType>();
|
const auto *RT = RType->getAs<RecordType>();
|
||||||
ASTContext &Context = CGF.getContext();
|
ASTContext &Context = CGF.getContext();
|
||||||
RecordDecl *RD = RT->getDecl()->getDefinition();
|
RecordDecl *RD = RT->getDecl()->getDefinition();
|
||||||
|
@ -1736,6 +1736,10 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
|
||||||
}
|
}
|
||||||
|
|
||||||
case Builtin::BI__builtin_dump_struct: {
|
case Builtin::BI__builtin_dump_struct: {
|
||||||
|
llvm::Type *LLVMIntTy = getTypes().ConvertType(getContext().IntTy);
|
||||||
|
llvm::FunctionType *LLVMFuncType = llvm::FunctionType::get(
|
||||||
|
LLVMIntTy, {llvm::Type::getInt8PtrTy(getLLVMContext())}, true);
|
||||||
|
|
||||||
Value *Func = EmitScalarExpr(E->getArg(1)->IgnoreImpCasts());
|
Value *Func = EmitScalarExpr(E->getArg(1)->IgnoreImpCasts());
|
||||||
CharUnits Arg0Align = EmitPointerWithAlignment(E->getArg(0)).getAlignment();
|
CharUnits Arg0Align = EmitPointerWithAlignment(E->getArg(0)).getAlignment();
|
||||||
|
|
||||||
|
@ -1743,7 +1747,8 @@ RValue CodeGenFunction::EmitBuiltinExpr(const GlobalDecl GD, unsigned BuiltinID,
|
||||||
QualType Arg0Type = Arg0->getType()->getPointeeType();
|
QualType Arg0Type = Arg0->getType()->getPointeeType();
|
||||||
|
|
||||||
Value *RecordPtr = EmitScalarExpr(Arg0);
|
Value *RecordPtr = EmitScalarExpr(Arg0);
|
||||||
Value *Res = dumpRecord(*this, Arg0Type, RecordPtr, Arg0Align, Func, 0);
|
Value *Res = dumpRecord(*this, Arg0Type, RecordPtr, Arg0Align,
|
||||||
|
{LLVMFuncType, Func}, 0);
|
||||||
return RValue::get(Res);
|
return RValue::get(Res);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2201,7 +2201,7 @@ void CodeGenFunction::pushRegularPartialArrayCleanup(llvm::Value *arrayBegin,
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lazily declare the @llvm.lifetime.start intrinsic.
|
/// Lazily declare the @llvm.lifetime.start intrinsic.
|
||||||
llvm::Constant *CodeGenModule::getLLVMLifetimeStartFn() {
|
llvm::Function *CodeGenModule::getLLVMLifetimeStartFn() {
|
||||||
if (LifetimeStartFn)
|
if (LifetimeStartFn)
|
||||||
return LifetimeStartFn;
|
return LifetimeStartFn;
|
||||||
LifetimeStartFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
LifetimeStartFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
||||||
|
@ -2210,7 +2210,7 @@ llvm::Constant *CodeGenModule::getLLVMLifetimeStartFn() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Lazily declare the @llvm.lifetime.end intrinsic.
|
/// Lazily declare the @llvm.lifetime.end intrinsic.
|
||||||
llvm::Constant *CodeGenModule::getLLVMLifetimeEndFn() {
|
llvm::Function *CodeGenModule::getLLVMLifetimeEndFn() {
|
||||||
if (LifetimeEndFn)
|
if (LifetimeEndFn)
|
||||||
return LifetimeEndFn;
|
return LifetimeEndFn;
|
||||||
LifetimeEndFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
LifetimeEndFn = llvm::Intrinsic::getDeclaration(&getModule(),
|
||||||
|
|
|
@ -278,7 +278,7 @@ void CodeGenFunction::FinishThunk() {
|
||||||
FinishFunction();
|
FinishFunction();
|
||||||
}
|
}
|
||||||
|
|
||||||
void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
void CodeGenFunction::EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
|
||||||
const ThunkInfo *Thunk,
|
const ThunkInfo *Thunk,
|
||||||
bool IsUnprototyped) {
|
bool IsUnprototyped) {
|
||||||
assert(isa<CXXMethodDecl>(CurGD.getDecl()) &&
|
assert(isa<CXXMethodDecl>(CurGD.getDecl()) &&
|
||||||
|
@ -303,7 +303,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
||||||
CGM.ErrorUnsupported(
|
CGM.ErrorUnsupported(
|
||||||
MD, "non-trivial argument copy for return-adjusting thunk");
|
MD, "non-trivial argument copy for return-adjusting thunk");
|
||||||
}
|
}
|
||||||
EmitMustTailThunk(CurGD, AdjustedThisPtr, CalleePtr);
|
EmitMustTailThunk(CurGD, AdjustedThisPtr, Callee);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -354,8 +354,8 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
||||||
|
|
||||||
// Now emit our call.
|
// Now emit our call.
|
||||||
llvm::CallBase *CallOrInvoke;
|
llvm::CallBase *CallOrInvoke;
|
||||||
CGCallee Callee = CGCallee::forDirect(CalleePtr, CurGD);
|
RValue RV = EmitCall(*CurFnInfo, CGCallee::forDirect(Callee, CurGD), Slot,
|
||||||
RValue RV = EmitCall(*CurFnInfo, Callee, Slot, CallArgs, &CallOrInvoke);
|
CallArgs, &CallOrInvoke);
|
||||||
|
|
||||||
// Consider return adjustment if we have ThunkInfo.
|
// Consider return adjustment if we have ThunkInfo.
|
||||||
if (Thunk && !Thunk->Return.isEmpty())
|
if (Thunk && !Thunk->Return.isEmpty())
|
||||||
|
@ -375,7 +375,7 @@ void CodeGenFunction::EmitCallAndReturnForThunk(llvm::Constant *CalleePtr,
|
||||||
|
|
||||||
void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
||||||
llvm::Value *AdjustedThisPtr,
|
llvm::Value *AdjustedThisPtr,
|
||||||
llvm::Value *CalleePtr) {
|
llvm::FunctionCallee Callee) {
|
||||||
// Emitting a musttail call thunk doesn't use any of the CGCall.cpp machinery
|
// Emitting a musttail call thunk doesn't use any of the CGCall.cpp machinery
|
||||||
// to translate AST arguments into LLVM IR arguments. For thunks, we know
|
// to translate AST arguments into LLVM IR arguments. For thunks, we know
|
||||||
// that the caller prototype more or less matches the callee prototype with
|
// that the caller prototype more or less matches the callee prototype with
|
||||||
|
@ -404,14 +404,14 @@ void CodeGenFunction::EmitMustTailThunk(GlobalDecl GD,
|
||||||
|
|
||||||
// Emit the musttail call manually. Even if the prologue pushed cleanups, we
|
// Emit the musttail call manually. Even if the prologue pushed cleanups, we
|
||||||
// don't actually want to run them.
|
// don't actually want to run them.
|
||||||
llvm::CallInst *Call = Builder.CreateCall(CalleePtr, Args);
|
llvm::CallInst *Call = Builder.CreateCall(Callee, Args);
|
||||||
Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
|
Call->setTailCallKind(llvm::CallInst::TCK_MustTail);
|
||||||
|
|
||||||
// Apply the standard set of call attributes.
|
// Apply the standard set of call attributes.
|
||||||
unsigned CallingConv;
|
unsigned CallingConv;
|
||||||
llvm::AttributeList Attrs;
|
llvm::AttributeList Attrs;
|
||||||
CGM.ConstructAttributeList(CalleePtr->getName(), *CurFnInfo, GD, Attrs,
|
CGM.ConstructAttributeList(Callee.getCallee()->getName(), *CurFnInfo, GD,
|
||||||
CallingConv, /*AttrOnCallSite=*/true);
|
Attrs, CallingConv, /*AttrOnCallSite=*/true);
|
||||||
Call->setAttributes(Attrs);
|
Call->setAttributes(Attrs);
|
||||||
Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
|
Call->setCallingConv(static_cast<llvm::CallingConv::ID>(CallingConv));
|
||||||
|
|
||||||
|
@ -449,7 +449,8 @@ void CodeGenFunction::generateThunk(llvm::Function *Fn,
|
||||||
Callee = llvm::ConstantExpr::getBitCast(Callee, Fn->getType());
|
Callee = llvm::ConstantExpr::getBitCast(Callee, Fn->getType());
|
||||||
|
|
||||||
// Make the call and return the result.
|
// Make the call and return the result.
|
||||||
EmitCallAndReturnForThunk(Callee, &Thunk, IsUnprototyped);
|
EmitCallAndReturnForThunk(llvm::FunctionCallee(Fn->getFunctionType(), Callee),
|
||||||
|
&Thunk, IsUnprototyped);
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool shouldEmitVTableThunk(CodeGenModule &CGM, const CXXMethodDecl *MD,
|
static bool shouldEmitVTableThunk(CodeGenModule &CGM, const CXXMethodDecl *MD,
|
||||||
|
|
|
@ -1852,14 +1852,14 @@ public:
|
||||||
void StartThunk(llvm::Function *Fn, GlobalDecl GD,
|
void StartThunk(llvm::Function *Fn, GlobalDecl GD,
|
||||||
const CGFunctionInfo &FnInfo, bool IsUnprototyped);
|
const CGFunctionInfo &FnInfo, bool IsUnprototyped);
|
||||||
|
|
||||||
void EmitCallAndReturnForThunk(llvm::Constant *Callee, const ThunkInfo *Thunk,
|
void EmitCallAndReturnForThunk(llvm::FunctionCallee Callee,
|
||||||
bool IsUnprototyped);
|
const ThunkInfo *Thunk, bool IsUnprototyped);
|
||||||
|
|
||||||
void FinishThunk();
|
void FinishThunk();
|
||||||
|
|
||||||
/// Emit a musttail call for a thunk with a potentially adjusted this pointer.
|
/// Emit a musttail call for a thunk with a potentially adjusted this pointer.
|
||||||
void EmitMustTailThunk(GlobalDecl GD, llvm::Value *AdjustedThisPtr,
|
void EmitMustTailThunk(GlobalDecl GD, llvm::Value *AdjustedThisPtr,
|
||||||
llvm::Value *Callee);
|
llvm::FunctionCallee Callee);
|
||||||
|
|
||||||
/// Generate a thunk for the given method.
|
/// Generate a thunk for the given method.
|
||||||
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
|
void generateThunk(llvm::Function *Fn, const CGFunctionInfo &FnInfo,
|
||||||
|
|
|
@ -511,10 +511,10 @@ private:
|
||||||
} Block;
|
} Block;
|
||||||
|
|
||||||
/// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
|
/// void @llvm.lifetime.start(i64 %size, i8* nocapture <ptr>)
|
||||||
llvm::Constant *LifetimeStartFn = nullptr;
|
llvm::Function *LifetimeStartFn = nullptr;
|
||||||
|
|
||||||
/// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
|
/// void @llvm.lifetime.end(i64 %size, i8* nocapture <ptr>)
|
||||||
llvm::Constant *LifetimeEndFn = nullptr;
|
llvm::Function *LifetimeEndFn = nullptr;
|
||||||
|
|
||||||
GlobalDecl initializedGlobalDecl;
|
GlobalDecl initializedGlobalDecl;
|
||||||
|
|
||||||
|
@ -1023,8 +1023,8 @@ public:
|
||||||
|
|
||||||
///@}
|
///@}
|
||||||
|
|
||||||
llvm::Constant *getLLVMLifetimeStartFn();
|
llvm::Function *getLLVMLifetimeStartFn();
|
||||||
llvm::Constant *getLLVMLifetimeEndFn();
|
llvm::Function *getLLVMLifetimeEndFn();
|
||||||
|
|
||||||
// Make sure that this type is translated.
|
// Make sure that this type is translated.
|
||||||
void UpdateCompletedType(const TagDecl *TD);
|
void UpdateCompletedType(const TagDecl *TD);
|
||||||
|
|
|
@ -1996,7 +1996,7 @@ MicrosoftCXXABI::EmitVirtualMemPtrThunk(const CXXMethodDecl *MD,
|
||||||
llvm::Value *Callee =
|
llvm::Value *Callee =
|
||||||
CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
|
CGF.Builder.CreateAlignedLoad(VFuncPtr, CGF.getPointerAlign());
|
||||||
|
|
||||||
CGF.EmitMustTailThunk(MD, getThisValue(CGF), Callee);
|
CGF.EmitMustTailThunk(MD, getThisValue(CGF), {ThunkTy, Callee});
|
||||||
|
|
||||||
return ThunkFn;
|
return ThunkFn;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue