aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2022-02-28 14:35:38 +0000
committergingerBill <bill@gingerbill.org>2022-02-28 14:35:38 +0000
commit2d89faa17cf88b76e183e35f4d50722271c76d20 (patch)
tree274521da1527d8f7242a0415a78ccf514c0a8d3f /src
parent882116e35819937206e14dbf02d1c9ad42037d93 (diff)
Add extra checks for -disallow-rtti
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend.cpp9
-rw-r--r--src/llvm_backend_type.cpp8
2 files changed, 15 insertions, 2 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp
index 04c3200f8..40c06c23a 100644
--- a/src/llvm_backend.cpp
+++ b/src/llvm_backend.cpp
@@ -624,6 +624,9 @@ struct lbGlobalVariable {
};
lbProcedure *lb_create_startup_type_info(lbModule *m) {
+ if (build_context.disallow_rtti) {
+ return nullptr;
+ }
LLVMPassManagerRef default_function_pass_manager = LLVMCreateFunctionPassManagerForModule(m->mod);
lb_populate_function_pass_manager(m, default_function_pass_manager, false, build_context.optimization_level);
LLVMFinalizeFunctionPassManager(default_function_pass_manager);
@@ -711,7 +714,9 @@ lbProcedure *lb_create_startup_runtime(lbModule *main_module, lbProcedure *start
lb_begin_procedure_body(p);
- LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, startup_type_info->type)), startup_type_info->value, nullptr, 0, "");
+ if (startup_type_info) {
+ LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, startup_type_info->type)), startup_type_info->value, nullptr, 0, "");
+ }
if (objc_names) {
LLVMBuildCall2(p->builder, LLVMGetElementType(lb_type(main_module, objc_names->type)), objc_names->value, nullptr, 0, "");
@@ -1394,7 +1399,7 @@ void lb_generate_code(lbGenerator *gen) {
TIME_SECTION("LLVM Global Variables");
- {
+ if (!build_context.disallow_rtti) {
lbModule *m = default_module;
{ // Add type info data
diff --git a/src/llvm_backend_type.cpp b/src/llvm_backend_type.cpp
index 1aac75f9c..e245a8b40 100644
--- a/src/llvm_backend_type.cpp
+++ b/src/llvm_backend_type.cpp
@@ -90,6 +90,8 @@ lbValue lb_typeid(lbModule *m, Type *type) {
}
lbValue lb_type_info(lbModule *m, Type *type) {
+ GB_ASSERT(!build_context.disallow_rtti);
+
type = default_type(type);
isize index = lb_type_info_index(m->info, type);
@@ -108,6 +110,8 @@ lbValue lb_type_info(lbModule *m, Type *type) {
}
lbValue lb_get_type_info_ptr(lbModule *m, Type *type) {
+ GB_ASSERT(!build_context.disallow_rtti);
+
i32 index = cast(i32)lb_type_info_index(m->info, type);
GB_ASSERT(index >= 0);
// gb_printf_err("%d %s\n", index, type_to_string(type));
@@ -157,6 +161,10 @@ lbValue lb_type_info_member_tags_offset(lbProcedure *p, isize count) {
void lb_setup_type_info_data(lbProcedure *p) { // NOTE(bill): Setup type_info data
+ if (build_context.disallow_rtti) {
+ return;
+ }
+
lbModule *m = p->module;
CheckerInfo *info = m->info;