diff options
Diffstat (limited to 'clang/lib/CodeGen/CGCall.cpp')
| -rw-r--r-- | clang/lib/CodeGen/CGCall.cpp | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/clang/lib/CodeGen/CGCall.cpp b/clang/lib/CodeGen/CGCall.cpp index 466546b2f130..0b2fce4244fb 100644 --- a/clang/lib/CodeGen/CGCall.cpp +++ b/clang/lib/CodeGen/CGCall.cpp @@ -752,9 +752,8 @@ const CGFunctionInfo &CodeGenTypes::arrangeBuiltinFunctionDeclaration( RequiredArgs::All); } -const CGFunctionInfo & -CodeGenTypes::arrangeSYCLKernelCallerDeclaration(QualType resultType, - const FunctionArgList &args) { +const CGFunctionInfo &CodeGenTypes::arrangeDeviceKernelCallerDeclaration( + QualType resultType, const FunctionArgList &args) { CanQualTypeList argTypes = getArgTypesForDeclaration(Context, args); return arrangeLLVMFunctionInfo(GetReturnType(resultType), FnInfoOpts::None, @@ -1005,10 +1004,9 @@ getTypeExpansion(QualType Ty, const ASTContext &Context) { return std::make_unique<ConstantArrayExpansion>(AT->getElementType(), AT->getZExtSize()); } - if (const RecordType *RT = Ty->getAs<RecordType>()) { + if (const auto *RD = Ty->getAsRecordDecl()) { SmallVector<const CXXBaseSpecifier *, 1> Bases; SmallVector<const FieldDecl *, 1> Fields; - const RecordDecl *RD = RT->getOriginalDecl()->getDefinitionOrSelf(); assert(!RD->hasFlexibleArrayMember() && "Cannot expand structure with flexible array."); if (RD->isUnion()) { @@ -1897,7 +1895,7 @@ bool CodeGenModule::MayDropFunctionReturn(const ASTContext &Context, // We can't just discard the return value for a record type with a // complex destructor or a non-trivially copyable type. if (const RecordType *RT = - ReturnType.getCanonicalType()->getAs<RecordType>()) { + ReturnType.getCanonicalType()->getAsCanonical<RecordType>()) { if (const auto *ClassDecl = dyn_cast<CXXRecordDecl>(RT->getOriginalDecl())) return ClassDecl->hasTrivialDestructor(); } @@ -2014,8 +2012,6 @@ static void getTrivialDefaultFunctionAttributes( FuncAttrs.addAttribute("no-infs-fp-math", "true"); if (LangOpts.NoHonorNaNs) FuncAttrs.addAttribute("no-nans-fp-math", "true"); - if (LangOpts.ApproxFunc) - FuncAttrs.addAttribute("approx-func-fp-math", "true"); if (LangOpts.AllowFPReassoc && LangOpts.AllowRecip && LangOpts.NoSignedZero && LangOpts.ApproxFunc && (LangOpts.getDefaultFPContractMode() == @@ -2874,10 +2870,7 @@ void CodeGenModule::ConstructAttributeList(StringRef Name, // whose destruction / clean-up is carried out within the callee // (e.g., Obj-C ARC-managed structs, MSVC callee-destroyed objects). if (!ParamType.isDestructedType() || !ParamType->isRecordType() || - ParamType->castAs<RecordType>() - ->getOriginalDecl() - ->getDefinitionOrSelf() - ->isParamDestroyedInCallee()) + ParamType->castAsRecordDecl()->isParamDestroyedInCallee()) Attrs.addAttribute(llvm::Attribute::DeadOnReturn); } } @@ -3890,7 +3883,7 @@ static void setUsedBits(CodeGenModule &CGM, const ConstantArrayType *ATy, // the type `QTy`. static void setUsedBits(CodeGenModule &CGM, QualType QTy, int Offset, SmallVectorImpl<uint64_t> &Bits) { - if (const auto *RTy = QTy->getAs<RecordType>()) + if (const auto *RTy = QTy->getAsCanonical<RecordType>()) return setUsedBits(CGM, RTy, Offset, Bits); ASTContext &Context = CGM.getContext(); @@ -3934,7 +3927,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src, const llvm::DataLayout &DataLayout = CGM.getDataLayout(); int Size = DataLayout.getTypeStoreSize(ITy); SmallVector<uint64_t, 4> Bits(Size); - setUsedBits(CGM, QTy->castAs<RecordType>(), 0, Bits); + setUsedBits(CGM, QTy->castAsCanonical<RecordType>(), 0, Bits); int CharWidth = CGM.getContext().getCharWidth(); uint64_t Mask = @@ -3951,7 +3944,7 @@ llvm::Value *CodeGenFunction::EmitCMSEClearRecord(llvm::Value *Src, const llvm::DataLayout &DataLayout = CGM.getDataLayout(); int Size = DataLayout.getTypeStoreSize(ATy); SmallVector<uint64_t, 16> Bits(Size); - setUsedBits(CGM, QTy->castAs<RecordType>(), 0, Bits); + setUsedBits(CGM, QTy->castAsCanonical<RecordType>(), 0, Bits); // Clear each element of the LLVM array. int CharWidth = CGM.getContext().getCharWidth(); @@ -4308,10 +4301,7 @@ void CodeGenFunction::EmitDelegateCallArg(CallArgList &args, // Deactivate the cleanup for the callee-destructed param that was pushed. if (type->isRecordType() && !CurFuncIsThunk && - type->castAs<RecordType>() - ->getOriginalDecl() - ->getDefinitionOrSelf() - ->isParamDestroyedInCallee() && + type->castAsRecordDecl()->isParamDestroyedInCallee() && param->needsDestruction(getContext())) { EHScopeStack::stable_iterator cleanup = CalleeDestructedParamCleanups.lookup(cast<ParmVarDecl>(param)); @@ -4827,19 +4817,6 @@ struct DestroyUnpassedArg final : EHScopeStack::Cleanup { } }; -struct DisableDebugLocationUpdates { - CodeGenFunction &CGF; - bool disabledDebugInfo; - DisableDebugLocationUpdates(CodeGenFunction &CGF, const Expr *E) : CGF(CGF) { - if ((disabledDebugInfo = isa<CXXDefaultArgExpr>(E) && CGF.getDebugInfo())) - CGF.disableDebugInfo(); - } - ~DisableDebugLocationUpdates() { - if (disabledDebugInfo) - CGF.enableDebugInfo(); - } -}; - } // end anonymous namespace RValue CallArg::getRValue(CodeGenFunction &CGF) const { @@ -4876,7 +4853,9 @@ void CodeGenFunction::EmitWritebacks(const CallArgList &args) { void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, QualType type) { - DisableDebugLocationUpdates Dis(*this, E); + std::optional<DisableDebugLocationUpdates> Dis; + if (isa<CXXDefaultArgExpr>(E)) + Dis.emplace(*this); if (const ObjCIndirectCopyRestoreExpr *CRE = dyn_cast<ObjCIndirectCopyRestoreExpr>(E)) { assert(getLangOpts().ObjCAutoRefCount); @@ -4904,10 +4883,8 @@ void CodeGenFunction::EmitCallArg(CallArgList &args, const Expr *E, // In the Microsoft C++ ABI, aggregate arguments are destructed by the callee. // However, we still have to push an EH-only cleanup in case we unwind before // we make it to the call. - if (type->isRecordType() && type->castAs<RecordType>() - ->getOriginalDecl() - ->getDefinitionOrSelf() - ->isParamDestroyedInCallee()) { + if (type->isRecordType() && + type->castAsRecordDecl()->isParamDestroyedInCallee()) { // If we're using inalloca, use the argument memory. Otherwise, use a // temporary. AggValueSlot Slot = args.isUsingInAlloca() @@ -5261,9 +5238,12 @@ RValue CodeGenFunction::EmitCall(const CGFunctionInfo &CallInfo, // since otherwise we could be making a conditional call after a check for // the proper cpu features (and it won't cause code generation issues due to // function based code generation). - if (TargetDecl->hasAttr<AlwaysInlineAttr>() && - (TargetDecl->hasAttr<TargetAttr>() || - (CurFuncDecl && CurFuncDecl->hasAttr<TargetAttr>()))) + if ((TargetDecl->hasAttr<AlwaysInlineAttr>() && + (TargetDecl->hasAttr<TargetAttr>() || + (CurFuncDecl && CurFuncDecl->hasAttr<TargetAttr>()))) || + (CurFuncDecl && CurFuncDecl->hasAttr<FlattenAttr>() && + (CurFuncDecl->hasAttr<TargetAttr>() || + TargetDecl->hasAttr<TargetAttr>()))) checkTargetFeatures(Loc, FD); } @@ -6290,3 +6270,12 @@ RValue CodeGenFunction::EmitVAArg(VAArgExpr *VE, Address &VAListAddr, return CGM.getABIInfo().EmitMSVAArg(*this, VAListAddr, Ty, Slot); return CGM.getABIInfo().EmitVAArg(*this, VAListAddr, Ty, Slot); } + +DisableDebugLocationUpdates::DisableDebugLocationUpdates(CodeGenFunction &CGF) + : CGF(CGF) { + CGF.disableDebugInfo(); +} + +DisableDebugLocationUpdates::~DisableDebugLocationUpdates() { + CGF.enableDebugInfo(); +} |
