disable list of constants in read-only section

This commit is contained in:
Folkert 2021-10-03 00:16:52 +02:00
parent 7e6a3431e2
commit fa57ff88a5

View file

@ -2185,7 +2185,10 @@ fn list_literal<'a, 'ctx, 'env>(
let list_length = elems.len(); let list_length = elems.len();
let list_length_intval = env.ptr_int().const_int(list_length as _, false); let list_length_intval = env.ptr_int().const_int(list_length as _, false);
if element_type.is_int_type() { // TODO re-enable, currently causes morphic segfaults because it tries to update
// constants in-place...
// if element_type.is_int_type() {
if false {
let element_type = element_type.into_int_type(); let element_type = element_type.into_int_type();
let element_width = elem_layout.stack_size(env.ptr_bytes); let element_width = elem_layout.stack_size(env.ptr_bytes);
let size = list_length * element_width as usize; let size = list_length * element_width as usize;
@ -2228,15 +2231,16 @@ fn list_literal<'a, 'ctx, 'env>(
let val = load_symbol(scope, symbol); let val = load_symbol(scope, symbol);
let intval = val.into_int_value(); let intval = val.into_int_value();
if intval.is_const() { // here we'd like to furthermore check for intval.is_const().
global_elements.push(intval); // if all elements are const for LLVM, we could make the array a constant.
} else { // BUT morphic does not know about this, and could allow us to modify that
is_all_constant = false; // array in-place. That would cause a segfault. So, we'll have to find
// constants ourselves and cannot lean on LLVM here.
is_all_constant = false;
runtime_evaluated_elements.push((index, val)); runtime_evaluated_elements.push((index, val));
global_elements.push(element_type.get_undef()); global_elements.push(element_type.get_undef());
}
} }
}; };
} }