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

Unified Diff: lib/Transforms/NaCl/RewriteAtomics.cpp

Issue 857403002: Emit atomic memory order other than seq_cst on demand only (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Add test for -pnacl-memory-order-seq-cst-only=true Created 5 years, 11 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/Transforms/NaCl/atomic/atomic-seq-cst-only.ll » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/NaCl/RewriteAtomics.cpp
diff --git a/lib/Transforms/NaCl/RewriteAtomics.cpp b/lib/Transforms/NaCl/RewriteAtomics.cpp
index 6b02dea276886ba3885d1efda51fbed3d30d360a..8aafe3d13d3f1615da60f2e26e03e3b8e7bab6cf 100644
--- a/lib/Transforms/NaCl/RewriteAtomics.cpp
+++ b/lib/Transforms/NaCl/RewriteAtomics.cpp
@@ -19,12 +19,13 @@
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/InlineAsm.h"
+#include "llvm/IR/InstVisitor.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/Intrinsics.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NaClAtomicIntrinsics.h"
-#include "llvm/IR/InstVisitor.h"
#include "llvm/Pass.h"
+#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Compiler.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Transforms/NaCl.h"
@@ -33,7 +34,17 @@
using namespace llvm;
+// TODO(jfb) Keep the default of this option to true for Chrome 42, and change
+// it to false for Chrome 43. This allows the PNaCl translator to be
+// updated before the SDK starts emitting atomic memory orders that
+// the old translator rejected.
+static cl::opt<bool> PNaClMemoryOrderSeqCstOnly(
+ "pnacl-memory-order-seq-cst-only",
+ cl::desc("PNaCl should upgrade all atomic memory orders to seq_cst"),
+ cl::init(true));
+
namespace {
+
class RewriteAtomics : public ModulePass {
public:
static char ID; // Pass identification, replacement for typeid
@@ -195,7 +206,7 @@ ConstantInt *AtomicVisitor::freezeMemoryOrder(const Instruction &I,
}
// TODO For now only acquire/release/acq_rel/seq_cst are allowed.
- if (AO == NaCl::MemoryOrderRelaxed)
+ if (PNaClMemoryOrderSeqCstOnly || AO == NaCl::MemoryOrderRelaxed)
AO = NaCl::MemoryOrderSequentiallyConsistent;
return ConstantInt::get(Type::getInt32Ty(C), AO);
« no previous file with comments | « no previous file | test/Transforms/NaCl/atomic/atomic-seq-cst-only.ll » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698