Browse Source

Fix calling convention stuff with LLVM C API

gingerBill 5 years ago
parent
commit
37a3abdaaa
2 changed files with 8 additions and 3 deletions
  1. 7 3
      src/llvm_backend.cpp
  2. 1 0
      src/llvm_backend.hpp

+ 7 - 3
src/llvm_backend.cpp

@@ -2032,7 +2032,7 @@ lbProcedure *lb_create_procedure(lbModule *m, Entity *entity) {
 	if (build_context.metrics.os != TargetOs_js)  {
 	if (build_context.metrics.os != TargetOs_js)  {
 		cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
 		cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
 	}
 	}
-	LLVMSetFunctionCallConv(p->value, lb_calling_convention_map[pt->Proc.calling_convention]);
+	LLVMSetFunctionCallConv(p->value, cc_kind);
 	lbValue proc_value = {p->value, p->type};
 	lbValue proc_value = {p->value, p->type};
 	lb_add_entity(m, entity,  proc_value);
 	lb_add_entity(m, entity,  proc_value);
 	lb_add_member(m, p->name, proc_value);
 	lb_add_member(m, p->name, proc_value);
@@ -2172,8 +2172,12 @@ lbProcedure *lb_create_dummy_procedure(lbModule *m, String link_name, Type *type
 	p->value = LLVMAddFunction(m->mod, c_link_name, func_type);
 	p->value = LLVMAddFunction(m->mod, c_link_name, func_type);
 
 
 	Type *pt = p->type;
 	Type *pt = p->type;
-
-	LLVMSetFunctionCallConv(p->value, lb_calling_convention_map[pt->Proc.calling_convention]);
+	lbCallingConventionKind cc_kind = lbCallingConvention_C;
+	// TODO(bill): Clean up this logic
+	if (build_context.metrics.os != TargetOs_js)  {
+		cc_kind = lb_calling_convention_map[pt->Proc.calling_convention];
+	}
+	LLVMSetFunctionCallConv(p->value, cc_kind);
 	lbValue proc_value = {p->value, p->type};
 	lbValue proc_value = {p->value, p->type};
 	lb_add_member(m, p->name, proc_value);
 	lb_add_member(m, p->name, proc_value);
 	lb_add_procedure_value(m, p);
 	lb_add_procedure_value(m, p);

+ 1 - 0
src/llvm_backend.hpp

@@ -415,6 +415,7 @@ lbCallingConventionKind const lb_calling_convention_map[ProcCC_MAX] = {
 	lbCallingConvention_C,            // ProcCC_Invalid,
 	lbCallingConvention_C,            // ProcCC_Invalid,
 	lbCallingConvention_C,            // ProcCC_Odin,
 	lbCallingConvention_C,            // ProcCC_Odin,
 	lbCallingConvention_C,            // ProcCC_Contextless,
 	lbCallingConvention_C,            // ProcCC_Contextless,
+	lbCallingConvention_C,            // ProcCC_Pure,
 	lbCallingConvention_C,            // ProcCC_CDecl,
 	lbCallingConvention_C,            // ProcCC_CDecl,
 	lbCallingConvention_X86_StdCall,  // ProcCC_StdCall,
 	lbCallingConvention_X86_StdCall,  // ProcCC_StdCall,
 	lbCallingConvention_X86_FastCall, // ProcCC_FastCall,
 	lbCallingConvention_X86_FastCall, // ProcCC_FastCall,