| 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)
|
|
|