From 01ef691b842db30951d4c554ca3045420f58bab2 Mon Sep 17 00:00:00 2001 From: Yan Da Date: Wed, 9 Dec 2020 14:36:00 +0800 Subject: [PATCH] [LANG] Fix gep bug in INC --- lib/lang/code_gen.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/lang/code_gen.cc b/lib/lang/code_gen.cc index 647742ea0..6de85ea25 100644 --- a/lib/lang/code_gen.cc +++ b/lib/lang/code_gen.cc @@ -203,11 +203,12 @@ ir::value* Generator::GenUnaryInc(UnaryOp* expr, bool is_postfix, else instr = bld_->create_sub(arg, _1); } else if (arg->get_type()->is_pointer_ty()) { - _1 = ir::constant_int::get(arg->get_type(), 1); + ir::type *ty = ir::type::get_int64_ty(*ctx_); + _1 = ir::constant_int::get(ty, 1); if (is_inc) instr = bld_->create_gep(arg, {_1}); else { - ir::value *neg_1 = ir::constant_int::get(arg->get_type(), -1); + ir::value *neg_1 = ir::constant_int::get(ty, -1); instr = bld_->create_gep(arg, {neg_1}); } } else