Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(852)

Side by Side Diff: lib/CodeGen/CGStmt.cpp

Issue 22294002: Treat __sync_synchronize and asm("":::"memory") as stronger fences. (Closed) Base URL: http://git.chromium.org/native_client/pnacl-clang.git@master
Patch Set: Make isAsmMemory a member of InlineAsm as suggested by eliben. Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « lib/CodeGen/CGBuiltin.cpp ('k') | lib/CodeGen/TargetInfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===// 1 //===--- CGStmt.cpp - Emit LLVM Code from Statements ----------------------===//
2 // 2 //
3 // The LLVM Compiler Infrastructure 3 // The LLVM Compiler Infrastructure
4 // 4 //
5 // This file is distributed under the University of Illinois Open Source 5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details. 6 // License. See LICENSE.TXT for details.
7 // 7 //
8 //===----------------------------------------------------------------------===// 8 //===----------------------------------------------------------------------===//
9 // 9 //
10 // This contains code to emit Stmt nodes as LLVM code. 10 // This contains code to emit Stmt nodes as LLVM code.
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
1694 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0; 1694 bool HasSideEffect = S.isVolatile() || S.getNumOutputs() == 0;
1695 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ? 1695 llvm::InlineAsm::AsmDialect AsmDialect = isa<MSAsmStmt>(&S) ?
1696 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT; 1696 llvm::InlineAsm::AD_Intel : llvm::InlineAsm::AD_ATT;
1697 llvm::InlineAsm *IA = 1697 llvm::InlineAsm *IA =
1698 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect, 1698 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect,
1699 /* IsAlignStack */ false, AsmDialect); 1699 /* IsAlignStack */ false, AsmDialect);
1700 llvm::CallInst *Result = Builder.CreateCall(IA, Args); 1700 llvm::CallInst *Result = Builder.CreateCall(IA, Args);
1701 Result->addAttribute(llvm::AttributeSet::FunctionIndex, 1701 Result->addAttribute(llvm::AttributeSet::FunctionIndex,
1702 llvm::Attribute::NoUnwind); 1702 llvm::Attribute::NoUnwind);
1703 1703
1704 // @LOCALMOD-START
1705 if (getTargetHooks().asmMemoryIsFence() && IA->isAsmMemory()) {
1706 // Targets can ask that ``asm("":::"memory")`` be treated like
1707 // ``__sync_synchronize()``.
1708 Builder.CreateFence(llvm::SequentiallyConsistent);
1709 Builder.CreateCall(
1710 llvm::InlineAsm::get(FTy, AsmString, Constraints, HasSideEffect))->
1711 addAttribute(llvm::AttributeSet::FunctionIndex,
1712 llvm::Attribute::NoUnwind);
1713 }
1714 // @LOCALMOD-END
1715
1704 // Slap the source location of the inline asm into a !srcloc metadata on the 1716 // Slap the source location of the inline asm into a !srcloc metadata on the
1705 // call. FIXME: Handle metadata for MS-style inline asms. 1717 // call. FIXME: Handle metadata for MS-style inline asms.
1706 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S)) 1718 if (const GCCAsmStmt *gccAsmStmt = dyn_cast<GCCAsmStmt>(&S))
1707 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(), 1719 Result->setMetadata("srcloc", getAsmSrcLocInfo(gccAsmStmt->getAsmString(),
1708 *this)); 1720 *this));
1709 1721
1710 // Extract all of the register value results from the asm. 1722 // Extract all of the register value results from the asm.
1711 std::vector<llvm::Value*> RegResults; 1723 std::vector<llvm::Value*> RegResults;
1712 if (ResultRegTypes.size() == 1) { 1724 if (ResultRegTypes.size() == 1) {
1713 RegResults.push_back(Result); 1725 RegResults.push_back(Result);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1747 } 1759 }
1748 } 1760 }
1749 1761
1750 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]); 1762 EmitStoreThroughLValue(RValue::get(Tmp), ResultRegDests[i]);
1751 } 1763 }
1752 } 1764 }
1753 1765
1754 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) { 1766 void CodeGenFunction::EmitCapturedStmt(const CapturedStmt &S) {
1755 llvm_unreachable("not implemented yet"); 1767 llvm_unreachable("not implemented yet");
1756 } 1768 }
OLDNEW
« no previous file with comments | « lib/CodeGen/CGBuiltin.cpp ('k') | lib/CodeGen/TargetInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698