Skip to content

Commit

Permalink
Merge pull request #16309 from JuliaLang/yyc/threads/signal_fence
Browse files Browse the repository at this point in the history
Use inlineasm as signal fence on ARM and AArch64
  • Loading branch information
yuyichao committed May 11, 2016
2 parents 85c20a7 + 779f7ac commit b7eed50
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/cgutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1762,10 +1762,19 @@ static Value *emit_exc_in_transit(jl_codectx_t *ctx)

static void emit_signal_fence(void)
{
#ifdef LLVM39
builder.CreateFence(AtomicOrdering::SequentiallyConsistent, SingleThread);
#if defined(_CPU_ARM_) || defined(_CPU_AARCH64_)
// LLVM generates very inefficient code (and might include function call)
// for signal fence. Fallback to the poor man signal fence with
// inline asm instead.
// https://llvm.org/bugs/show_bug.cgi?id=27545
builder.CreateCall(InlineAsm::get(FunctionType::get(T_void, false), "",
"~{memory}", true));
#else
# ifdef LLVM39
builder.CreateFence(AtomicOrdering::SequentiallyConsistent, SingleThread);
# else
builder.CreateFence(SequentiallyConsistent, SingleThread);
# endif
#endif
}

Expand Down
3 changes: 3 additions & 0 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,9 @@
#include <llvm/ExecutionEngine/JITMemoryManager.h>
#include <llvm/ExecutionEngine/Interpreter.h>
#endif
#if defined(_CPU_ARM_) || defined(_CPU_AARCH64_)
# include <llvm/IR/InlineAsm.h>
#endif

using namespace llvm;

Expand Down

0 comments on commit b7eed50

Please sign in to comment.