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

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

Issue 939073008: Rebased PNaCl localmods in LLVM to 223109 (Closed)
Patch Set: undo localmod Created 5 years, 10 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/MinSFI/SandboxMemoryAccesses.cpp ('k') | lib/Transforms/MinSFI/SubstituteUndefs.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/Transforms/MinSFI/StripTls.cpp
diff --git a/lib/Transforms/MinSFI/StripTls.cpp b/lib/Transforms/MinSFI/StripTls.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..f15ae0ab30a6cb6a976cc891e5e875b2233b71eb
--- /dev/null
+++ b/lib/Transforms/MinSFI/StripTls.cpp
@@ -0,0 +1,51 @@
+//===- 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.
+//
+//===----------------------------------------------------------------------===//
+//
+// Runtime support for thread-local storage depends on pthreads which are
+// currently not supported by MinSFI. This pass removes the thread_local
+// attribute from all global variables until thread support is in place.
+//
+// The pass should be invoked before the pnacl-abi-simplify passes.
+//
+//===----------------------------------------------------------------------===//
+
+#include "llvm/Pass.h"
+#include "llvm/IR/GlobalVariable.h"
+#include "llvm/IR/Module.h"
+
+using namespace llvm;
+
+namespace {
+class StripTls : public ModulePass {
+ public:
+ static char ID;
+ StripTls() : ModulePass(ID) {
+ initializeStripTlsPass(*PassRegistry::getPassRegistry());
+ }
+
+ virtual bool runOnModule(Module &M);
+};
+} // namespace
+
+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;
+}
+
+char StripTls::ID = 0;
+INITIALIZE_PASS(StripTls, "minsfi-strip-tls",
+ "Remove the thread_local attribute from variables",
+ false, false)
« no previous file with comments | « lib/Transforms/MinSFI/SandboxMemoryAccesses.cpp ('k') | lib/Transforms/MinSFI/SubstituteUndefs.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698