@@ -55,6 +55,7 @@ static llvm::Constant *get_symbol_name_ptr(
55
55
auto *global = module->getOrInsertGlobal (
56
56
fmt::format (" sym_name_{}" , name), str->getType ());
57
57
auto *global_var = llvm::dyn_cast<llvm::GlobalVariable>(global);
58
+ global_var->setConstant (true );
58
59
if (!global_var->hasInitializer ()) {
59
60
global_var->setInitializer (str);
60
61
}
@@ -144,6 +145,7 @@ static void emit_data_table_for_symbol(
144
145
auto *table_type = llvm::ArrayType::get (ty, syms.size ());
145
146
auto *table = module->getOrInsertGlobal (" table_" + name, table_type);
146
147
auto *global_var = llvm::cast<llvm::GlobalVariable>(table);
148
+ global_var->setConstant (true );
147
149
init_debug_global (
148
150
" table_" + name,
149
151
get_array_debug_type (
@@ -437,6 +439,7 @@ emit_get_tag_for_fresh_sort(kore_definition *definition, llvm::Module *module) {
437
439
auto *global
438
440
= module->getOrInsertGlobal (" sort_name_" + name, str->getType ());
439
441
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
442
+ global_var->setConstant (true );
440
443
if (!global_var->hasInitializer ()) {
441
444
global_var->setInitializer (str);
442
445
}
@@ -504,6 +507,7 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
504
507
auto *global
505
508
= module->getOrInsertGlobal (" sort_name_" + name, str->getType ());
506
509
auto *global_var = llvm::dyn_cast<llvm::GlobalVariable>(global);
510
+ global_var->setConstant (true );
507
511
if (!global_var->hasInitializer ()) {
508
512
global_var->setInitializer (str);
509
513
}
@@ -531,6 +535,7 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
531
535
auto *str = llvm::ConstantDataArray::getString (ctx, " true" , false );
532
536
auto *global = module->getOrInsertGlobal (" bool_true" , str->getType ());
533
537
auto *global_var = llvm::dyn_cast<llvm::GlobalVariable>(global);
538
+ global_var->setConstant (true );
534
539
if (!global_var->hasInitializer ()) {
535
540
global_var->setInitializer (str);
536
541
}
@@ -625,6 +630,8 @@ static void emit_get_token(kore_definition *definition, llvm::Module *module) {
625
630
string_type, block, {zero, zero32, zero32}, " " , current_block);
626
631
auto *block_size = module->getOrInsertGlobal (
627
632
" VAR_BLOCK_SIZE" , llvm::Type::getInt64Ty (ctx));
633
+ auto *global_var = llvm::dyn_cast<llvm::GlobalVariable>(block_size);
634
+ global_var->setConstant (true );
628
635
auto *block_size_val = new llvm::LoadInst (
629
636
llvm::Type::getInt64Ty (ctx), block_size, " " , current_block);
630
637
auto *block_alloc_size = llvm::BinaryOperator::Create (
@@ -904,6 +911,7 @@ static void get_visitor(
904
911
auto *global = module->getOrInsertGlobal (
905
912
fmt::format (" sort_name_{}" , sort_name), str->getType ());
906
913
auto *global_var = llvm::dyn_cast<llvm::GlobalVariable>(global);
914
+ global_var->setConstant (true );
907
915
if (!global_var->hasInitializer ()) {
908
916
global_var->setInitializer (str);
909
917
}
@@ -1097,6 +1105,7 @@ static llvm::Constant *get_layout_data(
1097
1105
auto *global = module->getOrInsertGlobal (
1098
1106
" layout_item_" + std::to_string (layout), arr->getType ());
1099
1107
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
1108
+ global_var->setConstant (true );
1100
1109
if (!global_var->hasInitializer ()) {
1101
1110
global_var->setInitializer (arr);
1102
1111
}
@@ -1109,6 +1118,7 @@ static llvm::Constant *get_layout_data(
1109
1118
name,
1110
1119
llvm::StructType::getTypeByName (module->getContext (), layout_struct));
1111
1120
auto *global_var2 = llvm::cast<llvm::GlobalVariable>(global2);
1121
+ global_var2->setConstant (true );
1112
1122
init_debug_global (name, get_forward_decl (layout_struct), global_var2);
1113
1123
if (!global_var2->hasInitializer ()) {
1114
1124
global_var2->setInitializer (llvm::ConstantStruct::get (
@@ -1201,6 +1211,7 @@ static void emit_sort_table_for_proof_trace_serialization(
1201
1211
auto *subtable = module->getOrInsertGlobal (
1202
1212
fmt::format (" sort_tags_{}" , ast_to_string (*symbol)), subtable_type);
1203
1213
auto *subtable_var = llvm::dyn_cast<llvm::GlobalVariable>(subtable);
1214
+ subtable_var->setConstant (true );
1204
1215
init_debug_global (
1205
1216
" sort_tags_" + symbol->get_name (),
1206
1217
get_array_debug_type (
@@ -1246,6 +1257,7 @@ static void emit_sort_table(kore_definition *def, llvm::Module *mod) {
1246
1257
auto *subtable = module->getOrInsertGlobal (
1247
1258
fmt::format (" sorts_{}" , ast_to_string (*symbol)), subtable_type);
1248
1259
auto *subtable_var = llvm::dyn_cast<llvm::GlobalVariable>(subtable);
1260
+ subtable_var->setConstant (true );
1249
1261
init_debug_global (
1250
1262
" sorts_" + symbol->get_name (),
1251
1263
get_array_debug_type (
@@ -1304,6 +1316,7 @@ static void emit_return_sort_table(kore_definition *def, llvm::Module *mod) {
1304
1316
auto *sort_name
1305
1317
= module->getOrInsertGlobal (" sort_name_" + sort_str, str_type);
1306
1318
auto *global_var = llvm::cast<llvm::GlobalVariable>(sort_name);
1319
+ global_var->setConstant (true );
1307
1320
if (!global_var->hasInitializer ()) {
1308
1321
global_var->setInitializer (str);
1309
1322
}
0 commit comments