void setOperand(unsigned I, MDNode *New);
StringRef getName() const;
void print(raw_ostream &ROS, bool IsForDebug = false) const;
+ void print(raw_ostream &ROS, ModuleSlotTracker &MST,
+ bool IsForDebug = false) const;
void dump() const;
// ---------------------------------------------------------------------------
W.printNamedMDNode(this);
}
+void NamedMDNode::print(raw_ostream &ROS, ModuleSlotTracker &MST,
+ bool IsForDebug) const {
+ Optional<SlotTracker> LocalST;
+ SlotTracker *SlotTable;
+ if (auto *ST = MST.getMachine())
+ SlotTable = ST;
+ else {
+ LocalST.emplace(getParent());
+ SlotTable = &*LocalST;
+ }
+
+ formatted_raw_ostream OS(ROS);
+ AssemblyWriter W(OS, *SlotTable, getParent(), nullptr, IsForDebug);
+ W.printNamedMDNode(this);
+}
+
void Comdat::print(raw_ostream &ROS, bool /*IsForDebug*/) const {
PrintLLVMName(ROS, getName(), ComdatPrefix);
ROS << " = comdat ";
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Metadata.h"
#include "llvm/IR/Module.h"
+#include "llvm/IR/ModuleSlotTracker.h"
#include "llvm/IR/PassManager.h"
#include "llvm/IR/Statepoint.h"
#include "llvm/Pass.h"
struct VerifierSupport {
raw_ostream *OS;
const Module *M = nullptr;
+ Optional<ModuleSlotTracker> MST;
/// Track the brokenness of the module while recursively visiting.
bool Broken = false;
if (!V)
return;
if (isa<Instruction>(V)) {
- *OS << *V << '\n';
+ V->print(*OS, *MST);
+ *OS << '\n';
} else {
- V->printAsOperand(*OS, true, M);
+ V->printAsOperand(*OS, true, *MST);
*OS << '\n';
}
}
void Write(const Metadata *MD) {
if (!MD)
return;
- MD->print(*OS, M);
+ MD->print(*OS, *MST, M);
*OS << '\n';
}
void Write(const NamedMDNode *NMD) {
if (!NMD)
return;
- NMD->print(*OS);
+ NMD->print(*OS, *MST);
*OS << '\n';
}
void checkAtomicMemAccessSize(const Module *M, Type *Ty,
const Instruction *I);
+
+ void updateModule(const Module *NewM) {
+ if (M == NewM)
+ return;
+ MST.emplace(NewM);
+ M = NewM;
+ }
+
public:
explicit Verifier(raw_ostream *OS)
: VerifierSupport(OS), Context(nullptr), LandingPadResultTy(nullptr),
SawFrameEscape(false) {}
bool verify(const Function &F) {
- M = F.getParent();
+ updateModule(F.getParent());
Context = &M->getContext();
// First ensure the function is well-enough formed to compute dominance
}
bool verify(const Module &M) {
- this->M = &M;
+ updateModule(&M);
Context = &M.getContext();
Broken = false;