File tree 3 files changed +32
-9
lines changed
3 files changed +32
-9
lines changed Original file line number Diff line number Diff line change @@ -173,7 +173,7 @@ struct ValueInfo {
173
173
RefAndFlags.setInt (HaveGVs);
174
174
}
175
175
176
- operator bool () const { return getRef (); }
176
+ explicit operator bool () const { return getRef (); }
177
177
178
178
GlobalValue::GUID getGUID () const { return getRef ()->first ; }
179
179
const GlobalValue *getValue () const {
Original file line number Diff line number Diff line change @@ -604,24 +604,26 @@ static void ComputeImportForModule(
604
604
}
605
605
606
606
#ifndef NDEBUG
607
+ static bool isGlobalVarSummary (const ModuleSummaryIndex &Index, ValueInfo VI) {
608
+ auto SL = VI.getSummaryList ();
609
+ return SL.empty ()
610
+ ? false
611
+ : SL[0 ]->getSummaryKind () == GlobalValueSummary::GlobalVarKind;
612
+ }
613
+
607
614
static bool isGlobalVarSummary (const ModuleSummaryIndex &Index,
608
615
GlobalValue::GUID G) {
609
- if (const auto &VI = Index.getValueInfo (G)) {
610
- auto SL = VI.getSummaryList ();
611
- if (!SL.empty ())
612
- return SL[0 ]->getSummaryKind () == GlobalValueSummary::GlobalVarKind;
613
- }
616
+ if (const auto &VI = Index.getValueInfo (G))
617
+ return isGlobalVarSummary (Index, VI);
614
618
return false ;
615
619
}
616
620
617
- static GlobalValue::GUID getGUID (GlobalValue::GUID G) { return G; }
618
-
619
621
template <class T >
620
622
static unsigned numGlobalVarSummaries (const ModuleSummaryIndex &Index,
621
623
T &Cont) {
622
624
unsigned NumGVS = 0 ;
623
625
for (auto &V : Cont)
624
- if (isGlobalVarSummary (Index, getGUID (V) ))
626
+ if (isGlobalVarSummary (Index, V ))
625
627
++NumGVS;
626
628
return NumGVS;
627
629
}
Original file line number Diff line number Diff line change
1
+ ; REQUIRES: asserts
2
+ ; RUN: opt -module-summary %p/funcimport.ll -o %t.bc
3
+ ; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
4
+ ; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
5
+
6
+ ; RUN: llvm-lto -thinlto-action=import %t2.bc -thinlto-index=%t3.bc -o /dev/null -debug-only=function-import -stats > %t4 2>&1
7
+ ; RUN: cat %t4 | grep 'Is importing global' | count 4
8
+ ; RUN: cat %t4 | grep 'Is importing function' | count 8
9
+ ; RUN: cat %t4 | grep 'Is importing aliasee' | count 1
10
+ ; RUN: cat %t4 | FileCheck %s
11
+
12
+ ; CHECK: - [[NUM_FUNCS:[0-9]+]] functions imported from
13
+ ; CHECK-NEXT: - [[NUM_VARS:[0-9]+]] global vars imported from
14
+
15
+ ; CHECK: [[NUM_FUNCS]] function-import - Number of functions imported in backend
16
+ ; CHECK-NEXT: [[NUM_FUNCS]] function-import - Number of functions thin link decided to import
17
+ ; CHECK-NEXT: [[NUM_VARS]] function-import - Number of global variables imported in backend
18
+ ; CHECK-NEXT: [[NUM_VARS]] function-import - Number of global variables thin link decided to import
19
+ ; CHECK-NEXT: 1 function-import - Number of modules imported from
20
+ ; CHECK-NEXT: [[NUM_VARS]] module-summary-index - Number of live global variables marked read only
21
+ ; CHECK-NEXT: 1 module-summary-index - Number of live global variables marked write only
You can’t perform that action at this time.
0 commit comments