NAKAMURA Takumi | 8496503 | 2015-09-22 11:14:12 +0000 | [diff] [blame] | 1 | //===---- DemandedBits.cpp - Determine demanded bits ----------------------===// |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 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 | // This pass implements a demanded bits analysis. A demanded bit is one that |
| 11 | // contributes to a result; bits that are not demanded can be either zero or |
| 12 | // one without affecting control or data flow. For example in this sequence: |
| 13 | // |
| 14 | // %1 = add i32 %x, %y |
| 15 | // %2 = trunc i32 %1 to i16 |
| 16 | // |
| 17 | // Only the lowest 16 bits of %1 are demanded; the rest are removed by the |
| 18 | // trunc. |
| 19 | // |
| 20 | //===----------------------------------------------------------------------===// |
| 21 | |
| 22 | #include "llvm/Analysis/DemandedBits.h" |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 23 | #include "llvm/ADT/DepthFirstIterator.h" |
| 24 | #include "llvm/ADT/SmallPtrSet.h" |
| 25 | #include "llvm/ADT/SmallVector.h" |
James Molloy | bcd7f0a | 2015-10-08 12:39:59 +0000 | [diff] [blame] | 26 | #include "llvm/ADT/StringExtras.h" |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 27 | #include "llvm/Analysis/ValueTracking.h" |
| 28 | #include "llvm/IR/BasicBlock.h" |
| 29 | #include "llvm/IR/CFG.h" |
| 30 | #include "llvm/IR/DataLayout.h" |
| 31 | #include "llvm/IR/Dominators.h" |
| 32 | #include "llvm/IR/InstIterator.h" |
| 33 | #include "llvm/IR/Instructions.h" |
| 34 | #include "llvm/IR/IntrinsicInst.h" |
| 35 | #include "llvm/IR/Module.h" |
| 36 | #include "llvm/IR/Operator.h" |
| 37 | #include "llvm/Pass.h" |
| 38 | #include "llvm/Support/Debug.h" |
| 39 | #include "llvm/Support/raw_ostream.h" |
| 40 | using namespace llvm; |
| 41 | |
| 42 | #define DEBUG_TYPE "demanded-bits" |
| 43 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 44 | char DemandedBitsWrapperPass::ID = 0; |
| 45 | INITIALIZE_PASS_BEGIN(DemandedBitsWrapperPass, "demanded-bits", |
| 46 | "Demanded bits analysis", false, false) |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 47 | INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass) |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 48 | INITIALIZE_PASS_END(DemandedBitsWrapperPass, "demanded-bits", |
| 49 | "Demanded bits analysis", false, false) |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 50 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 51 | DemandedBitsWrapperPass::DemandedBitsWrapperPass() : FunctionPass(ID) { |
| 52 | initializeDemandedBitsWrapperPassPass(*PassRegistry::getPassRegistry()); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 53 | } |
| 54 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 55 | void DemandedBitsWrapperPass::getAnalysisUsage(AnalysisUsage &AU) const { |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 56 | AU.setPreservesCFG(); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 57 | AU.addRequired<DominatorTreeWrapperPass>(); |
| 58 | AU.setPreservesAll(); |
| 59 | } |
| 60 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 61 | void DemandedBitsWrapperPass::print(raw_ostream &OS, const Module *M) const { |
| 62 | DB->print(OS); |
| 63 | } |
| 64 | |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 65 | static bool isAlwaysLive(Instruction *I) { |
| 66 | return isa<TerminatorInst>(I) || isa<DbgInfoIntrinsic>(I) || |
| 67 | I->isEHPad() || I->mayHaveSideEffects(); |
| 68 | } |
| 69 | |
NAKAMURA Takumi | 0a7d0ad | 2015-09-22 11:15:07 +0000 | [diff] [blame] | 70 | void DemandedBits::determineLiveOperandBits( |
| 71 | const Instruction *UserI, const Instruction *I, unsigned OperandNo, |
| 72 | const APInt &AOut, APInt &AB, APInt &KnownZero, APInt &KnownOne, |
| 73 | APInt &KnownZero2, APInt &KnownOne2) { |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 74 | unsigned BitWidth = AB.getBitWidth(); |
| 75 | |
| 76 | // We're called once per operand, but for some instructions, we need to |
| 77 | // compute known bits of both operands in order to determine the live bits of |
| 78 | // either (when both operands are instructions themselves). We don't, |
| 79 | // however, want to do this twice, so we cache the result in APInts that live |
| 80 | // in the caller. For the two-relevant-operands case, both operand values are |
| 81 | // provided here. |
| 82 | auto ComputeKnownBits = |
| 83 | [&](unsigned BitWidth, const Value *V1, const Value *V2) { |
| 84 | const DataLayout &DL = I->getModule()->getDataLayout(); |
| 85 | KnownZero = APInt(BitWidth, 0); |
| 86 | KnownOne = APInt(BitWidth, 0); |
| 87 | computeKnownBits(const_cast<Value *>(V1), KnownZero, KnownOne, DL, 0, |
Hal Finkel | 3ca4a6b | 2016-12-15 03:02:15 +0000 | [diff] [blame] | 88 | UserI, &DT); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 89 | |
| 90 | if (V2) { |
| 91 | KnownZero2 = APInt(BitWidth, 0); |
| 92 | KnownOne2 = APInt(BitWidth, 0); |
| 93 | computeKnownBits(const_cast<Value *>(V2), KnownZero2, KnownOne2, DL, |
Hal Finkel | 3ca4a6b | 2016-12-15 03:02:15 +0000 | [diff] [blame] | 94 | 0, UserI, &DT); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 95 | } |
| 96 | }; |
| 97 | |
| 98 | switch (UserI->getOpcode()) { |
| 99 | default: break; |
| 100 | case Instruction::Call: |
| 101 | case Instruction::Invoke: |
| 102 | if (const IntrinsicInst *II = dyn_cast<IntrinsicInst>(UserI)) |
| 103 | switch (II->getIntrinsicID()) { |
| 104 | default: break; |
| 105 | case Intrinsic::bswap: |
| 106 | // The alive bits of the input are the swapped alive bits of |
| 107 | // the output. |
| 108 | AB = AOut.byteSwap(); |
| 109 | break; |
| 110 | case Intrinsic::ctlz: |
| 111 | if (OperandNo == 0) { |
| 112 | // We need some output bits, so we need all bits of the |
| 113 | // input to the left of, and including, the leftmost bit |
| 114 | // known to be one. |
| 115 | ComputeKnownBits(BitWidth, I, nullptr); |
| 116 | AB = APInt::getHighBitsSet(BitWidth, |
| 117 | std::min(BitWidth, KnownOne.countLeadingZeros()+1)); |
| 118 | } |
| 119 | break; |
| 120 | case Intrinsic::cttz: |
| 121 | if (OperandNo == 0) { |
| 122 | // We need some output bits, so we need all bits of the |
| 123 | // input to the right of, and including, the rightmost bit |
| 124 | // known to be one. |
| 125 | ComputeKnownBits(BitWidth, I, nullptr); |
| 126 | AB = APInt::getLowBitsSet(BitWidth, |
| 127 | std::min(BitWidth, KnownOne.countTrailingZeros()+1)); |
| 128 | } |
| 129 | break; |
| 130 | } |
| 131 | break; |
| 132 | case Instruction::Add: |
| 133 | case Instruction::Sub: |
James Molloy | bcd7f0a | 2015-10-08 12:39:59 +0000 | [diff] [blame] | 134 | case Instruction::Mul: |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 135 | // Find the highest live output bit. We don't need any more input |
| 136 | // bits than that (adds, and thus subtracts, ripple only to the |
| 137 | // left). |
| 138 | AB = APInt::getLowBitsSet(BitWidth, AOut.getActiveBits()); |
| 139 | break; |
| 140 | case Instruction::Shl: |
| 141 | if (OperandNo == 0) |
| 142 | if (ConstantInt *CI = |
| 143 | dyn_cast<ConstantInt>(UserI->getOperand(1))) { |
| 144 | uint64_t ShiftAmt = CI->getLimitedValue(BitWidth-1); |
| 145 | AB = AOut.lshr(ShiftAmt); |
| 146 | |
| 147 | // If the shift is nuw/nsw, then the high bits are not dead |
| 148 | // (because we've promised that they *must* be zero). |
| 149 | const ShlOperator *S = cast<ShlOperator>(UserI); |
| 150 | if (S->hasNoSignedWrap()) |
| 151 | AB |= APInt::getHighBitsSet(BitWidth, ShiftAmt+1); |
| 152 | else if (S->hasNoUnsignedWrap()) |
| 153 | AB |= APInt::getHighBitsSet(BitWidth, ShiftAmt); |
| 154 | } |
| 155 | break; |
| 156 | case Instruction::LShr: |
| 157 | if (OperandNo == 0) |
| 158 | if (ConstantInt *CI = |
| 159 | dyn_cast<ConstantInt>(UserI->getOperand(1))) { |
| 160 | uint64_t ShiftAmt = CI->getLimitedValue(BitWidth-1); |
| 161 | AB = AOut.shl(ShiftAmt); |
| 162 | |
| 163 | // If the shift is exact, then the low bits are not dead |
| 164 | // (they must be zero). |
| 165 | if (cast<LShrOperator>(UserI)->isExact()) |
| 166 | AB |= APInt::getLowBitsSet(BitWidth, ShiftAmt); |
| 167 | } |
| 168 | break; |
| 169 | case Instruction::AShr: |
| 170 | if (OperandNo == 0) |
| 171 | if (ConstantInt *CI = |
| 172 | dyn_cast<ConstantInt>(UserI->getOperand(1))) { |
| 173 | uint64_t ShiftAmt = CI->getLimitedValue(BitWidth-1); |
| 174 | AB = AOut.shl(ShiftAmt); |
| 175 | // Because the high input bit is replicated into the |
| 176 | // high-order bits of the result, if we need any of those |
| 177 | // bits, then we must keep the highest input bit. |
| 178 | if ((AOut & APInt::getHighBitsSet(BitWidth, ShiftAmt)) |
| 179 | .getBoolValue()) |
| 180 | AB.setBit(BitWidth-1); |
| 181 | |
| 182 | // If the shift is exact, then the low bits are not dead |
| 183 | // (they must be zero). |
| 184 | if (cast<AShrOperator>(UserI)->isExact()) |
| 185 | AB |= APInt::getLowBitsSet(BitWidth, ShiftAmt); |
| 186 | } |
| 187 | break; |
| 188 | case Instruction::And: |
| 189 | AB = AOut; |
| 190 | |
| 191 | // For bits that are known zero, the corresponding bits in the |
| 192 | // other operand are dead (unless they're both zero, in which |
| 193 | // case they can't both be dead, so just mark the LHS bits as |
| 194 | // dead). |
| 195 | if (OperandNo == 0) { |
| 196 | ComputeKnownBits(BitWidth, I, UserI->getOperand(1)); |
| 197 | AB &= ~KnownZero2; |
| 198 | } else { |
| 199 | if (!isa<Instruction>(UserI->getOperand(0))) |
| 200 | ComputeKnownBits(BitWidth, UserI->getOperand(0), I); |
| 201 | AB &= ~(KnownZero & ~KnownZero2); |
| 202 | } |
| 203 | break; |
| 204 | case Instruction::Or: |
| 205 | AB = AOut; |
| 206 | |
| 207 | // For bits that are known one, the corresponding bits in the |
| 208 | // other operand are dead (unless they're both one, in which |
| 209 | // case they can't both be dead, so just mark the LHS bits as |
| 210 | // dead). |
| 211 | if (OperandNo == 0) { |
| 212 | ComputeKnownBits(BitWidth, I, UserI->getOperand(1)); |
| 213 | AB &= ~KnownOne2; |
| 214 | } else { |
| 215 | if (!isa<Instruction>(UserI->getOperand(0))) |
| 216 | ComputeKnownBits(BitWidth, UserI->getOperand(0), I); |
| 217 | AB &= ~(KnownOne & ~KnownOne2); |
| 218 | } |
| 219 | break; |
| 220 | case Instruction::Xor: |
| 221 | case Instruction::PHI: |
| 222 | AB = AOut; |
| 223 | break; |
| 224 | case Instruction::Trunc: |
| 225 | AB = AOut.zext(BitWidth); |
| 226 | break; |
| 227 | case Instruction::ZExt: |
| 228 | AB = AOut.trunc(BitWidth); |
| 229 | break; |
| 230 | case Instruction::SExt: |
| 231 | AB = AOut.trunc(BitWidth); |
| 232 | // Because the high input bit is replicated into the |
| 233 | // high-order bits of the result, if we need any of those |
| 234 | // bits, then we must keep the highest input bit. |
| 235 | if ((AOut & APInt::getHighBitsSet(AOut.getBitWidth(), |
| 236 | AOut.getBitWidth() - BitWidth)) |
| 237 | .getBoolValue()) |
| 238 | AB.setBit(BitWidth-1); |
| 239 | break; |
| 240 | case Instruction::Select: |
| 241 | if (OperandNo != 0) |
| 242 | AB = AOut; |
| 243 | break; |
| 244 | } |
| 245 | } |
| 246 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 247 | bool DemandedBitsWrapperPass::runOnFunction(Function &F) { |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 248 | auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree(); |
Hal Finkel | 3ca4a6b | 2016-12-15 03:02:15 +0000 | [diff] [blame] | 249 | DB.emplace(F, DT); |
James Molloy | ab9fdb9 | 2015-10-08 12:39:50 +0000 | [diff] [blame] | 250 | return false; |
| 251 | } |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 252 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 253 | void DemandedBitsWrapperPass::releaseMemory() { |
| 254 | DB.reset(); |
| 255 | } |
| 256 | |
James Molloy | ab9fdb9 | 2015-10-08 12:39:50 +0000 | [diff] [blame] | 257 | void DemandedBits::performAnalysis() { |
| 258 | if (Analyzed) |
| 259 | // Analysis already completed for this function. |
| 260 | return; |
| 261 | Analyzed = true; |
James Molloy | ab9fdb9 | 2015-10-08 12:39:50 +0000 | [diff] [blame] | 262 | |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 263 | Visited.clear(); |
| 264 | AliveBits.clear(); |
| 265 | |
| 266 | SmallVector<Instruction*, 128> Worklist; |
| 267 | |
| 268 | // Collect the set of "root" instructions that are known live. |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 269 | for (Instruction &I : instructions(F)) { |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 270 | if (!isAlwaysLive(&I)) |
| 271 | continue; |
| 272 | |
| 273 | DEBUG(dbgs() << "DemandedBits: Root: " << I << "\n"); |
| 274 | // For integer-valued instructions, set up an initial empty set of alive |
| 275 | // bits and add the instruction to the work list. For other instructions |
| 276 | // add their operands to the work list (for integer values operands, mark |
| 277 | // all bits as live). |
| 278 | if (IntegerType *IT = dyn_cast<IntegerType>(I.getType())) { |
Benjamin Kramer | a9e477b | 2016-07-21 13:37:55 +0000 | [diff] [blame] | 279 | if (AliveBits.try_emplace(&I, IT->getBitWidth(), 0).second) |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 280 | Worklist.push_back(&I); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 281 | |
| 282 | continue; |
| 283 | } |
| 284 | |
| 285 | // Non-integer-typed instructions... |
| 286 | for (Use &OI : I.operands()) { |
| 287 | if (Instruction *J = dyn_cast<Instruction>(OI)) { |
| 288 | if (IntegerType *IT = dyn_cast<IntegerType>(J->getType())) |
| 289 | AliveBits[J] = APInt::getAllOnesValue(IT->getBitWidth()); |
| 290 | Worklist.push_back(J); |
| 291 | } |
| 292 | } |
| 293 | // To save memory, we don't add I to the Visited set here. Instead, we |
| 294 | // check isAlwaysLive on every instruction when searching for dead |
| 295 | // instructions later (we need to check isAlwaysLive for the |
| 296 | // integer-typed instructions anyway). |
| 297 | } |
| 298 | |
| 299 | // Propagate liveness backwards to operands. |
| 300 | while (!Worklist.empty()) { |
| 301 | Instruction *UserI = Worklist.pop_back_val(); |
| 302 | |
| 303 | DEBUG(dbgs() << "DemandedBits: Visiting: " << *UserI); |
| 304 | APInt AOut; |
| 305 | if (UserI->getType()->isIntegerTy()) { |
| 306 | AOut = AliveBits[UserI]; |
| 307 | DEBUG(dbgs() << " Alive Out: " << AOut); |
| 308 | } |
| 309 | DEBUG(dbgs() << "\n"); |
| 310 | |
| 311 | if (!UserI->getType()->isIntegerTy()) |
| 312 | Visited.insert(UserI); |
| 313 | |
| 314 | APInt KnownZero, KnownOne, KnownZero2, KnownOne2; |
| 315 | // Compute the set of alive bits for each operand. These are anded into the |
| 316 | // existing set, if any, and if that changes the set of alive bits, the |
| 317 | // operand is added to the work-list. |
| 318 | for (Use &OI : UserI->operands()) { |
| 319 | if (Instruction *I = dyn_cast<Instruction>(OI)) { |
| 320 | if (IntegerType *IT = dyn_cast<IntegerType>(I->getType())) { |
| 321 | unsigned BitWidth = IT->getBitWidth(); |
| 322 | APInt AB = APInt::getAllOnesValue(BitWidth); |
| 323 | if (UserI->getType()->isIntegerTy() && !AOut && |
| 324 | !isAlwaysLive(UserI)) { |
| 325 | AB = APInt(BitWidth, 0); |
| 326 | } else { |
NAKAMURA Takumi | 8496503 | 2015-09-22 11:14:12 +0000 | [diff] [blame] | 327 | // If all bits of the output are dead, then all bits of the input |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 328 | // Bits of each operand that are used to compute alive bits of the |
| 329 | // output are alive, all others are dead. |
| 330 | determineLiveOperandBits(UserI, I, OI.getOperandNo(), AOut, AB, |
| 331 | KnownZero, KnownOne, |
| 332 | KnownZero2, KnownOne2); |
| 333 | } |
| 334 | |
| 335 | // If we've added to the set of alive bits (or the operand has not |
| 336 | // been previously visited), then re-queue the operand to be visited |
| 337 | // again. |
| 338 | APInt ABPrev(BitWidth, 0); |
| 339 | auto ABI = AliveBits.find(I); |
| 340 | if (ABI != AliveBits.end()) |
| 341 | ABPrev = ABI->second; |
| 342 | |
| 343 | APInt ABNew = AB | ABPrev; |
| 344 | if (ABNew != ABPrev || ABI == AliveBits.end()) { |
| 345 | AliveBits[I] = std::move(ABNew); |
| 346 | Worklist.push_back(I); |
| 347 | } |
| 348 | } else if (!Visited.count(I)) { |
| 349 | Worklist.push_back(I); |
| 350 | } |
| 351 | } |
| 352 | } |
| 353 | } |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 354 | } |
| 355 | |
| 356 | APInt DemandedBits::getDemandedBits(Instruction *I) { |
James Molloy | ab9fdb9 | 2015-10-08 12:39:50 +0000 | [diff] [blame] | 357 | performAnalysis(); |
| 358 | |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 359 | const DataLayout &DL = I->getParent()->getModule()->getDataLayout(); |
Benjamin Kramer | a9e477b | 2016-07-21 13:37:55 +0000 | [diff] [blame] | 360 | auto Found = AliveBits.find(I); |
| 361 | if (Found != AliveBits.end()) |
| 362 | return Found->second; |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 363 | return APInt::getAllOnesValue(DL.getTypeSizeInBits(I->getType())); |
| 364 | } |
| 365 | |
| 366 | bool DemandedBits::isInstructionDead(Instruction *I) { |
James Molloy | ab9fdb9 | 2015-10-08 12:39:50 +0000 | [diff] [blame] | 367 | performAnalysis(); |
| 368 | |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 369 | return !Visited.count(I) && AliveBits.find(I) == AliveBits.end() && |
| 370 | !isAlwaysLive(I); |
| 371 | } |
| 372 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 373 | void DemandedBits::print(raw_ostream &OS) { |
| 374 | performAnalysis(); |
James Molloy | bcd7f0a | 2015-10-08 12:39:59 +0000 | [diff] [blame] | 375 | for (auto &KV : AliveBits) { |
| 376 | OS << "DemandedBits: 0x" << utohexstr(KV.second.getLimitedValue()) << " for " |
| 377 | << *KV.first << "\n"; |
| 378 | } |
| 379 | } |
| 380 | |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 381 | FunctionPass *llvm::createDemandedBitsWrapperPass() { |
| 382 | return new DemandedBitsWrapperPass(); |
| 383 | } |
| 384 | |
Chandler Carruth | dab4eae | 2016-11-23 17:53:26 +0000 | [diff] [blame] | 385 | AnalysisKey DemandedBitsAnalysis::Key; |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 386 | |
| 387 | DemandedBits DemandedBitsAnalysis::run(Function &F, |
Sean Silva | 36e0d01 | 2016-08-09 00:28:15 +0000 | [diff] [blame] | 388 | FunctionAnalysisManager &AM) { |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 389 | auto &DT = AM.getResult<DominatorTreeAnalysis>(F); |
Hal Finkel | 3ca4a6b | 2016-12-15 03:02:15 +0000 | [diff] [blame] | 390 | return DemandedBits(F, DT); |
Michael Kuperstein | de16b44 | 2016-04-18 23:55:01 +0000 | [diff] [blame] | 391 | } |
| 392 | |
| 393 | PreservedAnalyses DemandedBitsPrinterPass::run(Function &F, |
| 394 | FunctionAnalysisManager &AM) { |
| 395 | AM.getResult<DemandedBitsAnalysis>(F).print(OS); |
| 396 | return PreservedAnalyses::all(); |
James Molloy | 87405c7 | 2015-08-14 11:09:09 +0000 | [diff] [blame] | 397 | } |