#include "llvm/SandboxIR/BasicBlock.h"
#include "llvm/SandboxIR/Context.h"
#include "llvm/SandboxIR/Function.h"
#include "llvm/SandboxIR/Instruction.h"
namespace llvm::sandboxir {
BBIterator &BBIterator::operator++() { … }
BBIterator &BBIterator::operator--() { … }
BasicBlock *BBIterator::getNodeParent() const { … }
BasicBlock::iterator::pointer
BasicBlock::iterator::getInstr(llvm::BasicBlock::iterator It) const { … }
Function *BasicBlock::getParent() const { … }
void BasicBlock::buildBasicBlockFromLLVMIR(llvm::BasicBlock *LLVMBB) { … }
BasicBlock::iterator BasicBlock::begin() const { … }
Instruction *BasicBlock::getTerminator() const { … }
Instruction &BasicBlock::front() const { … }
Instruction &BasicBlock::back() const { … }
#ifndef NDEBUG
void BasicBlock::dumpOS(raw_ostream &OS) const {
llvm::BasicBlock *BB = cast<llvm::BasicBlock>(Val);
const auto &Name = BB->getName();
OS << Name;
if (!Name.empty())
OS << ":\n";
if (any_of(*BB, [this](llvm::Instruction &I) {
return Ctx.getValue(&I) == nullptr;
})) {
OS << "<Crash-proof mode!>\n";
DenseSet<Instruction *> Visited;
for (llvm::Instruction &IRef : *BB) {
Value *SBV = Ctx.getValue(&IRef);
if (SBV == nullptr)
OS << IRef << " *** No SandboxIR ***\n";
else {
auto *SBI = dyn_cast<Instruction>(SBV);
if (SBI == nullptr) {
OS << IRef << " *** Not a SBInstruction!!! ***\n";
} else {
if (Visited.insert(SBI).second)
OS << *SBI << "\n";
}
}
}
} else {
for (auto &SBI : *this) {
SBI.dumpOS(OS);
OS << "\n";
}
}
}
void BasicBlock::verify() const {
assert(isa<llvm::BasicBlock>(Val) && "Expected BasicBlock!");
for (const auto &I : *this) {
I.verify();
}
}
#endif
}