OLD | NEW |
(Empty) | |
| 1 //===- StripTls.cpp - Remove the thread_local attribute from variables ----===// |
| 2 // |
| 3 // The LLVM Compiler Infrastructure |
| 4 // |
| 5 // This file is distributed under the University of Illinois Open Source |
| 6 // License. See LICENSE.TXT for details. |
| 7 // |
| 8 //===----------------------------------------------------------------------===// |
| 9 // |
| 10 // Runtime support for thread-local storage depends on pthreads which are |
| 11 // currently not supported by MinSFI. This pass removes the thread_local |
| 12 // attribute from all global variables until thread support is in place. |
| 13 // |
| 14 // The pass should be invoked before the pnacl-abi-simplify passes. |
| 15 // |
| 16 //===----------------------------------------------------------------------===// |
| 17 |
| 18 #include "llvm/Pass.h" |
| 19 #include "llvm/IR/GlobalVariable.h" |
| 20 #include "llvm/IR/Module.h" |
| 21 |
| 22 using namespace llvm; |
| 23 |
| 24 namespace { |
| 25 class StripTls : public ModulePass { |
| 26 public: |
| 27 static char ID; |
| 28 StripTls() : ModulePass(ID) { |
| 29 initializeStripTlsPass(*PassRegistry::getPassRegistry()); |
| 30 } |
| 31 |
| 32 virtual bool runOnModule(Module &M); |
| 33 }; |
| 34 } // namespace |
| 35 |
| 36 bool StripTls::runOnModule(Module &M) { |
| 37 bool Changed = false; |
| 38 for (Module::global_iterator GV = M.global_begin(), E = M.global_end(); |
| 39 GV != E; ++GV) { |
| 40 if (GV->isThreadLocal()) { |
| 41 GV->setThreadLocal(false); |
| 42 Changed = true; |
| 43 } |
| 44 } |
| 45 return Changed; |
| 46 } |
| 47 |
| 48 char StripTls::ID = 0; |
| 49 INITIALIZE_PASS(StripTls, "minsfi-strip-tls", |
| 50 "Remove the thread_local attribute from variables", |
| 51 false, false) |
OLD | NEW |