Skip to content

Commit aa3ae6a

Browse files
gbaraldivchuravy
authored andcommitted
Address clangsa concerns on macos + add workaround for static analyzer bug
1 parent 0a436bf commit aa3ae6a

File tree

5 files changed

+14
-6
lines changed

5 files changed

+14
-6
lines changed

src/cgutils.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -466,6 +466,9 @@ Constant *literal_pointer_val_slot(jl_codegen_params_t &params, Module *M, jl_va
466466
if (addr->smalltag) {
467467
// some common builtin datatypes have a special pool for accessing them by smalltag id
468468
Constant *tag = ConstantInt::get(getInt32Ty(M->getContext()), addr->smalltag << 4);
469+
#ifdef __clang_analyzer__
470+
[[clang::suppress]] // Workaround https://github.com/llvm/llvm-project/issues/119415
471+
#endif
469472
Constant *smallp = ConstantExpr::getInBoundsGetElementPtr(getInt8Ty(M->getContext()), prepare_global_in(M, jl_small_typeof_var), tag);
470473
if (smallp->getType()->getPointerAddressSpace() != 0)
471474
smallp = ConstantExpr::getAddrSpaceCast(smallp, getPointerTy(M->getContext()));

src/debuginfo.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1249,7 +1249,7 @@ extern "C" JL_DLLEXPORT_CODEGEN int jl_getFunctionInfo_impl(jl_frame_t **frames_
12491249
frames[0].line = -1;
12501250
*frames_out = frames;
12511251

1252-
llvm::DIContext *context;
1252+
llvm::DIContext *context = nullptr;
12531253
object::SectionRef Section;
12541254
int64_t slide;
12551255
uint64_t symsize;

src/jitlayers.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1217,11 +1217,11 @@ class JLDebuginfoPlugin : public ObjectLinkingLayer::Plugin {
12171217

12181218
class JLMemoryUsagePlugin : public ObjectLinkingLayer::Plugin {
12191219
private:
1220-
std::atomic<size_t> &jit_bytes_size;
1220+
_Atomic(size_t)* jit_bytes_size;
12211221

12221222
public:
12231223

1224-
JLMemoryUsagePlugin(std::atomic<size_t> &jit_bytes_size)
1224+
JLMemoryUsagePlugin(_Atomic(size_t)* jit_bytes_size)
12251225
: jit_bytes_size(jit_bytes_size) {}
12261226

12271227
Error notifyFailed(orc::MaterializationResponsibility &MR) override {
@@ -1258,7 +1258,7 @@ class JLMemoryUsagePlugin : public ObjectLinkingLayer::Plugin {
12581258
}
12591259
(void) code_size;
12601260
(void) data_size;
1261-
this->jit_bytes_size.fetch_add(graph_size, std::memory_order_relaxed);
1261+
jl_atomic_fetch_add_relaxed(this->jit_bytes_size, graph_size)
12621262
jl_timing_counter_inc(JL_TIMING_COUNTER_JITSize, graph_size);
12631263
jl_timing_counter_inc(JL_TIMING_COUNTER_JITCodeSize, code_size);
12641264
jl_timing_counter_inc(JL_TIMING_COUNTER_JITDataSize, data_size);
@@ -2001,7 +2001,7 @@ JuliaOJIT::JuliaOJIT()
20012001
ES, std::move(ehRegistrar)));
20022002

20032003
ObjectLayer.addPlugin(std::make_unique<JLDebuginfoPlugin>());
2004-
ObjectLayer.addPlugin(std::make_unique<JLMemoryUsagePlugin>(jit_bytes_size));
2004+
ObjectLayer.addPlugin(std::make_unique<JLMemoryUsagePlugin>(&jit_bytes_size));
20052005
#else
20062006
UnlockedObjectLayer.setNotifyLoaded(registerRTDyldJITObject);
20072007
#endif

src/signals-mach.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ static void jl_throw_in_thread(jl_ptls_t ptls2, mach_port_t thread, jl_value_t *
339339
NULL /*current_task?*/);
340340
ptls2->sig_exception = exception;
341341
ptls2->io_wait = 0;
342-
jl_task_t *ct = ptls2->current_task;
342+
jl_task_t *ct = jl_atomic_load_relaxed(&ptls2->current_task);
343343
jl_handler_t *eh = ct->eh;
344344
if (eh != NULL) {
345345
asan_unpoison_task_stack(ct, &eh->eh_ctx);

src/threading.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -322,6 +322,11 @@ JL_DLLEXPORT uint64_t jl_get_ptls_rng(void) JL_NOTSAFEPOINT
322322
return jl_current_task->ptls->rngseed;
323323
}
324324

325+
326+
#if !defined(_OS_WINDOWS_) && !defined(JL_DISABLE_LIBUNWIND) && !defined(LLVMLIBUNWIND)
327+
extern int unw_ensure_tls (void);
328+
#endif
329+
325330
// get thread local rng
326331
JL_DLLEXPORT void jl_set_ptls_rng(uint64_t new_seed) JL_NOTSAFEPOINT
327332
{

0 commit comments

Comments
 (0)