@@ -168,7 +168,7 @@ static Constant *julia_const_to_llvm(jl_codectx_t &ctx, const void *ptr, jl_data
168168 return ConstantFP::get (jl_LLVMContext,
169169 APFloat (lt->getFltSemantics (), APInt (64 , data64)));
170170 }
171- if (lt->isFloatingPointTy () || lt->isIntegerTy ()) {
171+ if (lt->isFloatingPointTy () || lt->isIntegerTy () || lt-> isPointerTy () ) {
172172 int nb = jl_datatype_size (bt);
173173 APInt val (8 * nb, 0 );
174174 void *bits = const_cast <uint64_t *>(val.getRawData ());
@@ -178,6 +178,11 @@ static Constant *julia_const_to_llvm(jl_codectx_t &ctx, const void *ptr, jl_data
178178 return ConstantFP::get (jl_LLVMContext,
179179 APFloat (lt->getFltSemantics (), val));
180180 }
181+ if (lt->isPointerTy ()) {
182+ Type *Ty = IntegerType::get (jl_LLVMContext, 8 * nb);
183+ Constant *addr = ConstantInt::get (Ty, val);
184+ return ConstantExpr::getIntToPtr (addr, lt);
185+ }
181186 assert (cast<IntegerType>(lt)->getBitWidth () == 8u * nb);
182187 return ConstantInt::get (lt, val);
183188 }
@@ -257,8 +262,10 @@ static Constant *julia_const_to_llvm(jl_codectx_t &ctx, const void *ptr, jl_data
257262 return ConstantVector::get (fields);
258263 if (StructType *st = dyn_cast<StructType>(lt))
259264 return ConstantStruct::get (st, fields);
260- ArrayType *at = cast<ArrayType>(lt);
261- return ConstantArray::get (at, fields);
265+ if (ArrayType *at = dyn_cast<ArrayType>(lt))
266+ return ConstantArray::get (at, fields);
267+ assert (false && " Unknown LLVM type" );
268+ jl_unreachable ();
262269}
263270
264271static Constant *julia_const_to_llvm (jl_codectx_t &ctx, jl_value_t *e)
0 commit comments