diff options
Diffstat (limited to 'llvm/lib/Transforms/IPO/ExtractGV.cpp')
| -rw-r--r-- | llvm/lib/Transforms/IPO/ExtractGV.cpp | 13 | 
1 files changed, 8 insertions, 5 deletions
| diff --git a/llvm/lib/Transforms/IPO/ExtractGV.cpp b/llvm/lib/Transforms/IPO/ExtractGV.cpp index f77b528fc42d..b45766a8e783 100644 --- a/llvm/lib/Transforms/IPO/ExtractGV.cpp +++ b/llvm/lib/Transforms/IPO/ExtractGV.cpp @@ -54,6 +54,7 @@ namespace {    class GVExtractorPass : public ModulePass {      SetVector<GlobalValue *> Named;      bool deleteStuff; +    bool keepConstInit;    public:      static char ID; // Pass identification, replacement for typeid @@ -61,8 +62,9 @@ namespace {      /// Otherwise, it deletes as much of the module as possible, except for the      /// global values specified.      explicit GVExtractorPass(std::vector<GlobalValue*> &GVs, -                             bool deleteS = true) -      : ModulePass(ID), Named(GVs.begin(), GVs.end()), deleteStuff(deleteS) {} +                             bool deleteS = true, bool keepConstInit = false) +      : ModulePass(ID), Named(GVs.begin(), GVs.end()), deleteStuff(deleteS), +        keepConstInit(keepConstInit) {}      bool runOnModule(Module &M) override {        if (skipModule(M)) @@ -83,7 +85,8 @@ namespace {        for (Module::global_iterator I = M.global_begin(), E = M.global_end();             I != E; ++I) {          bool Delete = -            deleteStuff == (bool)Named.count(&*I) && !I->isDeclaration(); +            deleteStuff == (bool)Named.count(&*I) && !I->isDeclaration() && +            (!I->isConstant() || !keepConstInit);          if (!Delete) {            if (I->hasAvailableExternallyLinkage())              continue; @@ -156,6 +159,6 @@ namespace {  }  ModulePass *llvm::createGVExtractionPass(std::vector<GlobalValue *> &GVs, -                                         bool deleteFn) { -  return new GVExtractorPass(GVs, deleteFn); +                                         bool deleteFn, bool keepConstInit) { +  return new GVExtractorPass(GVs, deleteFn, keepConstInit);  } | 
