#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Analysis/AssumptionCache.h"
#include "llvm/Analysis/BasicAliasAnalysis.h"
#include "llvm/Analysis/BlockFrequencyInfo.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/CFG.h"
#include "llvm/Analysis/DomTreeUpdater.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/PostDominators.h"
#include "llvm/Analysis/TargetLibraryInfo.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/Dominators.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Support/SourceMgr.h"
#include "gtest/gtest.h"
usingnamespacellvm;
static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { … }
static BasicBlock *getBasicBlockByName(Function &F, StringRef Name) { … }
TEST(BasicBlockUtils, EliminateUnreachableBlocks) { … }
TEST(BasicBlockUtils, SplitEdge_ex1) { … }
TEST(BasicBlockUtils, SplitEdge_ex2) { … }
TEST(BasicBlockUtils, SplitEdge_ex3) { … }
TEST(BasicBlockUtils, SplitEdge_ex4) { … }
TEST(BasicBlockUtils, splitBasicBlockBefore_ex1) { … }
#ifndef NDEBUG
TEST(BasicBlockUtils, splitBasicBlockBefore_ex2) {
LLVMContext C;
std::unique_ptr<Module> M = parseIR(C, R"IR(
define void @foo() {
bb0:
%0 = mul i32 1, 2
br label %bb2
bb1:
br label %bb2
bb2:
%1 = phi i32 [ %0, %bb0 ], [ 1, %bb1 ]
br label %bb3
bb3:
ret void
}
)IR");
Function *F = M->getFunction("foo");
DominatorTree DT(*F);
BasicBlock *DestBlock = getBasicBlockByName(*F, "bb2");
ASSERT_DEATH(
{
DestBlock->splitBasicBlockBefore(DestBlock->front().getIterator(),
"test");
},
"cannot split on multi incoming phis");
}
#endif
TEST(BasicBlockUtils, NoUnreachableBlocksToEliminate) { … }
TEST(BasicBlockUtils, SplitBlockPredecessors) { … }
TEST(BasicBlockUtils, SplitCriticalEdge) { … }
TEST(BasicBlockUtils, SplitIndirectBrCriticalEdgesIgnorePHIs) { … }
TEST(BasicBlockUtils, SplitIndirectBrCriticalEdges) { … }
TEST(BasicBlockUtils, SetEdgeProbability) { … }
TEST(BasicBlockUtils, IsPresplitCoroSuspendExitTest) { … }