Skip to content

Commit

Permalink
only use CreateThreadLocalAddress() #ifdef __MACH__
Browse files Browse the repository at this point in the history
  • Loading branch information
stevenmeker committed Oct 25, 2024
1 parent d47a99b commit 93ac37c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/codegen/CreateTerm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -783,8 +783,12 @@ llvm::Value *create_term::disable_gc() {
= module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_));
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
global_var->setThreadLocal(true);
#ifdef __MACH__
llvm::IRBuilder b(current_block_);
auto global_var_address = b.CreateThreadLocalAddress(global_var);
#else
auto global_var_address = global_var;
#endif
auto *old_val = new llvm::LoadInst(
llvm::Type::getInt1Ty(ctx_), global_var_address, "was_enabled",
current_block_);
Expand All @@ -798,8 +802,12 @@ void create_term::enable_gc(llvm::Value *was_enabled) {
= module_->getOrInsertGlobal("gc_enabled", llvm::Type::getInt1Ty(ctx_));
auto *global_var = llvm::cast<llvm::GlobalVariable>(global);
global_var->setThreadLocal(true);
#ifdef __MACH__
llvm::IRBuilder b(current_block_);
auto global_var_address = b.CreateThreadLocalAddress(global_var);
#else
auto global_var_address = global_var;
#endif
new llvm::StoreInst(was_enabled, global_var_address, current_block_);
}

Expand Down

0 comments on commit 93ac37c

Please sign in to comment.