From e9f1b74ccc8068ec1033784bdfb1264e55b961ae Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Mon, 15 Oct 2018 10:42:50 +0000 Subject: [PATCH] [TI removal] Make `getTerminator()` return a generic `Instruction`. This removes the primary remaining API producing `TerminatorInst` which will reduce the rate at which code is introduced trying to use it and generally make it much easier to remove the remaining APIs across the codebase. Also clean up some of the stragglers that the previous mechanical update of variables missed. Users of LLVM and out-of-tree code generally will need to update any explicit variable types to handle this. Replacing `TerminatorInst` with `Instruction` (or `auto`) almost always works. Most of these edits were made in prior commits using the perl one-liner: ``` perl -i -ple 's/TerminatorInst(\b.* = .*getTerminator\(\))/Instruction\1/g' ``` This also my break some rare use cases where people overload for both `Instruction` and `TerminatorInst`, but these should be easily fixed by removing the `TerminatorInst` overload. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@344504 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/CGCleanup.cpp | 4 ++-- lib/CodeGen/CGException.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/CodeGen/CGCleanup.cpp b/lib/CodeGen/CGCleanup.cpp index 0a766d1762..3743d24f11 100644 --- a/lib/CodeGen/CGCleanup.cpp +++ b/lib/CodeGen/CGCleanup.cpp @@ -366,7 +366,7 @@ static llvm::SwitchInst *TransitionToCleanupSwitch(CodeGenFunction &CGF, llvm::BasicBlock *Block) { // If it's a branch, turn it into a switch whose default // destination is its original target. - llvm::TerminatorInst *Term = Block->getTerminator(); + llvm::Instruction *Term = Block->getTerminator(); assert(Term && "can't transition block without terminator"); if (llvm::BranchInst *Br = dyn_cast(Term)) { @@ -589,7 +589,7 @@ static void ForwardPrebranchedFallthrough(llvm::BasicBlock *Exit, llvm::BasicBlock *To) { // Exit is the exit block of a cleanup, so it always terminates in // an unconditional branch or a switch. - llvm::TerminatorInst *Term = Exit->getTerminator(); + llvm::Instruction *Term = Exit->getTerminator(); if (llvm::BranchInst *Br = dyn_cast(Term)) { assert(Br->isUnconditional() && Br->getSuccessor(0) == From); diff --git a/lib/CodeGen/CGException.cpp b/lib/CodeGen/CGException.cpp index 4ee835259a..3297bb319d 100644 --- a/lib/CodeGen/CGException.cpp +++ b/lib/CodeGen/CGException.cpp @@ -1248,7 +1248,7 @@ void CodeGenFunction::ExitCXXTryStmt(const CXXTryStmt &S, bool IsFnTryBlock) { // we follow the false destination for each of the cond branches to reach // the rethrow block. llvm::BasicBlock *RethrowBlock = WasmCatchStartBlock; - while (llvm::TerminatorInst *TI = RethrowBlock->getTerminator()) { + while (llvm::Instruction *TI = RethrowBlock->getTerminator()) { auto *BI = cast(TI); assert(BI->isConditional()); RethrowBlock = BI->getSuccessor(1); -- 2.40.0