| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 1 | //===- SpeculativeExecution.cpp ---------------------------------*- C++ -*-===// | 
|  | 2 | // | 
| Chandler Carruth | 2946cd7 | 2019-01-19 08:50:56 +0000 | [diff] [blame] | 3 | // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. | 
|  | 4 | // See https://llvm.org/LICENSE.txt for license information. | 
|  | 5 | // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 6 | // | 
|  | 7 | //===----------------------------------------------------------------------===// | 
|  | 8 | // | 
|  | 9 | // This pass hoists instructions to enable speculative execution on | 
|  | 10 | // targets where branches are expensive. This is aimed at GPUs. It | 
|  | 11 | // currently works on simple if-then and if-then-else | 
|  | 12 | // patterns. | 
|  | 13 | // | 
|  | 14 | // Removing branches is not the only motivation for this | 
|  | 15 | // pass. E.g. consider this code and assume that there is no | 
|  | 16 | // addressing mode for multiplying by sizeof(*a): | 
|  | 17 | // | 
|  | 18 | //   if (b > 0) | 
|  | 19 | //     c = a[i + 1] | 
|  | 20 | //   if (d > 0) | 
|  | 21 | //     e = a[i + 2] | 
|  | 22 | // | 
|  | 23 | // turns into | 
|  | 24 | // | 
|  | 25 | //   p = &a[i + 1]; | 
|  | 26 | //   if (b > 0) | 
|  | 27 | //     c = *p; | 
|  | 28 | //   q = &a[i + 2]; | 
|  | 29 | //   if (d > 0) | 
|  | 30 | //     e = *q; | 
|  | 31 | // | 
|  | 32 | // which could later be optimized to | 
|  | 33 | // | 
|  | 34 | //   r = &a[i]; | 
|  | 35 | //   if (b > 0) | 
|  | 36 | //     c = r[1]; | 
|  | 37 | //   if (d > 0) | 
|  | 38 | //     e = r[2]; | 
|  | 39 | // | 
|  | 40 | // Later passes sink back much of the speculated code that did not enable | 
|  | 41 | // further optimization. | 
|  | 42 | // | 
| Jingyue Wu | 5db9cba | 2015-05-19 20:52:45 +0000 | [diff] [blame] | 43 | // This pass is more aggressive than the function SpeculativeyExecuteBB in | 
|  | 44 | // SimplifyCFG. SimplifyCFG will not speculate if no selects are introduced and | 
|  | 45 | // it will speculate at most one instruction. It also will not speculate if | 
|  | 46 | // there is a value defined in the if-block that is only used in the then-block. | 
|  | 47 | // These restrictions make sense since the speculation in SimplifyCFG seems | 
|  | 48 | // aimed at introducing cheap selects, while this pass is intended to do more | 
|  | 49 | // aggressive speculation while counting on later passes to either capitalize on | 
|  | 50 | // that or clean it up. | 
|  | 51 | // | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 52 | // If the pass was created by calling | 
|  | 53 | // createSpeculativeExecutionIfHasBranchDivergencePass or the | 
|  | 54 | // -spec-exec-only-if-divergent-target option is present, this pass only has an | 
|  | 55 | // effect on targets where TargetTransformInfo::hasBranchDivergence() is true; | 
|  | 56 | // on other targets, it is a nop. | 
|  | 57 | // | 
|  | 58 | // This lets you include this pass unconditionally in the IR pass pipeline, but | 
|  | 59 | // only enable it for relevant targets. | 
|  | 60 | // | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 61 | //===----------------------------------------------------------------------===// | 
|  | 62 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 63 | #include "llvm/Transforms/Scalar/SpeculativeExecution.h" | 
| Florian Hahn | a1cc848 | 2018-06-12 11:16:56 +0000 | [diff] [blame] | 64 | #include "llvm/ADT/SmallPtrSet.h" | 
| Kristof Beyls | c08f705 | 2016-05-03 08:33:26 +0000 | [diff] [blame] | 65 | #include "llvm/Analysis/GlobalsModRef.h" | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 66 | #include "llvm/Analysis/ValueTracking.h" | 
|  | 67 | #include "llvm/IR/Instructions.h" | 
|  | 68 | #include "llvm/IR/Module.h" | 
|  | 69 | #include "llvm/IR/Operator.h" | 
|  | 70 | #include "llvm/Support/CommandLine.h" | 
|  | 71 | #include "llvm/Support/Debug.h" | 
|  | 72 |  | 
|  | 73 | using namespace llvm; | 
|  | 74 |  | 
|  | 75 | #define DEBUG_TYPE "speculative-execution" | 
|  | 76 |  | 
|  | 77 | // The risk that speculation will not pay off increases with the | 
|  | 78 | // number of instructions speculated, so we put a limit on that. | 
|  | 79 | static cl::opt<unsigned> SpecExecMaxSpeculationCost( | 
|  | 80 | "spec-exec-max-speculation-cost", cl::init(7), cl::Hidden, | 
|  | 81 | cl::desc("Speculative execution is not applied to basic blocks where " | 
|  | 82 | "the cost of the instructions to speculatively execute " | 
|  | 83 | "exceeds this limit.")); | 
|  | 84 |  | 
|  | 85 | // Speculating just a few instructions from a larger block tends not | 
|  | 86 | // to be profitable and this limit prevents that. A reason for that is | 
|  | 87 | // that small basic blocks are more likely to be candidates for | 
|  | 88 | // further optimization. | 
|  | 89 | static cl::opt<unsigned> SpecExecMaxNotHoisted( | 
|  | 90 | "spec-exec-max-not-hoisted", cl::init(5), cl::Hidden, | 
|  | 91 | cl::desc("Speculative execution is not applied to basic blocks where the " | 
|  | 92 | "number of instructions that would not be speculatively executed " | 
|  | 93 | "exceeds this limit.")); | 
|  | 94 |  | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 95 | static cl::opt<bool> SpecExecOnlyIfDivergentTarget( | 
| Chad Rosier | 4466ff5 | 2016-05-02 19:06:02 +0000 | [diff] [blame] | 96 | "spec-exec-only-if-divergent-target", cl::init(false), cl::Hidden, | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 97 | cl::desc("Speculative execution is applied only to targets with divergent " | 
|  | 98 | "branches, even if the pass was configured to apply only to all " | 
|  | 99 | "targets.")); | 
|  | 100 |  | 
| Benjamin Kramer | d9f06c8 | 2015-05-16 16:16:35 +0000 | [diff] [blame] | 101 | namespace { | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 102 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 103 | class SpeculativeExecutionLegacyPass : public FunctionPass { | 
|  | 104 | public: | 
|  | 105 | static char ID; | 
|  | 106 | explicit SpeculativeExecutionLegacyPass(bool OnlyIfDivergentTarget = false) | 
|  | 107 | : FunctionPass(ID), OnlyIfDivergentTarget(OnlyIfDivergentTarget || | 
|  | 108 | SpecExecOnlyIfDivergentTarget), | 
|  | 109 | Impl(OnlyIfDivergentTarget) {} | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 110 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 111 | void getAnalysisUsage(AnalysisUsage &AU) const override; | 
|  | 112 | bool runOnFunction(Function &F) override; | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 113 |  | 
| Mehdi Amini | 117296c | 2016-10-01 02:56:57 +0000 | [diff] [blame] | 114 | StringRef getPassName() const override { | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 115 | if (OnlyIfDivergentTarget) | 
|  | 116 | return "Speculatively execute instructions if target has divergent " | 
|  | 117 | "branches"; | 
|  | 118 | return "Speculatively execute instructions"; | 
|  | 119 | } | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 120 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 121 | private: | 
|  | 122 | // Variable preserved purely for correct name printing. | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 123 | const bool OnlyIfDivergentTarget; | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 124 |  | 
|  | 125 | SpeculativeExecutionPass Impl; | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 126 | }; | 
| Benjamin Kramer | d9f06c8 | 2015-05-16 16:16:35 +0000 | [diff] [blame] | 127 | } // namespace | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 128 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 129 | char SpeculativeExecutionLegacyPass::ID = 0; | 
|  | 130 | INITIALIZE_PASS_BEGIN(SpeculativeExecutionLegacyPass, "speculative-execution", | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 131 | "Speculatively execute instructions", false, false) | 
|  | 132 | INITIALIZE_PASS_DEPENDENCY(TargetTransformInfoWrapperPass) | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 133 | INITIALIZE_PASS_END(SpeculativeExecutionLegacyPass, "speculative-execution", | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 134 | "Speculatively execute instructions", false, false) | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 135 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 136 | void SpeculativeExecutionLegacyPass::getAnalysisUsage(AnalysisUsage &AU) const { | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 137 | AU.addRequired<TargetTransformInfoWrapperPass>(); | 
| Kristof Beyls | c08f705 | 2016-05-03 08:33:26 +0000 | [diff] [blame] | 138 | AU.addPreserved<GlobalsAAWrapperPass>(); | 
| Michael Zolotukhin | 3180086 | 2018-06-07 00:19:29 +0000 | [diff] [blame] | 139 | AU.setPreservesCFG(); | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 140 | } | 
|  | 141 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 142 | bool SpeculativeExecutionLegacyPass::runOnFunction(Function &F) { | 
| Andrew Kaylor | aa641a5 | 2016-04-22 22:06:11 +0000 | [diff] [blame] | 143 | if (skipFunction(F)) | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 144 | return false; | 
|  | 145 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 146 | auto *TTI = &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(F); | 
|  | 147 | return Impl.runImpl(F, TTI); | 
|  | 148 | } | 
|  | 149 |  | 
|  | 150 | namespace llvm { | 
|  | 151 |  | 
|  | 152 | bool SpeculativeExecutionPass::runImpl(Function &F, TargetTransformInfo *TTI) { | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 153 | if (OnlyIfDivergentTarget && !TTI->hasBranchDivergence()) { | 
| Nicola Zaghen | d34e60c | 2018-05-14 12:53:11 +0000 | [diff] [blame] | 154 | LLVM_DEBUG(dbgs() << "Not running SpeculativeExecution because " | 
|  | 155 | "TTI->hasBranchDivergence() is false.\n"); | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 156 | return false; | 
|  | 157 | } | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 158 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 159 | this->TTI = TTI; | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 160 | bool Changed = false; | 
|  | 161 | for (auto& B : F) { | 
|  | 162 | Changed |= runOnBasicBlock(B); | 
|  | 163 | } | 
|  | 164 | return Changed; | 
|  | 165 | } | 
|  | 166 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 167 | bool SpeculativeExecutionPass::runOnBasicBlock(BasicBlock &B) { | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 168 | BranchInst *BI = dyn_cast<BranchInst>(B.getTerminator()); | 
|  | 169 | if (BI == nullptr) | 
|  | 170 | return false; | 
|  | 171 |  | 
|  | 172 | if (BI->getNumSuccessors() != 2) | 
|  | 173 | return false; | 
|  | 174 | BasicBlock &Succ0 = *BI->getSuccessor(0); | 
|  | 175 | BasicBlock &Succ1 = *BI->getSuccessor(1); | 
|  | 176 |  | 
|  | 177 | if (&B == &Succ0 || &B == &Succ1 || &Succ0 == &Succ1) { | 
|  | 178 | return false; | 
|  | 179 | } | 
|  | 180 |  | 
|  | 181 | // Hoist from if-then (triangle). | 
|  | 182 | if (Succ0.getSinglePredecessor() != nullptr && | 
|  | 183 | Succ0.getSingleSuccessor() == &Succ1) { | 
|  | 184 | return considerHoistingFromTo(Succ0, B); | 
|  | 185 | } | 
|  | 186 |  | 
|  | 187 | // Hoist from if-else (triangle). | 
|  | 188 | if (Succ1.getSinglePredecessor() != nullptr && | 
|  | 189 | Succ1.getSingleSuccessor() == &Succ0) { | 
|  | 190 | return considerHoistingFromTo(Succ1, B); | 
|  | 191 | } | 
|  | 192 |  | 
|  | 193 | // Hoist from if-then-else (diamond), but only if it is equivalent to | 
|  | 194 | // an if-else or if-then due to one of the branches doing nothing. | 
|  | 195 | if (Succ0.getSinglePredecessor() != nullptr && | 
|  | 196 | Succ1.getSinglePredecessor() != nullptr && | 
|  | 197 | Succ1.getSingleSuccessor() != nullptr && | 
|  | 198 | Succ1.getSingleSuccessor() != &B && | 
|  | 199 | Succ1.getSingleSuccessor() == Succ0.getSingleSuccessor()) { | 
|  | 200 | // If a block has only one instruction, then that is a terminator | 
|  | 201 | // instruction so that the block does nothing. This does happen. | 
|  | 202 | if (Succ1.size() == 1) // equivalent to if-then | 
|  | 203 | return considerHoistingFromTo(Succ0, B); | 
|  | 204 | if (Succ0.size() == 1) // equivalent to if-else | 
|  | 205 | return considerHoistingFromTo(Succ1, B); | 
|  | 206 | } | 
|  | 207 |  | 
|  | 208 | return false; | 
|  | 209 | } | 
|  | 210 |  | 
| Chandler Carruth | f3bd8dd | 2017-05-10 12:30:07 +0000 | [diff] [blame] | 211 | static unsigned ComputeSpeculationCost(const Instruction *I, | 
|  | 212 | const TargetTransformInfo &TTI) { | 
|  | 213 | switch (Operator::getOpcode(I)) { | 
|  | 214 | case Instruction::GetElementPtr: | 
|  | 215 | case Instruction::Add: | 
|  | 216 | case Instruction::Mul: | 
|  | 217 | case Instruction::And: | 
|  | 218 | case Instruction::Or: | 
|  | 219 | case Instruction::Select: | 
|  | 220 | case Instruction::Shl: | 
|  | 221 | case Instruction::Sub: | 
|  | 222 | case Instruction::LShr: | 
|  | 223 | case Instruction::AShr: | 
|  | 224 | case Instruction::Xor: | 
|  | 225 | case Instruction::ZExt: | 
|  | 226 | case Instruction::SExt: | 
|  | 227 | case Instruction::Call: | 
|  | 228 | case Instruction::BitCast: | 
|  | 229 | case Instruction::PtrToInt: | 
|  | 230 | case Instruction::IntToPtr: | 
|  | 231 | case Instruction::AddrSpaceCast: | 
|  | 232 | case Instruction::FPToUI: | 
|  | 233 | case Instruction::FPToSI: | 
|  | 234 | case Instruction::UIToFP: | 
|  | 235 | case Instruction::SIToFP: | 
|  | 236 | case Instruction::FPExt: | 
|  | 237 | case Instruction::FPTrunc: | 
|  | 238 | case Instruction::FAdd: | 
|  | 239 | case Instruction::FSub: | 
|  | 240 | case Instruction::FMul: | 
|  | 241 | case Instruction::FDiv: | 
|  | 242 | case Instruction::FRem: | 
| Cameron McInally | 7c5c0c9 | 2019-05-14 16:51:18 +0000 | [diff] [blame] | 243 | case Instruction::FNeg: | 
| Chandler Carruth | f3bd8dd | 2017-05-10 12:30:07 +0000 | [diff] [blame] | 244 | case Instruction::ICmp: | 
|  | 245 | case Instruction::FCmp: | 
|  | 246 | return TTI.getUserCost(I); | 
|  | 247 |  | 
|  | 248 | default: | 
|  | 249 | return UINT_MAX; // Disallow anything not whitelisted. | 
|  | 250 | } | 
|  | 251 | } | 
|  | 252 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 253 | bool SpeculativeExecutionPass::considerHoistingFromTo( | 
|  | 254 | BasicBlock &FromBlock, BasicBlock &ToBlock) { | 
| Florian Hahn | a1cc848 | 2018-06-12 11:16:56 +0000 | [diff] [blame] | 255 | SmallPtrSet<const Instruction *, 8> NotHoisted; | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 256 | const auto AllPrecedingUsesFromBlockHoisted = [&NotHoisted](User *U) { | 
|  | 257 | for (Value* V : U->operand_values()) { | 
|  | 258 | if (Instruction *I = dyn_cast<Instruction>(V)) { | 
|  | 259 | if (NotHoisted.count(I) > 0) | 
|  | 260 | return false; | 
|  | 261 | } | 
|  | 262 | } | 
|  | 263 | return true; | 
|  | 264 | }; | 
|  | 265 |  | 
|  | 266 | unsigned TotalSpeculationCost = 0; | 
|  | 267 | for (auto& I : FromBlock) { | 
| Chandler Carruth | f3bd8dd | 2017-05-10 12:30:07 +0000 | [diff] [blame] | 268 | const unsigned Cost = ComputeSpeculationCost(&I, *TTI); | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 269 | if (Cost != UINT_MAX && isSafeToSpeculativelyExecute(&I) && | 
|  | 270 | AllPrecedingUsesFromBlockHoisted(&I)) { | 
|  | 271 | TotalSpeculationCost += Cost; | 
|  | 272 | if (TotalSpeculationCost > SpecExecMaxSpeculationCost) | 
|  | 273 | return false;  // too much to hoist | 
|  | 274 | } else { | 
|  | 275 | NotHoisted.insert(&I); | 
|  | 276 | if (NotHoisted.size() > SpecExecMaxNotHoisted) | 
|  | 277 | return false; // too much left behind | 
|  | 278 | } | 
|  | 279 | } | 
|  | 280 |  | 
|  | 281 | if (TotalSpeculationCost == 0) | 
|  | 282 | return false; // nothing to hoist | 
|  | 283 |  | 
|  | 284 | for (auto I = FromBlock.begin(); I != FromBlock.end();) { | 
|  | 285 | // We have to increment I before moving Current as moving Current | 
|  | 286 | // changes the list that I is iterating through. | 
|  | 287 | auto Current = I; | 
|  | 288 | ++I; | 
| Duncan P. N. Exon Smith | be4d8cb | 2015-10-13 19:26:58 +0000 | [diff] [blame] | 289 | if (!NotHoisted.count(&*Current)) { | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 290 | Current->moveBefore(ToBlock.getTerminator()); | 
|  | 291 | } | 
|  | 292 | } | 
|  | 293 | return true; | 
|  | 294 | } | 
|  | 295 |  | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 296 | FunctionPass *createSpeculativeExecutionPass() { | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 297 | return new SpeculativeExecutionLegacyPass(); | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 298 | } | 
|  | 299 |  | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 300 | FunctionPass *createSpeculativeExecutionIfHasBranchDivergencePass() { | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 301 | return new SpeculativeExecutionLegacyPass(/* OnlyIfDivergentTarget = */ true); | 
| Justin Lebar | cad81cf | 2016-04-15 00:32:09 +0000 | [diff] [blame] | 302 | } | 
|  | 303 |  | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 304 | SpeculativeExecutionPass::SpeculativeExecutionPass(bool OnlyIfDivergentTarget) | 
|  | 305 | : OnlyIfDivergentTarget(OnlyIfDivergentTarget || | 
|  | 306 | SpecExecOnlyIfDivergentTarget) {} | 
|  | 307 |  | 
|  | 308 | PreservedAnalyses SpeculativeExecutionPass::run(Function &F, | 
|  | 309 | FunctionAnalysisManager &AM) { | 
|  | 310 | auto *TTI = &AM.getResult<TargetIRAnalysis>(F); | 
|  | 311 |  | 
|  | 312 | bool Changed = runImpl(F, TTI); | 
|  | 313 |  | 
|  | 314 | if (!Changed) | 
|  | 315 | return PreservedAnalyses::all(); | 
|  | 316 | PreservedAnalyses PA; | 
|  | 317 | PA.preserve<GlobalsAA>(); | 
| Michael Zolotukhin | 3180086 | 2018-06-07 00:19:29 +0000 | [diff] [blame] | 318 | PA.preserveSet<CFGAnalyses>(); | 
| Michael Kuperstein | c406186 | 2016-08-01 21:48:33 +0000 | [diff] [blame] | 319 | return PA; | 
|  | 320 | } | 
| Jingyue Wu | 154eb5a | 2015-05-15 17:54:48 +0000 | [diff] [blame] | 321 | }  // namespace llvm |