Mercurial > hg > CbC > CbC_llvm
comparison lib/IR/BasicBlock.cpp @ 134:3a76565eade5 LLVM5.0.1
update 5.0.1
author | mir3636 |
---|---|
date | Sat, 17 Feb 2018 09:57:20 +0900 |
parents | 803732b1fca8 |
children | c2174574ed3a |
comparison
equal
deleted
inserted
replaced
133:c60214abe0e8 | 134:3a76565eade5 |
---|---|
262 } | 262 } |
263 return SuccBB; | 263 return SuccBB; |
264 } | 264 } |
265 | 265 |
266 iterator_range<BasicBlock::phi_iterator> BasicBlock::phis() { | 266 iterator_range<BasicBlock::phi_iterator> BasicBlock::phis() { |
267 return make_range<phi_iterator>(dyn_cast<PHINode>(&front()), nullptr); | 267 PHINode *P = empty() ? nullptr : dyn_cast<PHINode>(&*begin()); |
268 return make_range<phi_iterator>(P, nullptr); | |
268 } | 269 } |
269 | 270 |
270 /// This method is used to notify a BasicBlock that the | 271 /// This method is used to notify a BasicBlock that the |
271 /// specified Predecessor of the block is no longer able to reach it. This is | 272 /// specified Predecessor of the block is no longer able to reach it. This is |
272 /// actually not used to update the Predecessor list, but is actually used to | 273 /// actually not used to update the Predecessor list, but is actually used to |
445 | 446 |
446 /// Return the landingpad instruction associated with the landing pad. | 447 /// Return the landingpad instruction associated with the landing pad. |
447 const LandingPadInst *BasicBlock::getLandingPadInst() const { | 448 const LandingPadInst *BasicBlock::getLandingPadInst() const { |
448 return dyn_cast<LandingPadInst>(getFirstNonPHI()); | 449 return dyn_cast<LandingPadInst>(getFirstNonPHI()); |
449 } | 450 } |
451 | |
452 Optional<uint64_t> BasicBlock::getIrrLoopHeaderWeight() const { | |
453 const TerminatorInst *TI = getTerminator(); | |
454 if (MDNode *MDIrrLoopHeader = | |
455 TI->getMetadata(LLVMContext::MD_irr_loop)) { | |
456 MDString *MDName = cast<MDString>(MDIrrLoopHeader->getOperand(0)); | |
457 if (MDName->getString().equals("loop_header_weight")) { | |
458 auto *CI = mdconst::extract<ConstantInt>(MDIrrLoopHeader->getOperand(1)); | |
459 return Optional<uint64_t>(CI->getValue().getZExtValue()); | |
460 } | |
461 } | |
462 return Optional<uint64_t>(); | |
463 } |