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

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

Issue 29743003: Add passes for applying SFI sandboxing at the LLVM IR level Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: Retry upload Created 6 years, 6 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 | « lib/Transforms/NaCl/SandboxMemoryAccesses.cpp ('k') | lib/Transforms/Scalar/LowerAtomic.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/NaCl/StripTls.cpp
diff --git a/lib/Transforms/NaCl/StripTls.cpp b/lib/Transforms/NaCl/StripTls.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..ec58d32d718a4334690436a9b0c0dd3b2754e0b1
--- /dev/null
+++ b/lib/Transforms/NaCl/StripTls.cpp
@@ -0,0 +1,57 @@
+//===- StripTls.cpp - Remove the thread_local attribute from variables-----===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+//
+// XXX
+//
+//===----------------------------------------------------------------------===//
+
+// #include "llvm/IR/Function.h"
+// #include "llvm/IR/Instructions.h"
+// #include "llvm/IR/Intrinsics.h"
+#include "llvm/IR/Module.h"
+#include "llvm/Pass.h"
+// #include "llvm/Support/raw_ostream.h"
+#include "llvm/Transforms/NaCl.h"
+
+using namespace llvm;
+
+namespace {
+ // This is a ModulePass so that XXX...
+ class StripTls : public ModulePass {
+ public:
+ static char ID; // Pass identification, replacement for typeid
+ StripTls() : ModulePass(ID) {
+ initializeStripTlsPass(*PassRegistry::getPassRegistry());
+ }
+
+ virtual bool runOnModule(Module &M);
+ };
+}
+
+char StripTls::ID = 0;
+INITIALIZE_PASS(StripTls, "strip-tls",
+ "Remove the thread_local attribute from variables",
+ false, false)
+
+bool StripTls::runOnModule(Module &M) {
+ bool Changed = false;
+ for (Module::global_iterator GV = M.global_begin(), E = M.global_end();
+ GV != E;
+ ++GV) {
+ if (GV->isThreadLocal()) {
+ GV->setThreadLocal(false);
+ Changed = true;
+ }
+ }
+ return Changed;
+}
+
+ModulePass *llvm::createStripTlsPass() {
+ return new StripTls();
+}
« no previous file with comments | « lib/Transforms/NaCl/SandboxMemoryAccesses.cpp ('k') | lib/Transforms/Scalar/LowerAtomic.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698