@@ -432,6 +432,18 @@ class GlobalValueSummary {
432432 // / Sububclass discriminator (for dyn_cast<> et al.)
433433 enum SummaryKind : unsigned { AliasKind, FunctionKind, GlobalVarKind };
434434
435+ enum ImportKind : unsigned {
436+ // The global value definition corresponding to the summary should be
437+ // imported from source module
438+ Definition = 0 ,
439+
440+ // When its definition doesn't exist in the destination module and not
441+ // imported (e.g., function is too large to be inlined), the global value
442+ // declaration corresponding to the summary should be imported, or the
443+ // attributes from summary should be annotated on the function declaration.
444+ Declaration = 1 ,
445+ };
446+
435447 // / Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
436448 struct GVFlags {
437449 // / The linkage type of the associated global value.
@@ -472,14 +484,19 @@ class GlobalValueSummary {
472484 // / means the symbol was externally visible.
473485 unsigned CanAutoHide : 1 ;
474486
487+ // / This field is written by the ThinLTO indexing step to postlink combined
488+ // / summary. The value is interpreted as 'ImportKind' enum defined above.
489+ unsigned ImportType : 1 ;
490+
475491 // / Convenience Constructors
476492 explicit GVFlags (GlobalValue::LinkageTypes Linkage,
477493 GlobalValue::VisibilityTypes Visibility,
478494 bool NotEligibleToImport, bool Live, bool IsLocal,
479- bool CanAutoHide)
495+ bool CanAutoHide, ImportKind ImportType )
480496 : Linkage(Linkage), Visibility(Visibility),
481497 NotEligibleToImport(NotEligibleToImport), Live(Live),
482- DSOLocal(IsLocal), CanAutoHide(CanAutoHide) {}
498+ DSOLocal(IsLocal), CanAutoHide(CanAutoHide),
499+ ImportType(static_cast <unsigned >(ImportType)) {}
483500 };
484501
485502private:
@@ -564,6 +581,12 @@ class GlobalValueSummary {
564581
565582 bool canAutoHide () const { return Flags.CanAutoHide ; }
566583
584+ bool shouldImportAsDecl () const {
585+ return Flags.ImportType == GlobalValueSummary::ImportKind::Declaration;
586+ }
587+
588+ void setImportKind (ImportKind IK) { Flags.ImportType = IK; }
589+
567590 GlobalValue::VisibilityTypes getVisibility () const {
568591 return (GlobalValue::VisibilityTypes)Flags.Visibility ;
569592 }
@@ -813,7 +836,7 @@ class FunctionSummary : public GlobalValueSummary {
813836 GlobalValue::LinkageTypes::AvailableExternallyLinkage,
814837 GlobalValue::DefaultVisibility,
815838 /* NotEligibleToImport=*/ true , /* Live=*/ true , /* IsLocal=*/ false ,
816- /* CanAutoHide=*/ false ),
839+ /* CanAutoHide=*/ false , GlobalValueSummary::ImportKind::Definition ),
817840 /* NumInsts=*/ 0 , FunctionSummary::FFlags{}, /* EntryCount=*/ 0 ,
818841 std::vector<ValueInfo>(), std::move (Edges),
819842 std::vector<GlobalValue::GUID>(),
0 commit comments