Browse Source

Mark external thread local globals

gingerBill 4 years ago
parent
commit
579b317be8
2 changed files with 22 additions and 0 deletions
  1. 19 0
      src/llvm_backend.cpp
  2. 3 0
      src/main.cpp

+ 19 - 0
src/llvm_backend.cpp

@@ -5773,6 +5773,25 @@ lbValue lb_find_value_from_entity(lbModule *m, Entity *e) {
 			g.type = alloc_type_pointer(e->type);
 			LLVMSetLinkage(g.value, LLVMExternalLinkage);
 
+			if (e->Variable.thread_local_model != "") {
+				LLVMSetThreadLocal(g.value, true);
+
+				String m = e->Variable.thread_local_model;
+				LLVMThreadLocalMode mode = LLVMGeneralDynamicTLSModel;
+				if (m == "default") {
+					mode = LLVMGeneralDynamicTLSModel;
+				} else if (m == "localdynamic") {
+					mode = LLVMLocalDynamicTLSModel;
+				} else if (m == "initialexec") {
+					mode = LLVMInitialExecTLSModel;
+				} else if (m == "localexec") {
+					mode = LLVMLocalExecTLSModel;
+				} else {
+					GB_PANIC("Unhandled thread local mode %.*s", LIT(m));
+				}
+				LLVMSetThreadLocalMode(g.value, mode);
+			}
+
 			lb_add_entity(m, e, g);
 			lb_add_member(m, name, g);
 			return g;

+ 3 - 0
src/main.cpp

@@ -2176,6 +2176,9 @@ int main(int arg_count, char const **arg_ptr) {
 	case BuildMode_DynamicLibrary:
 		i32 result = linker_stage(&gen);
 		if (result != 0) {
+			if (build_context.show_timings) {
+				show_timings(&checker, timings);
+			}
 			return 1;
 		}
 		break;