@@ -168,7 +168,7 @@ static Constant *julia_const_to_llvm(jl_codectx_t &ctx, const void *ptr, jl_data
168
168
return ConstantFP::get (jl_LLVMContext,
169
169
APFloat (lt->getFltSemantics (), APInt (64 , data64)));
170
170
}
171
- if (lt->isFloatingPointTy () || lt->isIntegerTy ()) {
171
+ if (lt->isFloatingPointTy () || lt->isIntegerTy () || lt-> isPointerTy () ) {
172
172
int nb = jl_datatype_size (bt);
173
173
APInt val (8 * nb, 0 );
174
174
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
178
178
return ConstantFP::get (jl_LLVMContext,
179
179
APFloat (lt->getFltSemantics (), val));
180
180
}
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
+ }
181
186
assert (cast<IntegerType>(lt)->getBitWidth () == 8u * nb);
182
187
return ConstantInt::get (lt, val);
183
188
}
@@ -257,8 +262,10 @@ static Constant *julia_const_to_llvm(jl_codectx_t &ctx, const void *ptr, jl_data
257
262
return ConstantVector::get (fields);
258
263
if (StructType *st = dyn_cast<StructType>(lt))
259
264
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 ();
262
269
}
263
270
264
271
static Constant *julia_const_to_llvm (jl_codectx_t &ctx, jl_value_t *e)
0 commit comments