aboutsummaryrefslogtreecommitdiff
path: root/src/llvm_backend_proc.cpp
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2023-09-28 16:01:26 +0100
committerGitHub <noreply@github.com>2023-09-28 16:01:26 +0100
commit77227c2ff552a81741130ae17d58847c3cfe3ba3 (patch)
treee690e5feae8aad170ce4d18bc11c279ec23cce45 /src/llvm_backend_proc.cpp
parent2370884722c9638cf0ba3916a8a54247096bb4f6 (diff)
parent2afccd7fbdb3a7c440597356fa4c9d635a06a8d2 (diff)
Merge pull request #2805 from odin-lang/llvm-17
Support LLVM 17.0.1
Diffstat (limited to 'src/llvm_backend_proc.cpp')
-rw-r--r--src/llvm_backend_proc.cpp32
1 files changed, 28 insertions, 4 deletions
diff --git a/src/llvm_backend_proc.cpp b/src/llvm_backend_proc.cpp
index b8f6f0f30..3b145b09d 100644
--- a/src/llvm_backend_proc.cpp
+++ b/src/llvm_backend_proc.cpp
@@ -139,7 +139,7 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
lb_ensure_abi_function_type(m, p);
lb_add_function_type_attributes(p->value, p->abi_function_type, p->abi_function_type->calling_convention);
-
+
if (pt->Proc.diverging) {
lb_add_attribute_to_proc(m, p->value, "noreturn");
}
@@ -152,7 +152,6 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
lb_add_attribute_to_proc(m, p->value, "noredzone");
}
-
switch (p->inlining) {
case ProcInlining_inline:
lb_add_attribute_to_proc(m, p->value, "alwaysinline");
@@ -318,6 +317,18 @@ gb_internal lbProcedure *lb_create_procedure(lbModule *m, Entity *entity, bool i
}
}
+ if (p->body && entity->pkg && ((entity->pkg->kind == Package_Normal) || (entity->pkg->kind == Package_Init))) {
+ if (build_context.sanitizer_flags & SanitizerFlag_Address) {
+ lb_add_attribute_to_proc(m, p->value, "sanitize_address");
+ }
+ if (build_context.sanitizer_flags & SanitizerFlag_Memory) {
+ lb_add_attribute_to_proc(m, p->value, "sanitize_memory");
+ }
+ if (build_context.sanitizer_flags & SanitizerFlag_Thread) {
+ lb_add_attribute_to_proc(m, p->value, "sanitize_thread");
+ }
+ }
+
lbValue proc_value = {p->value, p->type};
lb_add_entity(m, entity, proc_value);
lb_add_member(m, p->name, proc_value);
@@ -853,8 +864,21 @@ gb_internal lbValue lb_emit_call_internal(lbProcedure *p, lbValue value, lbValue
for (unsigned i = 0; i < param_count; i++) {
LLVMTypeRef param_type = param_types[i];
LLVMTypeRef arg_type = LLVMTypeOf(args[i]);
- // LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
- // LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
+ if (LB_USE_NEW_PASS_SYSTEM &&
+ arg_type != param_type) {
+ LLVMTypeKind arg_kind = LLVMGetTypeKind(arg_type);
+ LLVMTypeKind param_kind = LLVMGetTypeKind(param_type);
+ if (arg_kind == param_kind &&
+ arg_kind == LLVMPointerTypeKind) {
+ // NOTE(bill): LLVM's newer `ptr` only type system seems to fail at times
+ // I don't know why...
+ args[i] = LLVMBuildPointerCast(p->builder, args[i], param_type, "");
+ gb_printf_err("%s\n", LLVMPrintValueToString(args[i]));
+ arg_type = param_type;
+ continue;
+ }
+ }
+
GB_ASSERT_MSG(
arg_type == param_type,
"Parameter types do not match: %s != %s, argument: %s\n\t%s",