mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-07 12:33:42 +00:00
compiler, transform: remove runtime.isnil hack
This hack was originally introduced in https://github.com/tinygo-org/tinygo/pull/251 to fix an escape analysis regression after https://github.com/tinygo-org/tinygo/pull/222 introduced nil checks. Since a new optimization in LLVM (see https://reviews.llvm.org/D60047) this hack is not necessary anymore and can be removed. I've compared all regular tests and smoke tests before and after to check the size. In most cases this change was an improvement although there are a few regressions.
This commit is contained in:
committed by
Ron Evans
parent
bbfa601d27
commit
f8876ea245
@@ -98,24 +98,6 @@ func Optimize(mod llvm.Module, config *compileopts.Config, optLevel, sizeLevel i
|
||||
OptimizeAllocs(mod)
|
||||
OptimizeStringToBytes(mod)
|
||||
|
||||
// Lower runtime.isnil calls to regular nil comparisons.
|
||||
isnil := mod.NamedFunction("runtime.isnil")
|
||||
if !isnil.IsNil() {
|
||||
builder := mod.Context().NewBuilder()
|
||||
defer builder.Dispose()
|
||||
for _, use := range getUses(isnil) {
|
||||
builder.SetInsertPointBefore(use)
|
||||
ptr := use.Operand(0)
|
||||
if !ptr.IsABitCastInst().IsNil() {
|
||||
ptr = ptr.Operand(0)
|
||||
}
|
||||
nilptr := llvm.ConstPointerNull(ptr.Type())
|
||||
icmp := builder.CreateICmp(llvm.IntEQ, ptr, nilptr, "")
|
||||
use.ReplaceAllUsesWith(icmp)
|
||||
use.EraseFromParentAsInstruction()
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// Must be run at any optimization level.
|
||||
err := LowerInterfaces(mod)
|
||||
|
||||
Reference in New Issue
Block a user