From e34dffb45cd995d3445f6b93e60e6bb3d4dd681f Mon Sep 17 00:00:00 2001 From: Steven Eker Date: Thu, 24 Oct 2024 23:11:34 +0200 Subject: [PATCH] use CreateThreadLocalAddress() to get address to use for thread_local variable gc_enabled --- lib/codegen/CreateTerm.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/codegen/CreateTerm.cpp b/lib/codegen/CreateTerm.cpp index 4de24be17..52ee57c78 100644 --- a/lib/codegen/CreateTerm.cpp +++ b/lib/codegen/CreateTerm.cpp @@ -783,10 +783,12 @@ llvm::Value *create_term::disable_gc() { = module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_)); auto *global_var = llvm::cast(global); global_var->setThreadLocal(true); + llvm::IRBuilder b(current_block_); + auto global_var_address = b.CreateThreadLocalAddress(global_var); auto *old_val = new llvm::LoadInst( - llvm::Type::getInt1Ty(ctx_), global_var, "was_enabled", current_block_); + llvm::Type::getInt1Ty(ctx_), global_var_address, "was_enabled", current_block_); new llvm::StoreInst( - llvm::ConstantInt::getFalse(ctx_), global_var, current_block_); + llvm::ConstantInt::getFalse(ctx_), global_var_address, current_block_); return old_val; } @@ -795,7 +797,9 @@ void create_term::enable_gc(llvm::Value *was_enabled) { = module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_)); auto *global_var = llvm::cast(global); global_var->setThreadLocal(true); - new llvm::StoreInst(was_enabled, global_var, current_block_); + llvm::IRBuilder b(current_block_); + auto global_var_address = b.CreateThreadLocalAddress(global_var); + new llvm::StoreInst(was_enabled, global_var_address, current_block_); } // We use tailcc calling convention for apply_rule_* and eval_* functions to