X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=lib%2FTransforms%2FIPO%2FConstantMerge.cpp;h=7c71065674ec798a538f6f75de871a0d91cff503;hb=4ee451de366474b9c228b4e5fa573795a715216d;hp=0f949a4743ed507c853efd8ba2f3a5c02f4fbf9d;hpb=98a72203d75c7f2c94169155626f51f10eaca530;p=oota-llvm.git diff --git a/lib/Transforms/IPO/ConstantMerge.cpp b/lib/Transforms/IPO/ConstantMerge.cpp index 0f949a4743e..7c71065674e 100644 --- a/lib/Transforms/IPO/ConstantMerge.cpp +++ b/lib/Transforms/IPO/ConstantMerge.cpp @@ -2,8 +2,8 @@ // // The LLVM Compiler Infrastructure // -// This file was developed by the LLVM research group and is distributed under -// the University of Illinois Open Source License. See LICENSE.TXT for details. +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // @@ -29,12 +29,16 @@ STATISTIC(NumMerged, "Number of global constants merged"); namespace { struct VISIBILITY_HIDDEN ConstantMerge : public ModulePass { + static char ID; // Pass identification, replacement for typeid + ConstantMerge() : ModulePass((intptr_t)&ID) {} + // run - For this pass, process all of the globals in the module, // eliminating duplicate constants. // bool runOnModule(Module &M); }; + char ConstantMerge::ID = 0; RegisterPassX("constmerge","Merge Duplicate Global Constants"); } @@ -60,8 +64,10 @@ bool ConstantMerge::runOnModule(Module &M) { // because doing so may cause initializers of other globals to be rewritten, // invalidating the Constant* pointers in CMap. // - for (Module::global_iterator GV = M.global_begin(), E = M.global_end(); - GV != E; ++GV) { + for (Module::global_iterator GVI = M.global_begin(), E = M.global_end(); + GVI != E; ) { + GlobalVariable *GV = GVI++; + // If this GV is dead, remove it. GV->removeDeadConstantUsers(); if (GV->use_empty() && GV->hasInternalLinkage()) {