@@ -126,13 +126,16 @@ func (cl ContextLoader) makeFakeLoaderProgram(pkgs []*packages.Package) *loader.
126126 }
127127}
128128
129- func (cl ContextLoader ) buildSSAProgram (pkgs []* packages.Package ) * ssa.Program {
129+ func (cl ContextLoader ) buildSSAProgram (pkgs []* packages.Package , name string ) * ssa.Program {
130130 startedAt := time .Now ()
131+ var pkgsBuiltDuration time.Duration
131132 defer func () {
132- cl .log .Infof ("SSA repr building took %s" , time .Since (startedAt ))
133+ cl .log .Infof ("SSA %srepr building timing: packages building %s, total %s" ,
134+ name , pkgsBuiltDuration , time .Since (startedAt ))
133135 }()
134136
135137 ssaProg , _ := ssautil .Packages (pkgs , ssa .GlobalDebug )
138+ pkgsBuiltDuration = time .Since (startedAt )
136139 ssaProg .Build ()
137140 return ssaProg
138141}
@@ -300,24 +303,10 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
300303 prog = cl .makeFakeLoaderProgram (pkgs )
301304 }
302305
303- var ssaProg * ssa.Program
306+ var ssaProg , megacheckSSAProg * ssa.Program
304307 if loadMode == packages .LoadAllSyntax {
305- ssaProg = cl .buildSSAProgram (pkgs )
306- for _ , pkginfo := range prog .InitialPackages () {
307- if pkginfo == nil {
308- cl .log .Infof ("Pkginfo is nil" )
309- continue
310- }
311- if pkginfo .Pkg == nil {
312- cl .log .Infof ("Pkg %#v: types package is nil" , * pkginfo )
313- continue
314- }
315- ssaPkg := ssaProg .Package (pkginfo .Pkg )
316- if ssaPkg == nil {
317- cl .log .Infof ("Pkg %#v: ssaPkg is nil: %#v" , * pkginfo , * pkginfo .Pkg )
318- continue
319- }
320- }
308+ ssaProg = cl .buildSSAProgram (pkgs , "" )
309+ megacheckSSAProg = cl .buildSSAProgram (pkgs , "for megacheck " )
321310 }
322311
323312 astLog := cl .log .Child ("astcache" )
@@ -327,9 +316,10 @@ func (cl ContextLoader) Load(ctx context.Context, linters []linter.Config) (*lin
327316 }
328317
329318 ret := & linter.Context {
330- Packages : pkgs ,
331- Program : prog ,
332- SSAProgram : ssaProg ,
319+ Packages : pkgs ,
320+ Program : prog ,
321+ SSAProgram : ssaProg ,
322+ MegacheckSSAProgram : megacheckSSAProg ,
333323 LoaderConfig : & loader.Config {
334324 Cwd : "" , // used by depguard and fallbacked to os.Getcwd
335325 Build : nil , // used by depguard and megacheck and fallbacked to build.Default
0 commit comments