@@ -747,104 +747,6 @@ mlir::Value CIRGenFunction::createLoad(const VarDecl *VD, const char *Name) {
747747 addr.getElementType (), addr.getPointer ());
748748}
749749
750- static bool isMemcpyEquivalentSpecialMember (const CXXMethodDecl *D) {
751- auto *CD = llvm::dyn_cast<CXXConstructorDecl>(D);
752- if (!(CD && CD->isCopyOrMoveConstructor ()) &&
753- !D->isCopyAssignmentOperator () && !D->isMoveAssignmentOperator ())
754- return false ;
755-
756- // We can emit a memcpy for a trivial copy or move constructor/assignment
757- if (D->isTrivial () && !D->getParent ()->mayInsertExtraPadding ())
758- return true ;
759-
760- if (D->getParent ()->isUnion () && D->isDefaulted ())
761- return true ;
762-
763- return false ;
764- }
765-
766- void CIRGenFunction::buildCXXConstructorCall (const clang::CXXConstructorDecl *D,
767- clang::CXXCtorType Type,
768- bool ForVirtualBase,
769- bool Delegating,
770- AggValueSlot ThisAVS,
771- const clang::CXXConstructExpr *E) {
772- CallArgList Args;
773- Address This = ThisAVS.getAddress ();
774- LangAS SlotAS = ThisAVS.getQualifiers ().getAddressSpace ();
775- QualType ThisType = D->getThisType ();
776- LangAS ThisAS = ThisType.getTypePtr ()->getPointeeType ().getAddressSpace ();
777- mlir::Value ThisPtr = This.getPointer ();
778-
779- assert (SlotAS == ThisAS && " This edge case NYI" );
780-
781- Args.add (RValue::get (ThisPtr), D->getThisType ());
782-
783- // In LLVM Codegen: If this is a trivial constructor, just emit what's needed.
784- // If this is a union copy constructor, we must emit a memcpy, because the AST
785- // does not model that copy.
786- if (isMemcpyEquivalentSpecialMember (D)) {
787- assert (!MissingFeatures::isMemcpyEquivalentSpecialMember ());
788- }
789-
790- const FunctionProtoType *FPT = D->getType ()->castAs <FunctionProtoType>();
791- EvaluationOrder Order = E->isListInitialization ()
792- ? EvaluationOrder::ForceLeftToRight
793- : EvaluationOrder::Default;
794-
795- buildCallArgs (Args, FPT, E->arguments (), E->getConstructor (),
796- /* ParamsToSkip*/ 0 , Order);
797-
798- buildCXXConstructorCall (D, Type, ForVirtualBase, Delegating, This, Args,
799- ThisAVS.mayOverlap (), E->getExprLoc (),
800- ThisAVS.isSanitizerChecked ());
801- }
802-
803- void CIRGenFunction::buildCXXConstructorCall (
804- const CXXConstructorDecl *D, CXXCtorType Type, bool ForVirtualBase,
805- bool Delegating, Address This, CallArgList &Args,
806- AggValueSlot::Overlap_t Overlap, SourceLocation Loc,
807- bool NewPointerIsChecked) {
808-
809- const auto *ClassDecl = D->getParent ();
810-
811- if (!NewPointerIsChecked)
812- buildTypeCheck (CIRGenFunction::TCK_ConstructorCall, Loc, This.getPointer (),
813- getContext ().getRecordType (ClassDecl), CharUnits::Zero ());
814-
815- // If this is a call to a trivial default constructor:
816- // In LLVM: do nothing.
817- // In CIR: emit as a regular call, other later passes should lower the
818- // ctor call into trivial initialization.
819- assert (!MissingFeatures::isTrivialCtorOrDtor ());
820-
821- if (isMemcpyEquivalentSpecialMember (D)) {
822- assert (!MissingFeatures::isMemcpyEquivalentSpecialMember ());
823- }
824-
825- bool PassPrototypeArgs = true ;
826-
827- assert (!D->getInheritedConstructor () && " inheritance NYI" );
828-
829- // Insert any ABI-specific implicit constructor arguments.
830- CIRGenCXXABI::AddedStructorArgCounts ExtraArgs =
831- CGM.getCXXABI ().addImplicitConstructorArgs (*this , D, Type, ForVirtualBase,
832- Delegating, Args);
833-
834- // Emit the call.
835- auto CalleePtr = CGM.getAddrOfCXXStructor (GlobalDecl (D, Type));
836- const CIRGenFunctionInfo &Info = CGM.getTypes ().arrangeCXXConstructorCall (
837- Args, D, Type, ExtraArgs.Prefix , ExtraArgs.Suffix , PassPrototypeArgs);
838- CIRGenCallee Callee = CIRGenCallee::forDirect (CalleePtr, GlobalDecl (D, Type));
839- mlir::cir::CIRCallOpInterface C;
840- buildCall (Info, Callee, ReturnValueSlot (), Args, &C, false , getLoc (Loc));
841-
842- assert (CGM.getCodeGenOpts ().OptimizationLevel == 0 ||
843- ClassDecl->isDynamicClass () || Type == Ctor_Base ||
844- !CGM.getCodeGenOpts ().StrictVTablePointers &&
845- " vtable assumption loads NYI" );
846- }
847-
848750void CIRGenFunction::buildConstructorBody (FunctionArgList &Args) {
849751 // TODO: EmitAsanPrologueOrEpilogue(true);
850752 const auto *Ctor = cast<CXXConstructorDecl>(CurGD.getDecl ());
0 commit comments