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)
}
indices := make([]uint32, len(llvmIndices))
for i, operand := range llvmIndices {
for i, llvmIndex := range llvmIndices {
operand := fr.getLocal(llvmIndex)
if !operand.IsConstant() {
// not a constant operation, emit a low-level GEP
gep := fr.builder.CreateGEP(value.Value(), llvmIndices, inst.Name())
fr.locals[inst] = &LocalValue{fr.Eval, gep}
continue
// Not a constant operation.
// This should be detected by the scanner, but isn't at the
// moment.
panic("todo: non-const gep")
}
indices[i] = uint32(operand.ZExtValue())
indices[i] = uint32(operand.Value().ZExtValue())
}
result := value.GetElementPtr(indices)
if result.Type() != inst.Type() {