compiler: avoid some obviously false nil checks
Pointers to globals are never nil.
Этот коммит содержится в:
родитель
7ada00790c
коммит
f94af9f61e
1 изменённых файлов: 5 добавлений и 0 удалений
|
@ -114,6 +114,11 @@ func (c *Compiler) emitSliceBoundsCheck(frame *Frame, capacity, low, high llvm.V
|
||||||
// has no effect in well-behaved programs, but makes sure no uncaught nil
|
// has no effect in well-behaved programs, but makes sure no uncaught nil
|
||||||
// pointer dereferences exist in valid Go code.
|
// pointer dereferences exist in valid Go code.
|
||||||
func (c *Compiler) emitNilCheck(frame *Frame, ptr llvm.Value, blockPrefix string) {
|
func (c *Compiler) emitNilCheck(frame *Frame, ptr llvm.Value, blockPrefix string) {
|
||||||
|
// Check whether we need to emit this check at all.
|
||||||
|
if !ptr.IsAGlobalValue().IsNil() {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Check whether this is a nil pointer.
|
// Check whether this is a nil pointer.
|
||||||
faultBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".nil")
|
faultBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".nil")
|
||||||
nextBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".next")
|
nextBlock := c.ctx.AddBasicBlock(frame.fn.LLVMFn, blockPrefix+".next")
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче