1 //===- MergedLoadStoreMotion.cpp - merge and hoist/sink load/stores -------===// 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 // 10 //! \file 11 //! \brief This pass performs merges of loads and stores on both sides of a 12 // diamond (hammock). It hoists the loads and sinks the stores. 13 // 14 // The algorithm iteratively hoists two loads to the same address out of a 15 // diamond (hammock) and merges them into a single load in the header. Similar 16 // it sinks and merges two stores to the tail block (footer). The algorithm 17 // iterates over the instructions of one side of the diamond and attempts to 18 // find a matching load/store on the other side. It hoists / sinks when it 19 // thinks it safe to do so. This optimization helps with eg. hiding load 20 // latencies, triggering if-conversion, and reducing static code size. 21 // 22 //===----------------------------------------------------------------------===// 23 // 24 // 25 // Example: 26 // Diamond shaped code before merge: 27 // 28 // header: 29 // br %cond, label %if.then, label %if.else 30 // + + 31 // + + 32 // + + 33 // if.then: if.else: 34 // %lt = load %addr_l %le = load %addr_l 35 // <use %lt> <use %le> 36 // <...> <...> 37 // store %st, %addr_s store %se, %addr_s 38 // br label %if.end br label %if.end 39 // + + 40 // + + 41 // + + 42 // if.end ("footer"): 43 // <...> 44 // 45 // Diamond shaped code after merge: 46 // 47 // header: 48 // %l = load %addr_l 49 // br %cond, label %if.then, label %if.else 50 // + + 51 // + + 52 // + + 53 // if.then: if.else: 54 // <use %l> <use %l> 55 // <...> <...> 56 // br label %if.end br label %if.end 57 // + + 58 // + + 59 // + + 60 // if.end ("footer"): 61 // %s.sink = phi [%st, if.then], [%se, if.else] 62 // <...> 63 // store %s.sink, %addr_s 64 // <...> 65 // 66 // 67 //===----------------------- TODO -----------------------------------------===// 68 // 69 // 1) Generalize to regions other than diamonds 70 // 2) Be more aggressive merging memory operations 71 // Note that both changes require register pressure control 72 // 73 //===----------------------------------------------------------------------===// 74 75 #include "llvm/Transforms/Scalar/MergedLoadStoreMotion.h" 76 #include "llvm/ADT/Statistic.h" 77 #include "llvm/Analysis/AliasAnalysis.h" 78 #include "llvm/Analysis/CFG.h" 79 #include "llvm/Analysis/GlobalsModRef.h" 80 #include "llvm/Analysis/Loads.h" 81 #include "llvm/Analysis/MemoryBuiltins.h" 82 #include "llvm/Analysis/MemoryDependenceAnalysis.h" 83 #include "llvm/Analysis/ValueTracking.h" 84 #include "llvm/IR/Metadata.h" 85 #include "llvm/IR/PatternMatch.h" 86 #include "llvm/Support/Debug.h" 87 #include "llvm/Support/raw_ostream.h" 88 #include "llvm/Transforms/Scalar.h" 89 #include "llvm/Transforms/Utils/BasicBlockUtils.h" 90 #include "llvm/Transforms/Utils/SSAUpdater.h" 91 92 using namespace llvm; 93 94 #define DEBUG_TYPE "mldst-motion" 95 96 //===----------------------------------------------------------------------===// 97 // MergedLoadStoreMotion Pass 98 //===----------------------------------------------------------------------===// 99 class MergedLoadStoreMotion { 100 MemoryDependenceResults *MD = nullptr; 101 AliasAnalysis *AA = nullptr; 102 103 // The mergeLoad/Store algorithms could have Size0 * Size1 complexity, 104 // where Size0 and Size1 are the #instructions on the two sides of 105 // the diamond. The constant chosen here is arbitrary. Compiler Time 106 // Control is enforced by the check Size0 * Size1 < MagicCompileTimeControl. 107 const int MagicCompileTimeControl = 250; 108 109 public: 110 bool run(Function &F, MemoryDependenceResults *MD, AliasAnalysis &AA); 111 112 private: 113 /// 114 /// \brief Remove instruction from parent and update memory dependence 115 /// analysis. 116 /// 117 void removeInstruction(Instruction *Inst); 118 BasicBlock *getDiamondTail(BasicBlock *BB); 119 bool isDiamondHead(BasicBlock *BB); 120 // Routines for hoisting loads 121 bool isLoadHoistBarrierInRange(const Instruction &Start, 122 const Instruction &End, LoadInst *LI, 123 bool SafeToLoadUnconditionally); 124 LoadInst *canHoistFromBlock(BasicBlock *BB, LoadInst *LI); 125 void hoistInstruction(BasicBlock *BB, Instruction *HoistCand, 126 Instruction *ElseInst); 127 bool isSafeToHoist(Instruction *I) const; 128 bool hoistLoad(BasicBlock *BB, LoadInst *HoistCand, LoadInst *ElseInst); 129 bool mergeLoads(BasicBlock *BB); 130 // Routines for sinking stores 131 StoreInst *canSinkFromBlock(BasicBlock *BB, StoreInst *SI); 132 PHINode *getPHIOperand(BasicBlock *BB, StoreInst *S0, StoreInst *S1); 133 bool isStoreSinkBarrierInRange(const Instruction &Start, 134 const Instruction &End, MemoryLocation Loc); 135 bool sinkStore(BasicBlock *BB, StoreInst *SinkCand, StoreInst *ElseInst); 136 bool mergeStores(BasicBlock *BB); 137 }; 138 139 /// 140 /// \brief Remove instruction from parent and update memory dependence analysis. 141 /// 142 void MergedLoadStoreMotion::removeInstruction(Instruction *Inst) { 143 // Notify the memory dependence analysis. 144 if (MD) { 145 MD->removeInstruction(Inst); 146 if (auto *LI = dyn_cast<LoadInst>(Inst)) 147 MD->invalidateCachedPointerInfo(LI->getPointerOperand()); 148 if (Inst->getType()->isPtrOrPtrVectorTy()) { 149 MD->invalidateCachedPointerInfo(Inst); 150 } 151 } 152 Inst->eraseFromParent(); 153 } 154 155 /// 156 /// \brief Return tail block of a diamond. 157 /// 158 BasicBlock *MergedLoadStoreMotion::getDiamondTail(BasicBlock *BB) { 159 assert(isDiamondHead(BB) && "Basic block is not head of a diamond"); 160 return BB->getTerminator()->getSuccessor(0)->getSingleSuccessor(); 161 } 162 163 /// 164 /// \brief True when BB is the head of a diamond (hammock) 165 /// 166 bool MergedLoadStoreMotion::isDiamondHead(BasicBlock *BB) { 167 if (!BB) 168 return false; 169 auto *BI = dyn_cast<BranchInst>(BB->getTerminator()); 170 if (!BI || !BI->isConditional()) 171 return false; 172 173 BasicBlock *Succ0 = BI->getSuccessor(0); 174 BasicBlock *Succ1 = BI->getSuccessor(1); 175 176 if (!Succ0->getSinglePredecessor()) 177 return false; 178 if (!Succ1->getSinglePredecessor()) 179 return false; 180 181 BasicBlock *Succ0Succ = Succ0->getSingleSuccessor(); 182 BasicBlock *Succ1Succ = Succ1->getSingleSuccessor(); 183 // Ignore triangles. 184 if (!Succ0Succ || !Succ1Succ || Succ0Succ != Succ1Succ) 185 return false; 186 return true; 187 } 188 189 /// 190 /// \brief True when instruction is a hoist barrier for a load 191 /// 192 /// Whenever an instruction could possibly modify the value 193 /// being loaded or protect against the load from happening 194 /// it is considered a hoist barrier. 195 /// 196 bool MergedLoadStoreMotion::isLoadHoistBarrierInRange( 197 const Instruction &Start, const Instruction &End, LoadInst *LI, 198 bool SafeToLoadUnconditionally) { 199 if (!SafeToLoadUnconditionally) 200 for (const Instruction &Inst : 201 make_range(Start.getIterator(), End.getIterator())) 202 if (!isGuaranteedToTransferExecutionToSuccessor(&Inst)) 203 return true; 204 MemoryLocation Loc = MemoryLocation::get(LI); 205 return AA->canInstructionRangeModRef(Start, End, Loc, MRI_Mod); 206 } 207 208 /// 209 /// \brief Decide if a load can be hoisted 210 /// 211 /// When there is a load in \p BB to the same address as \p LI 212 /// and it can be hoisted from \p BB, return that load. 213 /// Otherwise return Null. 214 /// 215 LoadInst *MergedLoadStoreMotion::canHoistFromBlock(BasicBlock *BB1, 216 LoadInst *Load0) { 217 BasicBlock *BB0 = Load0->getParent(); 218 BasicBlock *Head = BB0->getSinglePredecessor(); 219 bool SafeToLoadUnconditionally = isSafeToLoadUnconditionally( 220 Load0->getPointerOperand(), Load0->getAlignment(), 221 Load0->getModule()->getDataLayout(), 222 /*ScanFrom=*/Head->getTerminator()); 223 for (BasicBlock::iterator BBI = BB1->begin(), BBE = BB1->end(); BBI != BBE; 224 ++BBI) { 225 Instruction *Inst = &*BBI; 226 227 // Only merge and hoist loads when their result in used only in BB 228 auto *Load1 = dyn_cast<LoadInst>(Inst); 229 if (!Load1 || Inst->isUsedOutsideOfBlock(BB1)) 230 continue; 231 232 MemoryLocation Loc0 = MemoryLocation::get(Load0); 233 MemoryLocation Loc1 = MemoryLocation::get(Load1); 234 if (Load0->isSameOperationAs(Load1) && AA->isMustAlias(Loc0, Loc1) && 235 !isLoadHoistBarrierInRange(BB1->front(), *Load1, Load1, 236 SafeToLoadUnconditionally) && 237 !isLoadHoistBarrierInRange(BB0->front(), *Load0, Load0, 238 SafeToLoadUnconditionally)) { 239 return Load1; 240 } 241 } 242 return nullptr; 243 } 244 245 /// 246 /// \brief Merge two equivalent instructions \p HoistCand and \p ElseInst into 247 /// \p BB 248 /// 249 /// BB is the head of a diamond 250 /// 251 void MergedLoadStoreMotion::hoistInstruction(BasicBlock *BB, 252 Instruction *HoistCand, 253 Instruction *ElseInst) { 254 DEBUG(dbgs() << " Hoist Instruction into BB \n"; BB->dump(); 255 dbgs() << "Instruction Left\n"; HoistCand->dump(); dbgs() << "\n"; 256 dbgs() << "Instruction Right\n"; ElseInst->dump(); dbgs() << "\n"); 257 // Hoist the instruction. 258 assert(HoistCand->getParent() != BB); 259 260 // Intersect optional metadata. 261 HoistCand->intersectOptionalDataWith(ElseInst); 262 HoistCand->dropUnknownNonDebugMetadata(); 263 264 // Prepend point for instruction insert 265 Instruction *HoistPt = BB->getTerminator(); 266 267 // Merged instruction 268 Instruction *HoistedInst = HoistCand->clone(); 269 270 // Hoist instruction. 271 HoistedInst->insertBefore(HoistPt); 272 273 HoistCand->replaceAllUsesWith(HoistedInst); 274 removeInstruction(HoistCand); 275 // Replace the else block instruction. 276 ElseInst->replaceAllUsesWith(HoistedInst); 277 removeInstruction(ElseInst); 278 } 279 280 /// 281 /// \brief Return true if no operand of \p I is defined in I's parent block 282 /// 283 bool MergedLoadStoreMotion::isSafeToHoist(Instruction *I) const { 284 BasicBlock *Parent = I->getParent(); 285 for (Use &U : I->operands()) 286 if (auto *Instr = dyn_cast<Instruction>(&U)) 287 if (Instr->getParent() == Parent) 288 return false; 289 return true; 290 } 291 292 /// 293 /// \brief Merge two equivalent loads and GEPs and hoist into diamond head 294 /// 295 bool MergedLoadStoreMotion::hoistLoad(BasicBlock *BB, LoadInst *L0, 296 LoadInst *L1) { 297 // Only one definition? 298 auto *A0 = dyn_cast<Instruction>(L0->getPointerOperand()); 299 auto *A1 = dyn_cast<Instruction>(L1->getPointerOperand()); 300 if (A0 && A1 && A0->isIdenticalTo(A1) && isSafeToHoist(A0) && 301 A0->hasOneUse() && (A0->getParent() == L0->getParent()) && 302 A1->hasOneUse() && (A1->getParent() == L1->getParent()) && 303 isa<GetElementPtrInst>(A0)) { 304 DEBUG(dbgs() << "Hoist Instruction into BB \n"; BB->dump(); 305 dbgs() << "Instruction Left\n"; L0->dump(); dbgs() << "\n"; 306 dbgs() << "Instruction Right\n"; L1->dump(); dbgs() << "\n"); 307 hoistInstruction(BB, A0, A1); 308 hoistInstruction(BB, L0, L1); 309 return true; 310 } 311 return false; 312 } 313 314 /// 315 /// \brief Try to hoist two loads to same address into diamond header 316 /// 317 /// Starting from a diamond head block, iterate over the instructions in one 318 /// successor block and try to match a load in the second successor. 319 /// 320 bool MergedLoadStoreMotion::mergeLoads(BasicBlock *BB) { 321 bool MergedLoads = false; 322 assert(isDiamondHead(BB)); 323 BranchInst *BI = cast<BranchInst>(BB->getTerminator()); 324 BasicBlock *Succ0 = BI->getSuccessor(0); 325 BasicBlock *Succ1 = BI->getSuccessor(1); 326 // #Instructions in Succ1 for Compile Time Control 327 int Size1 = Succ1->size(); 328 int NLoads = 0; 329 for (BasicBlock::iterator BBI = Succ0->begin(), BBE = Succ0->end(); 330 BBI != BBE;) { 331 Instruction *I = &*BBI; 332 ++BBI; 333 334 // Don't move non-simple (atomic, volatile) loads. 335 auto *L0 = dyn_cast<LoadInst>(I); 336 if (!L0 || !L0->isSimple() || L0->isUsedOutsideOfBlock(Succ0)) 337 continue; 338 339 ++NLoads; 340 if (NLoads * Size1 >= MagicCompileTimeControl) 341 break; 342 if (LoadInst *L1 = canHoistFromBlock(Succ1, L0)) { 343 bool Res = hoistLoad(BB, L0, L1); 344 MergedLoads |= Res; 345 // Don't attempt to hoist above loads that had not been hoisted. 346 if (!Res) 347 break; 348 } 349 } 350 return MergedLoads; 351 } 352 353 /// 354 /// \brief True when instruction is a sink barrier for a store 355 /// located in Loc 356 /// 357 /// Whenever an instruction could possibly read or modify the 358 /// value being stored or protect against the store from 359 /// happening it is considered a sink barrier. 360 /// 361 bool MergedLoadStoreMotion::isStoreSinkBarrierInRange(const Instruction &Start, 362 const Instruction &End, 363 MemoryLocation Loc) { 364 for (const Instruction &Inst : 365 make_range(Start.getIterator(), End.getIterator())) 366 if (Inst.mayThrow()) 367 return true; 368 return AA->canInstructionRangeModRef(Start, End, Loc, MRI_ModRef); 369 } 370 371 /// 372 /// \brief Check if \p BB contains a store to the same address as \p SI 373 /// 374 /// \return The store in \p when it is safe to sink. Otherwise return Null. 375 /// 376 StoreInst *MergedLoadStoreMotion::canSinkFromBlock(BasicBlock *BB1, 377 StoreInst *Store0) { 378 DEBUG(dbgs() << "can Sink? : "; Store0->dump(); dbgs() << "\n"); 379 BasicBlock *BB0 = Store0->getParent(); 380 for (Instruction &Inst : reverse(*BB1)) { 381 auto *Store1 = dyn_cast<StoreInst>(&Inst); 382 if (!Store1) 383 continue; 384 385 MemoryLocation Loc0 = MemoryLocation::get(Store0); 386 MemoryLocation Loc1 = MemoryLocation::get(Store1); 387 if (AA->isMustAlias(Loc0, Loc1) && Store0->isSameOperationAs(Store1) && 388 !isStoreSinkBarrierInRange(*Store1->getNextNode(), BB1->back(), Loc1) && 389 !isStoreSinkBarrierInRange(*Store0->getNextNode(), BB0->back(), Loc0)) { 390 return Store1; 391 } 392 } 393 return nullptr; 394 } 395 396 /// 397 /// \brief Create a PHI node in BB for the operands of S0 and S1 398 /// 399 PHINode *MergedLoadStoreMotion::getPHIOperand(BasicBlock *BB, StoreInst *S0, 400 StoreInst *S1) { 401 // Create a phi if the values mismatch. 402 Value *Opd1 = S0->getValueOperand(); 403 Value *Opd2 = S1->getValueOperand(); 404 if (Opd1 == Opd2) 405 return nullptr; 406 407 auto *NewPN = PHINode::Create(Opd1->getType(), 2, Opd2->getName() + ".sink", 408 &BB->front()); 409 NewPN->addIncoming(Opd1, S0->getParent()); 410 NewPN->addIncoming(Opd2, S1->getParent()); 411 if (MD && NewPN->getType()->getScalarType()->isPointerTy()) 412 MD->invalidateCachedPointerInfo(NewPN); 413 return NewPN; 414 } 415 416 /// 417 /// \brief Merge two stores to same address and sink into \p BB 418 /// 419 /// Also sinks GEP instruction computing the store address 420 /// 421 bool MergedLoadStoreMotion::sinkStore(BasicBlock *BB, StoreInst *S0, 422 StoreInst *S1) { 423 // Only one definition? 424 auto *A0 = dyn_cast<Instruction>(S0->getPointerOperand()); 425 auto *A1 = dyn_cast<Instruction>(S1->getPointerOperand()); 426 if (A0 && A1 && A0->isIdenticalTo(A1) && A0->hasOneUse() && 427 (A0->getParent() == S0->getParent()) && A1->hasOneUse() && 428 (A1->getParent() == S1->getParent()) && isa<GetElementPtrInst>(A0)) { 429 DEBUG(dbgs() << "Sink Instruction into BB \n"; BB->dump(); 430 dbgs() << "Instruction Left\n"; S0->dump(); dbgs() << "\n"; 431 dbgs() << "Instruction Right\n"; S1->dump(); dbgs() << "\n"); 432 // Hoist the instruction. 433 BasicBlock::iterator InsertPt = BB->getFirstInsertionPt(); 434 // Intersect optional metadata. 435 S0->intersectOptionalDataWith(S1); 436 S0->dropUnknownNonDebugMetadata(); 437 438 // Create the new store to be inserted at the join point. 439 StoreInst *SNew = cast<StoreInst>(S0->clone()); 440 Instruction *ANew = A0->clone(); 441 SNew->insertBefore(&*InsertPt); 442 ANew->insertBefore(SNew); 443 444 assert(S0->getParent() == A0->getParent()); 445 assert(S1->getParent() == A1->getParent()); 446 447 // New PHI operand? Use it. 448 if (PHINode *NewPN = getPHIOperand(BB, S0, S1)) 449 SNew->setOperand(0, NewPN); 450 removeInstruction(S0); 451 removeInstruction(S1); 452 A0->replaceAllUsesWith(ANew); 453 removeInstruction(A0); 454 A1->replaceAllUsesWith(ANew); 455 removeInstruction(A1); 456 return true; 457 } 458 return false; 459 } 460 461 /// 462 /// \brief True when two stores are equivalent and can sink into the footer 463 /// 464 /// Starting from a diamond tail block, iterate over the instructions in one 465 /// predecessor block and try to match a store in the second predecessor. 466 /// 467 bool MergedLoadStoreMotion::mergeStores(BasicBlock *T) { 468 469 bool MergedStores = false; 470 assert(T && "Footer of a diamond cannot be empty"); 471 472 pred_iterator PI = pred_begin(T), E = pred_end(T); 473 assert(PI != E); 474 BasicBlock *Pred0 = *PI; 475 ++PI; 476 BasicBlock *Pred1 = *PI; 477 ++PI; 478 // tail block of a diamond/hammock? 479 if (Pred0 == Pred1) 480 return false; // No. 481 if (PI != E) 482 return false; // No. More than 2 predecessors. 483 484 // #Instructions in Succ1 for Compile Time Control 485 int Size1 = Pred1->size(); 486 int NStores = 0; 487 488 for (BasicBlock::reverse_iterator RBI = Pred0->rbegin(), RBE = Pred0->rend(); 489 RBI != RBE;) { 490 491 Instruction *I = &*RBI; 492 ++RBI; 493 494 // Don't sink non-simple (atomic, volatile) stores. 495 auto *S0 = dyn_cast<StoreInst>(I); 496 if (!S0 || !S0->isSimple()) 497 continue; 498 499 ++NStores; 500 if (NStores * Size1 >= MagicCompileTimeControl) 501 break; 502 if (StoreInst *S1 = canSinkFromBlock(Pred1, S0)) { 503 bool Res = sinkStore(T, S0, S1); 504 MergedStores |= Res; 505 // Don't attempt to sink below stores that had to stick around 506 // But after removal of a store and some of its feeding 507 // instruction search again from the beginning since the iterator 508 // is likely stale at this point. 509 if (!Res) 510 break; 511 RBI = Pred0->rbegin(); 512 RBE = Pred0->rend(); 513 DEBUG(dbgs() << "Search again\n"; Instruction *I = &*RBI; I->dump()); 514 } 515 } 516 return MergedStores; 517 } 518 519 bool MergedLoadStoreMotion::run(Function &F, MemoryDependenceResults *MD, 520 AliasAnalysis &AA) { 521 this->MD = MD; 522 this->AA = &AA; 523 524 bool Changed = false; 525 DEBUG(dbgs() << "Instruction Merger\n"); 526 527 // Merge unconditional branches, allowing PRE to catch more 528 // optimization opportunities. 529 for (Function::iterator FI = F.begin(), FE = F.end(); FI != FE;) { 530 BasicBlock *BB = &*FI++; 531 532 // Hoist equivalent loads and sink stores 533 // outside diamonds when possible 534 if (isDiamondHead(BB)) { 535 Changed |= mergeLoads(BB); 536 Changed |= mergeStores(getDiamondTail(BB)); 537 } 538 } 539 return Changed; 540 } 541 542 namespace { 543 class MergedLoadStoreMotionLegacyPass : public FunctionPass { 544 public: 545 static char ID; // Pass identification, replacement for typeid 546 MergedLoadStoreMotionLegacyPass() : FunctionPass(ID) { 547 initializeMergedLoadStoreMotionLegacyPassPass( 548 *PassRegistry::getPassRegistry()); 549 } 550 551 /// 552 /// \brief Run the transformation for each function 553 /// 554 bool runOnFunction(Function &F) override { 555 if (skipFunction(F)) 556 return false; 557 MergedLoadStoreMotion Impl; 558 auto *MDWP = getAnalysisIfAvailable<MemoryDependenceWrapperPass>(); 559 return Impl.run(F, MDWP ? &MDWP->getMemDep() : nullptr, 560 getAnalysis<AAResultsWrapperPass>().getAAResults()); 561 } 562 563 private: 564 // This transformation requires dominator postdominator info 565 void getAnalysisUsage(AnalysisUsage &AU) const override { 566 AU.setPreservesCFG(); 567 AU.addRequired<AAResultsWrapperPass>(); 568 AU.addPreserved<GlobalsAAWrapperPass>(); 569 AU.addPreserved<MemoryDependenceWrapperPass>(); 570 } 571 }; 572 573 char MergedLoadStoreMotionLegacyPass::ID = 0; 574 } // anonymous namespace 575 576 /// 577 /// \brief createMergedLoadStoreMotionPass - The public interface to this file. 578 /// 579 FunctionPass *llvm::createMergedLoadStoreMotionPass() { 580 return new MergedLoadStoreMotionLegacyPass(); 581 } 582 583 INITIALIZE_PASS_BEGIN(MergedLoadStoreMotionLegacyPass, "mldst-motion", 584 "MergedLoadStoreMotion", false, false) 585 INITIALIZE_PASS_DEPENDENCY(MemoryDependenceWrapperPass) 586 INITIALIZE_PASS_DEPENDENCY(AAResultsWrapperPass) 587 INITIALIZE_PASS_END(MergedLoadStoreMotionLegacyPass, "mldst-motion", 588 "MergedLoadStoreMotion", false, false) 589 590 PreservedAnalyses 591 MergedLoadStoreMotionPass::run(Function &F, AnalysisManager<Function> &AM) { 592 MergedLoadStoreMotion Impl; 593 auto *MD = AM.getCachedResult<MemoryDependenceAnalysis>(F); 594 auto &AA = AM.getResult<AAManager>(F); 595 if (!Impl.run(F, MD, AA)) 596 return PreservedAnalyses::all(); 597 598 // FIXME: This pass should also 'preserve the CFG'. 599 // The new pass manager has currently no way to do it. 600 PreservedAnalyses PA; 601 PA.preserve<GlobalsAA>(); 602 PA.preserve<MemoryDependenceAnalysis>(); 603 return PA; 604 } 605