aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_const.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/llvm_backend_const.cpp')
-rw-r--r--src/llvm_backend_const.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index c9d2f5b26..2a121ff5d 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -473,6 +473,7 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
if (value.kind == ExactValue_Procedure) {
lbValue res = {};
Ast *expr = unparen_expr(value.value_procedure);
+ GB_ASSERT(expr != nullptr);
if (expr->kind == Ast_ProcLit) {
res = lb_generate_anonymous_proc_lit(m, str_lit("_proclit"), expr);
} else {
@@ -482,7 +483,10 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, bo
GB_ASSERT(res.value != nullptr);
GB_ASSERT(LLVMGetValueKind(res.value) == LLVMFunctionValueKind);
- res.value = LLVMConstPointerCast(res.value, lb_type(m, res.type));
+ if (LLVMGetIntrinsicID(res.value) == 0) {
+ // NOTE(bill): do not cast intrinsics as they are not really procedures that can be casted
+ res.value = LLVMConstPointerCast(res.value, lb_type(m, res.type));
+ }
return res;
}