77
88#include " llvm-version.h"
99#include " support/dtypes.h"
10+ #include " passes.h"
1011
1112#include < llvm-c/Core.h>
1213#include < llvm-c/Types.h>
@@ -34,13 +35,12 @@ typedef Instruction TerminatorInst;
3435
3536namespace {
3637
37- struct LowerPTLS : public ModulePass {
38- static char ID;
38+ struct LowerPTLS {
3939 LowerPTLS (bool imaging_mode=false )
40- : ModulePass(ID),
41- imaging_mode (imaging_mode)
40+ : imaging_mode(imaging_mode)
4241 {}
4342
43+ bool runOnModule (Module &M);
4444private:
4545 const bool imaging_mode;
4646 Module *M;
@@ -62,7 +62,6 @@ struct LowerPTLS: public ModulePass {
6262 template <typename T> T *add_comdat (T *G) const ;
6363 GlobalVariable *create_aliased_global (Type *T, StringRef name) const ;
6464 void fix_pgcstack_use (CallInst *pgcstack);
65- bool runOnModule (Module &M) override ;
6665};
6766
6867void LowerPTLS::set_pgcstack_attrs (CallInst *pgcstack) const
@@ -291,17 +290,37 @@ bool LowerPTLS::runOnModule(Module &_M)
291290 return true ;
292291}
293292
294- char LowerPTLS::ID = 0 ;
293+ struct LowerPTLSLegacy : public ModulePass {
294+ static char ID;
295+ LowerPTLSLegacy (bool imaging_mode=false )
296+ : ModulePass(ID),
297+ imaging_mode (imaging_mode)
298+ {}
295299
296- static RegisterPass<LowerPTLS> X (" LowerPTLS" , " LowerPTLS Pass" ,
300+ bool imaging_mode;
301+ bool runOnModule (Module &M) override {
302+ LowerPTLS lower (imaging_mode);
303+ return lower.runOnModule (M);
304+ }
305+ };
306+
307+ char LowerPTLSLegacy::ID = 0 ;
308+
309+ static RegisterPass<LowerPTLSLegacy> X (" LowerPTLS" , " LowerPTLS Pass" ,
297310 false /* Only looks at CFG */ ,
298311 false /* Analysis Pass */ );
299312
300313} // anonymous namespace
301314
315+ PreservedAnalyses LowerPTLSPass::run (Module &M, ModuleAnalysisManager &AM) {
316+ LowerPTLS lower (imaging_mode);
317+ lower.runOnModule (M);
318+ return PreservedAnalyses::all ();
319+ }
320+
302321Pass *createLowerPTLSPass (bool imaging_mode)
303322{
304- return new LowerPTLS (imaging_mode);
323+ return new LowerPTLSLegacy (imaging_mode);
305324}
306325
307326extern " C" JL_DLLEXPORT void LLVMExtraAddLowerPTLSPass_impl (LLVMPassManagerRef PM, LLVMBool imaging_mode)
0 commit comments