#include "llvm/IR/BasicBlock.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/AsmParser/Parser.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IRBuilder.h"
#include "llvm/IR/Instructions.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/NoFolder.h"
#include "llvm/IR/Verifier.h"
#include "llvm/Support/SourceMgr.h"
#include "gmock/gmock-matchers.h"
#include "gtest/gtest.h"
#include <memory>
namespace llvm {
namespace {
TEST(BasicBlockTest, PhiRange) { … }
#define CHECK_ITERATORS(Range1, Range2) …
TEST(BasicBlockTest, TestInstructionsWithoutDebug) { … }
TEST(BasicBlockTest, ComesBefore) { … }
class InstrOrderInvalidationTest : public ::testing::Test { … };
TEST_F(InstrOrderInvalidationTest, InsertInvalidation) { … }
TEST_F(InstrOrderInvalidationTest, SpliceInvalidation) { … }
TEST_F(InstrOrderInvalidationTest, RemoveNoInvalidation) { … }
TEST_F(InstrOrderInvalidationTest, EraseNoInvalidation) { … }
static std::unique_ptr<Module> parseIR(LLVMContext &C, const char *IR) { … }
TEST(BasicBlockTest, SpliceFromBB) { … }
TEST(BasicBlockTest, SpliceOneInstr) { … }
TEST(BasicBlockTest, SpliceOneInstrWhenFromIsSameAsTo) { … }
TEST(BasicBlockTest, SpliceLastInstr) { … }
TEST(BasicBlockTest, SpliceInstrRange) { … }
#ifdef EXPENSIVE_CHECKS
TEST(BasicBlockTest, SpliceEndBeforeBegin) {
LLVMContext Ctx;
std::unique_ptr<Module> M = parseIR(Ctx, R"(
define void @f(i32 %a) {
from:
%fromInstr1 = add i32 %a, %a
%fromInstr2 = sub i32 %a, %a
br label %to
to:
%toInstr1 = mul i32 %a, %a
%toInstr2 = sdiv i32 %a, %a
ret void
}
)");
Function *F = &*M->begin();
auto BBIt = F->begin();
BasicBlock *FromBB = &*BBIt++;
BasicBlock *ToBB = &*BBIt++;
auto FromBBIt = FromBB->begin();
Instruction *FromI1 = &*FromBBIt++;
Instruction *FromI2 = &*FromBBIt++;
auto ToBBIt = ToBB->begin();
Instruction *ToI2 = &*ToBBIt++;
EXPECT_DEATH(ToBB->splice(ToI2->getIterator(), FromBB, FromI2->getIterator(),
FromI1->getIterator()),
"FromBeginIt not before FromEndIt!");
}
#endif
TEST(BasicBlockTest, EraseRange) { … }
TEST(BasicBlockTest, DiscardValueNames) { … }
TEST(BasicBlockTest, DiscardValueNames2) { … }
}
}