@@ -432,6 +432,18 @@ class GlobalValueSummary {
432
432
// / Sububclass discriminator (for dyn_cast<> et al.)
433
433
enum SummaryKind : unsigned { AliasKind, FunctionKind, GlobalVarKind };
434
434
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
+
435
447
// / Group flags (Linkage, NotEligibleToImport, etc.) as a bitfield.
436
448
struct GVFlags {
437
449
// / The linkage type of the associated global value.
@@ -472,14 +484,19 @@ class GlobalValueSummary {
472
484
// / means the symbol was externally visible.
473
485
unsigned CanAutoHide : 1 ;
474
486
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
+
475
491
// / Convenience Constructors
476
492
explicit GVFlags (GlobalValue::LinkageTypes Linkage,
477
493
GlobalValue::VisibilityTypes Visibility,
478
494
bool NotEligibleToImport, bool Live, bool IsLocal,
479
- bool CanAutoHide)
495
+ bool CanAutoHide, ImportKind ImportType )
480
496
: Linkage(Linkage), Visibility(Visibility),
481
497
NotEligibleToImport(NotEligibleToImport), Live(Live),
482
- DSOLocal(IsLocal), CanAutoHide(CanAutoHide) {}
498
+ DSOLocal(IsLocal), CanAutoHide(CanAutoHide),
499
+ ImportType(static_cast <unsigned >(ImportType)) {}
483
500
};
484
501
485
502
private:
@@ -564,6 +581,12 @@ class GlobalValueSummary {
564
581
565
582
bool canAutoHide () const { return Flags.CanAutoHide ; }
566
583
584
+ bool shouldImportAsDecl () const {
585
+ return Flags.ImportType == GlobalValueSummary::ImportKind::Declaration;
586
+ }
587
+
588
+ void setImportKind (ImportKind IK) { Flags.ImportType = IK; }
589
+
567
590
GlobalValue::VisibilityTypes getVisibility () const {
568
591
return (GlobalValue::VisibilityTypes)Flags.Visibility ;
569
592
}
@@ -813,7 +836,7 @@ class FunctionSummary : public GlobalValueSummary {
813
836
GlobalValue::LinkageTypes::AvailableExternallyLinkage,
814
837
GlobalValue::DefaultVisibility,
815
838
/* NotEligibleToImport=*/ true , /* Live=*/ true , /* IsLocal=*/ false ,
816
- /* CanAutoHide=*/ false ),
839
+ /* CanAutoHide=*/ false , GlobalValueSummary::ImportKind::Definition ),
817
840
/* NumInsts=*/ 0 , FunctionSummary::FFlags{}, /* EntryCount=*/ 0 ,
818
841
std::vector<ValueInfo>(), std::move (Edges),
819
842
std::vector<GlobalValue::GUID>(),
0 commit comments