compiler: insert nil checks when storing to a pointer
This does increase code size, but it is necessary to avoid undefined behavior.
Этот коммит содержится в:
родитель
371c468e8e
коммит
3c2639ad55
1 изменённых файлов: 1 добавлений и 0 удалений
|
@ -1054,6 +1054,7 @@ func (c *Compiler) parseInstr(frame *Frame, instr ssa.Instruction) {
|
||||||
case *ssa.Store:
|
case *ssa.Store:
|
||||||
llvmAddr := c.getValue(frame, instr.Addr)
|
llvmAddr := c.getValue(frame, instr.Addr)
|
||||||
llvmVal := c.getValue(frame, instr.Val)
|
llvmVal := c.getValue(frame, instr.Val)
|
||||||
|
c.emitNilCheck(frame, llvmAddr, "store")
|
||||||
if c.targetData.TypeAllocSize(llvmVal.Type()) == 0 {
|
if c.targetData.TypeAllocSize(llvmVal.Type()) == 0 {
|
||||||
// nothing to store
|
// nothing to store
|
||||||
return
|
return
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче