diff options
author | JF Bastien <jfb@chromium.org> | 2013-08-07 15:50:44 -0700 |
---|---|---|
committer | JF Bastien <jfb@chromium.org> | 2013-08-07 15:50:44 -0700 |
commit | 3b1ef29c338890ce55a1990389d8e63f6be7da2c (patch) | |
tree | 6a12c31173392c21830fdcd251e67907770dcede /lib/CodeGen/CGStmt.cpp | |
parent | e801395572ecfeb5ba913c4064944ed7fac3e806 (diff) |
Treat __sync_synchronize and asm("":::"memory") as stronger fences.
This is a companion patch to:
https://codereview.chromium.org/22240002/
https://codereview.chromium.org/22474008/
and deals with the Clang-side of things.
The above patch will handle the fallouts of this Clang patch, including
some changes to un-duplicate work that RewriteAsmDirectives.cpp
does. The goal of this patch is to force some extra ordering on
non-atomics for le32 which LLVM doesn't necessarily provide.
R=eliben@chromium.org
TEST= ninja check-all
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3475
BUG= https://code.google.com/p/nativeclient/issues/detail?id=3611
Review URL: https://codereview.chromium.org/22294002
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r-- | lib/CodeGen/CGStmt.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/lib/CodeGen/CGStmt.cpp b/lib/CodeGen/CGStmt.cpp index 5e2ebe0d9c..a381736206 100644 --- a/lib/CodeGen/CGStmt.cpp +++ b/lib/CodeGen/CGStmt.cpp @@ -1701,6 +1701,18 @@ void CodeGenFunction::EmitAsmStmt(const AsmStmt &S) { Result->addAttribute(llvm::AttributeSet::FunctionIndex, llvm::Attribute::NoUnwind); + // @LOCALMOD-START + if (getTargetHooks().asmMemoryIsFence() && IA->isAsmMemory()) { + // Targets can ask that ``asm("":::"memory")`` be treated like + // ``__sync_synchronize()``. + Builder.CreateFence(llvm::SequentiallyConsistent); + Builder.CreateCall( + llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect))-> + addAttribute(llvm::AttributeSet::FunctionIndex, + llvm::Attribute::NoUnwind); + } + // @LOCALMOD-END + // Slap the source location of the inline asm into a !srcloc metadata on the // call. FIXME: Handle metadata for MS-style inline asms. if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) |