mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-30 02:25:19 +00:00
AsmWriter: Handle broken metadata nodes
Print out temporary `MDNode`s so we don't crash in the verifier (or during `dump()` output). git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@232417 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -1916,10 +1916,10 @@ static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
|
|||||||
TypePrinting *TypePrinter,
|
TypePrinting *TypePrinter,
|
||||||
SlotTracker *Machine,
|
SlotTracker *Machine,
|
||||||
const Module *Context) {
|
const Module *Context) {
|
||||||
assert(!Node->isTemporary() && "Unexpected forward declaration");
|
|
||||||
|
|
||||||
if (Node->isDistinct())
|
if (Node->isDistinct())
|
||||||
Out << "distinct ";
|
Out << "distinct ";
|
||||||
|
else if (Node->isTemporary())
|
||||||
|
Out << "<temporary!> "; // Handle broken code.
|
||||||
|
|
||||||
switch (Node->getMetadataID()) {
|
switch (Node->getMetadataID()) {
|
||||||
default:
|
default:
|
||||||
|
@@ -251,6 +251,22 @@ TEST_F(MDNodeTest, Print) {
|
|||||||
EXPECT_EQ(Expected_, Actual_); \
|
EXPECT_EQ(Expected_, Actual_); \
|
||||||
} while (false)
|
} while (false)
|
||||||
|
|
||||||
|
TEST_F(MDNodeTest, PrintTemporary) {
|
||||||
|
MDNode *Arg = getNode();
|
||||||
|
TempMDNode Temp = MDNode::getTemporary(Context, Arg);
|
||||||
|
MDNode *N = getNode(Temp.get());
|
||||||
|
Module M("test", Context);
|
||||||
|
NamedMDNode *NMD = M.getOrInsertNamedMetadata("named");
|
||||||
|
NMD->addOperand(N);
|
||||||
|
|
||||||
|
EXPECT_PRINTER_EQ("!0 = !{!1}", N->print(OS, &M));
|
||||||
|
EXPECT_PRINTER_EQ("!1 = <temporary!> !{!2}", Temp->print(OS, &M));
|
||||||
|
EXPECT_PRINTER_EQ("!2 = !{}", Arg->print(OS, &M));
|
||||||
|
|
||||||
|
// Cleanup.
|
||||||
|
Temp->replaceAllUsesWith(Arg);
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(MDNodeTest, PrintFromModule) {
|
TEST_F(MDNodeTest, PrintFromModule) {
|
||||||
Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 7);
|
Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 7);
|
||||||
MDString *S = MDString::get(Context, "foo");
|
MDString *S = MDString::get(Context, "foo");
|
||||||
|
Reference in New Issue
Block a user