build: add link-time dead method elimination#1868
Conversation
|
Codecov Report❌ Patch coverage is 📢 Thoughts on this report? Let us know! |
|
补充一个 DCE 方法槽修复点: 对于被判定为 dead 的方法槽, 原因是运行时构造 itab 时, 这会导致同一个 concrete type 到同一个接口的转换生成多个不同 itab。典型表现是 t0 == t1 // true
m[t1] // false最终会影响标准库里这类逻辑,例如 supportedTypes[reflect.TypeOf(5)]所以现在的策略是:dead method slot 仍保留非零函数入口,指向 |
|
Additional experiment on Summary over the same demo set: Top cases where name+sig keeps more than the precise rule:
Conclusion from this demo set: the more precise interface implementation check does reduce output size, but the measured delta is small here: about 83KB total, or 0.51% of the bytes saved by precise DCE. |
Summary
Notes
-vcache hit logging now prints only the package path.Test Plan
go test ./internal/deadcode ./internal/dcepass ./internal/metadata ./internal/build -count=1Demo Size Comparison
Built
_demo/godemos with DCE from this PR into_demo/go/520-dce, and with localupstream/main(ec1b2f74) into_demo/go/520-nodce.Build command shape:
LLGO_BUILD_CACHE=off llgo build -a -o <output> .Summary for demos that built successfully on both sides:
Two demos failed on both sides and were excluded from the size total:
defer/setjmp: C source files are present but this directllgo build .path is not using cgo/SWIG.defer/test: existing source errors aroundc.Printf/c.Str.All measured demos, sorted by saved bytes descending:
goimporter-1389embedunexport-1598gotypesabimethodmimeheaderreflectpointertoreflectmakenetipgobuild-1389randdemogotokensysexecoslookpathsynccreatetemp-1654gobuildrandcryptmaphashfailed/stacktracecgoreaddirtimedurmkdirdemosysopen-1654reflectfuncreflectcopylogdemocheckfilereflectname-1412oswritestringtexttemplateosfilecommandrunreflectindirectreflectmethodtimerasyncgotimesyscallifaceconvifaceprom-1559mapclosureexportcabiissue1538-floatcvtuint-overdeferdefer/stressissue1538complexdefer/setjmp/c_standard_demo/closure_testmathdefer/setjmp/c_standard_demo/llgo_testgoroutineruntimestatefn