Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 18 additions & 4 deletions gen/ms-cxx-helper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,18 @@ void findSuccessors(std::vector<llvm::BasicBlock *> &blocks,
llvm::BasicBlock *bb, llvm::BasicBlock *ebb) {
blocks.push_back(bb);
if (bb != ebb) {
#if LLVM_VERSION_MAJOR >= 23
assert(bb->getTerminatorOrNull());
#else
assert(bb->getTerminator());
#endif
for (size_t pos = 0; pos < blocks.size(); ++pos) {
bb = blocks[pos];
#if LLVM_VERSION_MAJOR >= 23
if (auto term = bb->getTerminatorOrNull()) {
#else
if (auto term = bb->getTerminator()) {
#endif
llvm::BasicBlock *unwindDest = getUnwindDest(term);
unsigned cnt = term->getNumSuccessors();
for (unsigned s = 0; s < cnt; s++) {
Expand Down Expand Up @@ -84,10 +92,16 @@ void cloneBlocks(const std::vector<llvm::BasicBlock *> &srcblocks,
llvm::Value *funclet) {
llvm::ValueToValueMapTy VMap;
// map the terminal branch to the new target
if (continueWith)
if (auto term = srcblocks.back()->getTerminator())
if (auto succ = term->getSuccessor(0))
VMap[succ] = continueWith;
if (continueWith) {
#if LLVM_VERSION_MAJOR >= 23
auto term = srcblocks.back()->getTerminatorOrNull();
#else
auto term = srcblocks.back()->getTerminator();
#endif
if (term)
if (auto succ = term->getSuccessor(0))
VMap[succ] = continueWith;
}

for (auto bb : srcblocks) {
llvm::Function *F = bb->getParent();
Expand Down
4 changes: 4 additions & 0 deletions gen/passes/GarbageCollect2Stack.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -611,7 +611,11 @@ static bool mayBeUsedAfterRealloc(Instruction *Def, BasicBlock::iterator Alloc,

// All instructions after the starting point in this block have been
// accounted for. Look for successors to add to the work list.
#if LLVM_VERSION_MAJOR >= 23
auto *Term = B->getTerminatorOrNull();
#else
auto *Term = B->getTerminator();
#endif
unsigned SuccCount = Term->getNumSuccessors();
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here (and in other sites) the breaking change for the existing API would have actually made sense, because we don't check for null afterwards, assuming that LLVM trunk introduced an appropriate assertion.

for (unsigned i = 0; i < SuccCount; i++) {
BasicBlock *Succ = Term->getSuccessor(i);
Expand Down
16 changes: 16 additions & 0 deletions gen/trycatchfinally.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,11 @@ llvm::BasicBlock *CleanupScope::run(IRState &irs, llvm::BasicBlock *sourceBlock,

// And convert the BranchInst to the existing branch target to a
// SelectInst so we can append the other cases to it.
#if LLVM_VERSION_MAJOR >= 23
endBlock()->getTerminatorOrNull()->eraseFromParent();
#else
endBlock()->getTerminator()->eraseFromParent();
#endif
llvm::Value *sel =
new llvm::LoadInst(branchSelectorType, branchSelector, "", endBlock());
llvm::SwitchInst::Create(
Expand Down Expand Up @@ -405,7 +409,11 @@ llvm::BasicBlock *CleanupScope::run(IRState &irs, llvm::BasicBlock *sourceBlock,

// We don't know this branch target yet, so add it to the SwitchInst...
llvm::ConstantInt *const selectorVal = DtoConstUint(exitTargets.size());
#if LLVM_VERSION_MAJOR >= 23
llvm::cast<llvm::SwitchInst>(endBlock()->getTerminatorOrNull())
#else
llvm::cast<llvm::SwitchInst>(endBlock()->getTerminator())
#endif
->addCase(selectorVal, continueWith);

// ... insert the store into the source block...
Expand All @@ -428,7 +436,11 @@ llvm::BasicBlock *CleanupScope::runCopying(IRState &irs,
if (isCatchSwitchBlock(beginBlock()))
return continueWith;
if (exitTargets.empty()) {
#if LLVM_VERSION_MAJOR >= 23
if (!endBlock()->getTerminatorOrNull())
#else
if (!endBlock()->getTerminator())
#endif
// Set up the unconditional branch at the end of the cleanup
createBranch(continueWith, endBlock());

Expand Down Expand Up @@ -459,7 +471,11 @@ llvm::BasicBlock *CleanupScope::runCopying(IRState &irs,
// change the continuation target if the initial branch was created
// by another instance with unwinding
if (continueWith)
#if LLVM_VERSION_MAJOR >= 23
if (auto term = endBlock()->getTerminatorOrNull())
#else
if (auto term = endBlock()->getTerminator())
#endif
if (auto succ = term->getSuccessor(0))
if (succ != continueWith)
remapBlocksValue(blocks, succ, continueWith);
Expand Down
Loading