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 // XXX |
| 11 // |
| 12 //===----------------------------------------------------------------------===// |
| 13 |
| 14 // #include "llvm/IR/Function.h" |
| 15 // #include "llvm/IR/Instructions.h" |
| 16 // #include "llvm/IR/Intrinsics.h" |
| 17 #include "llvm/IR/Module.h" |
| 18 #include "llvm/Pass.h" |
| 19 // #include "llvm/Support/raw_ostream.h" |
| 20 #include "llvm/Transforms/NaCl.h" |
| 21 |
| 22 using namespace llvm; |
| 23 |
| 24 namespace { |
| 25 // This is a ModulePass so that XXX... |
| 26 class StripTls : public ModulePass { |
| 27 public: |
| 28 static char ID; // Pass identification, replacement for typeid |
| 29 StripTls() : ModulePass(ID) { |
| 30 initializeStripTlsPass(*PassRegistry::getPassRegistry()); |
| 31 } |
| 32 |
| 33 virtual bool runOnModule(Module &M); |
| 34 }; |
| 35 } |
| 36 |
| 37 char StripTls::ID = 0; |
| 38 INITIALIZE_PASS(StripTls, "strip-tls", |
| 39 "Remove the thread_local attribute from variables", |
| 40 false, false) |
| 41 |
| 42 bool StripTls::runOnModule(Module &M) { |
| 43 bool Changed = false; |
| 44 for (Module::global_iterator GV = M.global_begin(), E = M.global_end(); |
| 45 GV != E; |
| 46 ++GV) { |
| 47 if (GV->isThreadLocal()) { |
| 48 GV->setThreadLocal(false); |
| 49 Changed = true; |
| 50 } |
| 51 } |
| 52 return Changed; |
| 53 } |
| 54 |
| 55 ModulePass *llvm::createStripTlsPass() { |
| 56 return new StripTls(); |
| 57 } |
OLD | NEW |