1 //===-- GlobalMerge.cpp - Internal globals merging -----------------------===// 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 // This pass merges globals with internal linkage into one. This way all the 10 // globals which were merged into a biggest one can be addressed using offsets 11 // from the same base pointer (no need for separate base pointer for each of the 12 // global). Such a transformation can significantly reduce the register pressure 13 // when many globals are involved. 14 // 15 // For example, consider the code which touches several global variables at 16 // once: 17 // 18 // static int foo[N], bar[N], baz[N]; 19 // 20 // for (i = 0; i < N; ++i) { 21 // foo[i] = bar[i] * baz[i]; 22 // } 23 // 24 // On ARM the addresses of 3 arrays should be kept in the registers, thus 25 // this code has quite large register pressure (loop body): 26 // 27 // ldr r1, [r5], #4 28 // ldr r2, [r6], #4 29 // mul r1, r2, r1 30 // str r1, [r0], #4 31 // 32 // Pass converts the code to something like: 33 // 34 // static struct { 35 // int foo[N]; 36 // int bar[N]; 37 // int baz[N]; 38 // } merged; 39 // 40 // for (i = 0; i < N; ++i) { 41 // merged.foo[i] = merged.bar[i] * merged.baz[i]; 42 // } 43 // 44 // and in ARM code this becomes: 45 // 46 // ldr r0, [r5, #40] 47 // ldr r1, [r5, #80] 48 // mul r0, r1, r0 49 // str r0, [r5], #4 50 // 51 // note that we saved 2 registers here almostly "for free". 52 // 53 // However, merging globals can have tradeoffs: 54 // - it confuses debuggers, tools, and users 55 // - it makes linker optimizations less useful (order files, LOHs, ...) 56 // - it forces usage of indexed addressing (which isn't necessarily "free") 57 // - it can increase register pressure when the uses are disparate enough. 58 // 59 // We use heuristics to discover the best global grouping we can (cf cl::opts). 60 // ===---------------------------------------------------------------------===// 61 62 #include "llvm/Transforms/Scalar.h" 63 #include "llvm/ADT/DenseMap.h" 64 #include "llvm/ADT/SmallBitVector.h" 65 #include "llvm/ADT/SmallPtrSet.h" 66 #include "llvm/ADT/Statistic.h" 67 #include "llvm/CodeGen/Passes.h" 68 #include "llvm/IR/Attributes.h" 69 #include "llvm/IR/Constants.h" 70 #include "llvm/IR/DataLayout.h" 71 #include "llvm/IR/DerivedTypes.h" 72 #include "llvm/IR/Function.h" 73 #include "llvm/IR/GlobalVariable.h" 74 #include "llvm/IR/Instructions.h" 75 #include "llvm/IR/Intrinsics.h" 76 #include "llvm/IR/Module.h" 77 #include "llvm/Pass.h" 78 #include "llvm/Support/CommandLine.h" 79 #include "llvm/Support/Debug.h" 80 #include "llvm/Support/raw_ostream.h" 81 #include "llvm/Target/TargetLowering.h" 82 #include "llvm/Target/TargetLoweringObjectFile.h" 83 #include "llvm/Target/TargetSubtargetInfo.h" 84 #include <algorithm> 85 using namespace llvm; 86 87 #define DEBUG_TYPE "global-merge" 88 89 // FIXME: This is only useful as a last-resort way to disable the pass. 90 static cl::opt<bool> 91 EnableGlobalMerge("enable-global-merge", cl::Hidden, 92 cl::desc("Enable the global merge pass"), 93 cl::init(true)); 94 95 static cl::opt<bool> GlobalMergeGroupByUse( 96 "global-merge-group-by-use", cl::Hidden, 97 cl::desc("Improve global merge pass to look at uses"), cl::init(true)); 98 99 static cl::opt<bool> GlobalMergeIgnoreSingleUse( 100 "global-merge-ignore-single-use", cl::Hidden, 101 cl::desc("Improve global merge pass to ignore globals only used alone"), 102 cl::init(true)); 103 104 static cl::opt<bool> 105 EnableGlobalMergeOnConst("global-merge-on-const", cl::Hidden, 106 cl::desc("Enable global merge pass on constants"), 107 cl::init(false)); 108 109 // FIXME: this could be a transitional option, and we probably need to remove 110 // it if only we are sure this optimization could always benefit all targets. 111 static cl::opt<bool> 112 EnableGlobalMergeOnExternal("global-merge-on-external", cl::Hidden, 113 cl::desc("Enable global merge pass on external linkage"), 114 cl::init(false)); 115 116 STATISTIC(NumMerged, "Number of globals merged"); 117 namespace { 118 class GlobalMerge : public FunctionPass { 119 const TargetMachine *TM; 120 // FIXME: Infer the maximum possible offset depending on the actual users 121 // (these max offsets are different for the users inside Thumb or ARM 122 // functions), see the code that passes in the offset in the ARM backend 123 // for more information. 124 unsigned MaxOffset; 125 126 /// Whether we should try to optimize for size only. 127 /// Currently, this applies a dead simple heuristic: only consider globals 128 /// used in minsize functions for merging. 129 /// FIXME: This could learn about optsize, and be used in the cost model. 130 bool OnlyOptimizeForSize; 131 132 bool doMerge(SmallVectorImpl<GlobalVariable*> &Globals, 133 Module &M, bool isConst, unsigned AddrSpace) const; 134 /// \brief Merge everything in \p Globals for which the corresponding bit 135 /// in \p GlobalSet is set. 136 bool doMerge(SmallVectorImpl<GlobalVariable *> &Globals, 137 const BitVector &GlobalSet, Module &M, bool isConst, 138 unsigned AddrSpace) const; 139 140 /// \brief Check if the given variable has been identified as must keep 141 /// \pre setMustKeepGlobalVariables must have been called on the Module that 142 /// contains GV 143 bool isMustKeepGlobalVariable(const GlobalVariable *GV) const { 144 return MustKeepGlobalVariables.count(GV); 145 } 146 147 /// Collect every variables marked as "used" or used in a landing pad 148 /// instruction for this Module. 149 void setMustKeepGlobalVariables(Module &M); 150 151 /// Collect every variables marked as "used" 152 void collectUsedGlobalVariables(Module &M); 153 154 /// Keep track of the GlobalVariable that must not be merged away 155 SmallPtrSet<const GlobalVariable *, 16> MustKeepGlobalVariables; 156 157 public: 158 static char ID; // Pass identification, replacement for typeid. 159 explicit GlobalMerge(const TargetMachine *TM = nullptr, 160 unsigned MaximalOffset = 0, 161 bool OnlyOptimizeForSize = false) 162 : FunctionPass(ID), TM(TM), MaxOffset(MaximalOffset), 163 OnlyOptimizeForSize(OnlyOptimizeForSize) { 164 initializeGlobalMergePass(*PassRegistry::getPassRegistry()); 165 } 166 167 bool doInitialization(Module &M) override; 168 bool runOnFunction(Function &F) override; 169 bool doFinalization(Module &M) override; 170 171 const char *getPassName() const override { 172 return "Merge internal globals"; 173 } 174 175 void getAnalysisUsage(AnalysisUsage &AU) const override { 176 AU.setPreservesCFG(); 177 FunctionPass::getAnalysisUsage(AU); 178 } 179 }; 180 } // end anonymous namespace 181 182 char GlobalMerge::ID = 0; 183 INITIALIZE_PASS_BEGIN(GlobalMerge, "global-merge", "Merge global variables", 184 false, false) 185 INITIALIZE_PASS_END(GlobalMerge, "global-merge", "Merge global variables", 186 false, false) 187 188 bool GlobalMerge::doMerge(SmallVectorImpl<GlobalVariable*> &Globals, 189 Module &M, bool isConst, unsigned AddrSpace) const { 190 auto &DL = M.getDataLayout(); 191 // FIXME: Find better heuristics 192 std::stable_sort( 193 Globals.begin(), Globals.end(), 194 [&DL](const GlobalVariable *GV1, const GlobalVariable *GV2) { 195 Type *Ty1 = cast<PointerType>(GV1->getType())->getElementType(); 196 Type *Ty2 = cast<PointerType>(GV2->getType())->getElementType(); 197 198 return (DL.getTypeAllocSize(Ty1) < DL.getTypeAllocSize(Ty2)); 199 }); 200 201 // If we want to just blindly group all globals together, do so. 202 if (!GlobalMergeGroupByUse) { 203 BitVector AllGlobals(Globals.size()); 204 AllGlobals.set(); 205 return doMerge(Globals, AllGlobals, M, isConst, AddrSpace); 206 } 207 208 // If we want to be smarter, look at all uses of each global, to try to 209 // discover all sets of globals used together, and how many times each of 210 // these sets occured. 211 // 212 // Keep this reasonably efficient, by having an append-only list of all sets 213 // discovered so far (UsedGlobalSet), and mapping each "together-ness" unit of 214 // code (currently, a Function) to the set of globals seen so far that are 215 // used together in that unit (GlobalUsesByFunction). 216 // 217 // When we look at the Nth global, we now that any new set is either: 218 // - the singleton set {N}, containing this global only, or 219 // - the union of {N} and a previously-discovered set, containing some 220 // combination of the previous N-1 globals. 221 // Using that knowledge, when looking at the Nth global, we can keep: 222 // - a reference to the singleton set {N} (CurGVOnlySetIdx) 223 // - a list mapping each previous set to its union with {N} (EncounteredUGS), 224 // if it actually occurs. 225 226 // We keep track of the sets of globals used together "close enough". 227 struct UsedGlobalSet { 228 UsedGlobalSet(size_t Size) : Globals(Size), UsageCount(1) {} 229 BitVector Globals; 230 unsigned UsageCount; 231 }; 232 233 // Each set is unique in UsedGlobalSets. 234 std::vector<UsedGlobalSet> UsedGlobalSets; 235 236 // Avoid repeating the create-global-set pattern. 237 auto CreateGlobalSet = [&]() -> UsedGlobalSet & { 238 UsedGlobalSets.emplace_back(Globals.size()); 239 return UsedGlobalSets.back(); 240 }; 241 242 // The first set is the empty set. 243 CreateGlobalSet().UsageCount = 0; 244 245 // We define "close enough" to be "in the same function". 246 // FIXME: Grouping uses by function is way too aggressive, so we should have 247 // a better metric for distance between uses. 248 // The obvious alternative would be to group by BasicBlock, but that's in 249 // turn too conservative.. 250 // Anything in between wouldn't be trivial to compute, so just stick with 251 // per-function grouping. 252 253 // The value type is an index into UsedGlobalSets. 254 // The default (0) conveniently points to the empty set. 255 DenseMap<Function *, size_t /*UsedGlobalSetIdx*/> GlobalUsesByFunction; 256 257 // Now, look at each merge-eligible global in turn. 258 259 // Keep track of the sets we already encountered to which we added the 260 // current global. 261 // Each element matches the same-index element in UsedGlobalSets. 262 // This lets us efficiently tell whether a set has already been expanded to 263 // include the current global. 264 std::vector<size_t> EncounteredUGS; 265 266 for (size_t GI = 0, GE = Globals.size(); GI != GE; ++GI) { 267 GlobalVariable *GV = Globals[GI]; 268 269 // Reset the encountered sets for this global... 270 std::fill(EncounteredUGS.begin(), EncounteredUGS.end(), 0); 271 // ...and grow it in case we created new sets for the previous global. 272 EncounteredUGS.resize(UsedGlobalSets.size()); 273 274 // We might need to create a set that only consists of the current global. 275 // Keep track of its index into UsedGlobalSets. 276 size_t CurGVOnlySetIdx = 0; 277 278 // For each global, look at all its Uses. 279 for (auto &U : GV->uses()) { 280 // This Use might be a ConstantExpr. We're interested in Instruction 281 // users, so look through ConstantExpr... 282 Use *UI, *UE; 283 if (ConstantExpr *CE = dyn_cast<ConstantExpr>(U.getUser())) { 284 if (CE->use_empty()) 285 continue; 286 UI = &*CE->use_begin(); 287 UE = nullptr; 288 } else if (isa<Instruction>(U.getUser())) { 289 UI = &U; 290 UE = UI->getNext(); 291 } else { 292 continue; 293 } 294 295 // ...to iterate on all the instruction users of the global. 296 // Note that we iterate on Uses and not on Users to be able to getNext(). 297 for (; UI != UE; UI = UI->getNext()) { 298 Instruction *I = dyn_cast<Instruction>(UI->getUser()); 299 if (!I) 300 continue; 301 302 Function *ParentFn = I->getParent()->getParent(); 303 304 // If we're only optimizing for size, ignore non-minsize functions. 305 if (OnlyOptimizeForSize && 306 !ParentFn->hasFnAttribute(Attribute::MinSize)) 307 continue; 308 309 size_t UGSIdx = GlobalUsesByFunction[ParentFn]; 310 311 // If this is the first global the basic block uses, map it to the set 312 // consisting of this global only. 313 if (!UGSIdx) { 314 // If that set doesn't exist yet, create it. 315 if (!CurGVOnlySetIdx) { 316 CurGVOnlySetIdx = UsedGlobalSets.size(); 317 CreateGlobalSet().Globals.set(GI); 318 } else { 319 ++UsedGlobalSets[CurGVOnlySetIdx].UsageCount; 320 } 321 322 GlobalUsesByFunction[ParentFn] = CurGVOnlySetIdx; 323 continue; 324 } 325 326 // If we already encountered this BB, just increment the counter. 327 if (UsedGlobalSets[UGSIdx].Globals.test(GI)) { 328 ++UsedGlobalSets[UGSIdx].UsageCount; 329 continue; 330 } 331 332 // If not, the previous set wasn't actually used in this function. 333 --UsedGlobalSets[UGSIdx].UsageCount; 334 335 // If we already expanded the previous set to include this global, just 336 // reuse that expanded set. 337 if (size_t ExpandedIdx = EncounteredUGS[UGSIdx]) { 338 ++UsedGlobalSets[ExpandedIdx].UsageCount; 339 GlobalUsesByFunction[ParentFn] = ExpandedIdx; 340 continue; 341 } 342 343 // If not, create a new set consisting of the union of the previous set 344 // and this global. Mark it as encountered, so we can reuse it later. 345 GlobalUsesByFunction[ParentFn] = EncounteredUGS[UGSIdx] = 346 UsedGlobalSets.size(); 347 348 UsedGlobalSet &NewUGS = CreateGlobalSet(); 349 NewUGS.Globals.set(GI); 350 NewUGS.Globals |= UsedGlobalSets[UGSIdx].Globals; 351 } 352 } 353 } 354 355 // Now we found a bunch of sets of globals used together. We accumulated 356 // the number of times we encountered the sets (i.e., the number of blocks 357 // that use that exact set of globals). 358 // 359 // Multiply that by the size of the set to give us a crude profitability 360 // metric. 361 std::sort(UsedGlobalSets.begin(), UsedGlobalSets.end(), 362 [](const UsedGlobalSet &UGS1, const UsedGlobalSet &UGS2) { 363 return UGS1.Globals.count() * UGS1.UsageCount < 364 UGS2.Globals.count() * UGS2.UsageCount; 365 }); 366 367 // We can choose to merge all globals together, but ignore globals never used 368 // with another global. This catches the obviously non-profitable cases of 369 // having a single global, but is aggressive enough for any other case. 370 if (GlobalMergeIgnoreSingleUse) { 371 BitVector AllGlobals(Globals.size()); 372 for (size_t i = 0, e = UsedGlobalSets.size(); i != e; ++i) { 373 const UsedGlobalSet &UGS = UsedGlobalSets[e - i - 1]; 374 if (UGS.UsageCount == 0) 375 continue; 376 if (UGS.Globals.count() > 1) 377 AllGlobals |= UGS.Globals; 378 } 379 return doMerge(Globals, AllGlobals, M, isConst, AddrSpace); 380 } 381 382 // Starting from the sets with the best (=biggest) profitability, find a 383 // good combination. 384 // The ideal (and expensive) solution can only be found by trying all 385 // combinations, looking for the one with the best profitability. 386 // Don't be smart about it, and just pick the first compatible combination, 387 // starting with the sets with the best profitability. 388 BitVector PickedGlobals(Globals.size()); 389 bool Changed = false; 390 391 for (size_t i = 0, e = UsedGlobalSets.size(); i != e; ++i) { 392 const UsedGlobalSet &UGS = UsedGlobalSets[e - i - 1]; 393 if (UGS.UsageCount == 0) 394 continue; 395 if (PickedGlobals.anyCommon(UGS.Globals)) 396 continue; 397 PickedGlobals |= UGS.Globals; 398 // If the set only contains one global, there's no point in merging. 399 // Ignore the global for inclusion in other sets though, so keep it in 400 // PickedGlobals. 401 if (UGS.Globals.count() < 2) 402 continue; 403 Changed |= doMerge(Globals, UGS.Globals, M, isConst, AddrSpace); 404 } 405 406 return Changed; 407 } 408 409 bool GlobalMerge::doMerge(SmallVectorImpl<GlobalVariable *> &Globals, 410 const BitVector &GlobalSet, Module &M, bool isConst, 411 unsigned AddrSpace) const { 412 413 Type *Int32Ty = Type::getInt32Ty(M.getContext()); 414 auto &DL = M.getDataLayout(); 415 416 assert(Globals.size() > 1); 417 418 DEBUG(dbgs() << " Trying to merge set, starts with #" 419 << GlobalSet.find_first() << "\n"); 420 421 ssize_t i = GlobalSet.find_first(); 422 while (i != -1) { 423 ssize_t j = 0; 424 uint64_t MergedSize = 0; 425 std::vector<Type*> Tys; 426 std::vector<Constant*> Inits; 427 428 bool HasExternal = false; 429 GlobalVariable *TheFirstExternal = 0; 430 for (j = i; j != -1; j = GlobalSet.find_next(j)) { 431 Type *Ty = Globals[j]->getType()->getElementType(); 432 MergedSize += DL.getTypeAllocSize(Ty); 433 if (MergedSize > MaxOffset) { 434 break; 435 } 436 Tys.push_back(Ty); 437 Inits.push_back(Globals[j]->getInitializer()); 438 439 if (Globals[j]->hasExternalLinkage() && !HasExternal) { 440 HasExternal = true; 441 TheFirstExternal = Globals[j]; 442 } 443 } 444 445 // If merged variables doesn't have external linkage, we needn't to expose 446 // the symbol after merging. 447 GlobalValue::LinkageTypes Linkage = HasExternal 448 ? GlobalValue::ExternalLinkage 449 : GlobalValue::InternalLinkage; 450 451 StructType *MergedTy = StructType::get(M.getContext(), Tys); 452 Constant *MergedInit = ConstantStruct::get(MergedTy, Inits); 453 454 // If merged variables have external linkage, we use symbol name of the 455 // first variable merged as the suffix of global symbol name. This would 456 // be able to avoid the link-time naming conflict for globalm symbols. 457 GlobalVariable *MergedGV = new GlobalVariable( 458 M, MergedTy, isConst, Linkage, MergedInit, 459 HasExternal ? "_MergedGlobals_" + TheFirstExternal->getName() 460 : "_MergedGlobals", 461 nullptr, GlobalVariable::NotThreadLocal, AddrSpace); 462 463 for (ssize_t k = i, idx = 0; k != j; k = GlobalSet.find_next(k)) { 464 GlobalValue::LinkageTypes Linkage = Globals[k]->getLinkage(); 465 std::string Name = Globals[k]->getName(); 466 467 Constant *Idx[2] = { 468 ConstantInt::get(Int32Ty, 0), 469 ConstantInt::get(Int32Ty, idx++) 470 }; 471 Constant *GEP = 472 ConstantExpr::getInBoundsGetElementPtr(MergedTy, MergedGV, Idx); 473 Globals[k]->replaceAllUsesWith(GEP); 474 Globals[k]->eraseFromParent(); 475 476 if (Linkage != GlobalValue::InternalLinkage) { 477 // Generate a new alias... 478 auto *PTy = cast<PointerType>(GEP->getType()); 479 GlobalAlias::create(PTy, Linkage, Name, GEP, &M); 480 } 481 482 NumMerged++; 483 } 484 i = j; 485 } 486 487 return true; 488 } 489 490 void GlobalMerge::collectUsedGlobalVariables(Module &M) { 491 // Extract global variables from llvm.used array 492 const GlobalVariable *GV = M.getGlobalVariable("llvm.used"); 493 if (!GV || !GV->hasInitializer()) return; 494 495 // Should be an array of 'i8*'. 496 const ConstantArray *InitList = cast<ConstantArray>(GV->getInitializer()); 497 498 for (unsigned i = 0, e = InitList->getNumOperands(); i != e; ++i) 499 if (const GlobalVariable *G = 500 dyn_cast<GlobalVariable>(InitList->getOperand(i)->stripPointerCasts())) 501 MustKeepGlobalVariables.insert(G); 502 } 503 504 void GlobalMerge::setMustKeepGlobalVariables(Module &M) { 505 collectUsedGlobalVariables(M); 506 507 for (Module::iterator IFn = M.begin(), IEndFn = M.end(); IFn != IEndFn; 508 ++IFn) { 509 for (Function::iterator IBB = IFn->begin(), IEndBB = IFn->end(); 510 IBB != IEndBB; ++IBB) { 511 // Follow the invoke link to find the landing pad instruction 512 const InvokeInst *II = dyn_cast<InvokeInst>(IBB->getTerminator()); 513 if (!II) continue; 514 515 const LandingPadInst *LPInst = II->getUnwindDest()->getLandingPadInst(); 516 // Look for globals in the clauses of the landing pad instruction 517 for (unsigned Idx = 0, NumClauses = LPInst->getNumClauses(); 518 Idx != NumClauses; ++Idx) 519 if (const GlobalVariable *GV = 520 dyn_cast<GlobalVariable>(LPInst->getClause(Idx) 521 ->stripPointerCasts())) 522 MustKeepGlobalVariables.insert(GV); 523 } 524 } 525 } 526 527 bool GlobalMerge::doInitialization(Module &M) { 528 if (!EnableGlobalMerge) 529 return false; 530 531 auto &DL = M.getDataLayout(); 532 DenseMap<unsigned, SmallVector<GlobalVariable*, 16> > Globals, ConstGlobals, 533 BSSGlobals; 534 bool Changed = false; 535 setMustKeepGlobalVariables(M); 536 537 // Grab all non-const globals. 538 for (Module::global_iterator I = M.global_begin(), 539 E = M.global_end(); I != E; ++I) { 540 // Merge is safe for "normal" internal or external globals only 541 if (I->isDeclaration() || I->isThreadLocal() || I->hasSection()) 542 continue; 543 544 if (!(EnableGlobalMergeOnExternal && I->hasExternalLinkage()) && 545 !I->hasInternalLinkage()) 546 continue; 547 548 PointerType *PT = dyn_cast<PointerType>(I->getType()); 549 assert(PT && "Global variable is not a pointer!"); 550 551 unsigned AddressSpace = PT->getAddressSpace(); 552 553 // Ignore fancy-aligned globals for now. 554 unsigned Alignment = DL.getPreferredAlignment(I); 555 Type *Ty = I->getType()->getElementType(); 556 if (Alignment > DL.getABITypeAlignment(Ty)) 557 continue; 558 559 // Ignore all 'special' globals. 560 if (I->getName().startswith("llvm.") || 561 I->getName().startswith(".llvm.")) 562 continue; 563 564 // Ignore all "required" globals: 565 if (isMustKeepGlobalVariable(I)) 566 continue; 567 568 if (DL.getTypeAllocSize(Ty) < MaxOffset) { 569 if (TargetLoweringObjectFile::getKindForGlobal(I, *TM).isBSSLocal()) 570 BSSGlobals[AddressSpace].push_back(I); 571 else if (I->isConstant()) 572 ConstGlobals[AddressSpace].push_back(I); 573 else 574 Globals[AddressSpace].push_back(I); 575 } 576 } 577 578 for (DenseMap<unsigned, SmallVector<GlobalVariable*, 16> >::iterator 579 I = Globals.begin(), E = Globals.end(); I != E; ++I) 580 if (I->second.size() > 1) 581 Changed |= doMerge(I->second, M, false, I->first); 582 583 for (DenseMap<unsigned, SmallVector<GlobalVariable*, 16> >::iterator 584 I = BSSGlobals.begin(), E = BSSGlobals.end(); I != E; ++I) 585 if (I->second.size() > 1) 586 Changed |= doMerge(I->second, M, false, I->first); 587 588 if (EnableGlobalMergeOnConst) 589 for (DenseMap<unsigned, SmallVector<GlobalVariable*, 16> >::iterator 590 I = ConstGlobals.begin(), E = ConstGlobals.end(); I != E; ++I) 591 if (I->second.size() > 1) 592 Changed |= doMerge(I->second, M, true, I->first); 593 594 return Changed; 595 } 596 597 bool GlobalMerge::runOnFunction(Function &F) { 598 return false; 599 } 600 601 bool GlobalMerge::doFinalization(Module &M) { 602 MustKeepGlobalVariables.clear(); 603 return false; 604 } 605 606 Pass *llvm::createGlobalMergePass(const TargetMachine *TM, unsigned Offset, 607 bool OnlyOptimizeForSize) { 608 return new GlobalMerge(TM, Offset, OnlyOptimizeForSize); 609 } 610