aboutsummaryrefslogtreecommitdiff
path: root/lib/CodeGen/CGStmt.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'lib/CodeGen/CGStmt.cpp')
-rw-r--r--lib/CodeGen/CGStmt.cpp12
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))