interp: fix GEP with const value in a local variable

Этот коммит содержится в:
Ayke van Laethem 2018-11-05 13:33:01 +01:00
родитель 2cd9846cc9
коммит bf9d62fe98
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: E97FF5335DFDFDED

Просмотреть файл

@ -114,14 +114,15 @@ func (fr *frame) evalBasicBlock(bb, incoming llvm.BasicBlock, indent string) (re
llvmIndices[i] = inst.Operand(i + 1) llvmIndices[i] = inst.Operand(i + 1)
} }
indices := make([]uint32, len(llvmIndices)) indices := make([]uint32, len(llvmIndices))
for i, operand := range llvmIndices { for i, llvmIndex := range llvmIndices {
operand := fr.getLocal(llvmIndex)
if !operand.IsConstant() { if !operand.IsConstant() {
// not a constant operation, emit a low-level GEP // Not a constant operation.
gep := fr.builder.CreateGEP(value.Value(), llvmIndices, inst.Name()) // This should be detected by the scanner, but isn't at the
fr.locals[inst] = &LocalValue{fr.Eval, gep} // moment.
continue panic("todo: non-const gep")
} }
indices[i] = uint32(operand.ZExtValue()) indices[i] = uint32(operand.Value().ZExtValue())
} }
result := value.GetElementPtr(indices) result := value.GetElementPtr(indices)
if result.Type() != inst.Type() { if result.Type() != inst.Type() {