@@ -384,7 +384,7 @@ func Do(args []string, conf *Config) ([]Package, error) {
384384 })
385385 preCollectRuntimeLinknames (prog , altPkgs )
386386
387- buildMode := ssaBuildMode
387+ buildMode := ssaBuildMode ()
388388 cabiOptimize := true
389389 passOpt := true
390390 if IsDbgEnabled () || mode == ModeGen {
@@ -571,9 +571,17 @@ func (p Package) isNeedRuntimeOrPyInit() (needRuntime, needPyInit bool) {
571571 return
572572}
573573
574- const (
575- ssaBuildMode = ssa .SanityCheckFunctions | ssa .InstantiateGenerics
576- )
574+ func ssaBuildMode () ssa.BuilderMode {
575+ mode := ssa .InstantiateGenerics
576+ if ssaSanityEnabled () {
577+ mode |= ssa .SanityCheckFunctions
578+ }
579+ return mode
580+ }
581+
582+ func ssaSanityEnabled () bool {
583+ return isEnvOn (llgoSSASanity , false )
584+ }
577585
578586type context struct {
579587 env * llvm.Env
@@ -1767,9 +1775,11 @@ func fixUntypedShiftTypes(p *packages.Package) {
17671775}
17681776
17691777func applyPatches (ctx * context , p * packages.Package , verbose bool ) {
1770- // Fix untyped shift types before SSA build
1778+ // Fix untyped shift types before SSA sanity checking.
17711779 // See: https://github.com/golang/go/issues/77067
1772- fixUntypedShiftTypes (p )
1780+ if ssaSanityEnabled () {
1781+ fixUntypedShiftTypes (p )
1782+ }
17731783
17741784 // fix instance patch
17751785 for id , inst := range p .TypesInfo .Instances {
@@ -1839,6 +1849,7 @@ const llgoWasiThreads = "LLGO_WASI_THREADS"
18391849const llgoStdioNobuf = "LLGO_STDIO_NOBUF"
18401850const llgoFullRpath = "LLGO_FULL_RPATH"
18411851const llgoBuildCache = "LLGO_BUILD_CACHE"
1852+ const llgoSSASanity = "LLGO_SSA_SANITY"
18421853
18431854// for Plan9 asm translation debug
18441855const llgoPlan9ASMPkgs = "LLGO_PLAN9ASM_PKGS"
0 commit comments