mirror of
https://github.com/RPCS3/llvm.git
synced 2025-01-11 23:16:20 +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:
parent
763e18696f
commit
bee74a3ad4
@ -1916,10 +1916,10 @@ static void WriteMDNodeBodyInternal(raw_ostream &Out, const MDNode *Node,
|
||||
TypePrinting *TypePrinter,
|
||||
SlotTracker *Machine,
|
||||
const Module *Context) {
|
||||
assert(!Node->isTemporary() && "Unexpected forward declaration");
|
||||
|
||||
if (Node->isDistinct())
|
||||
Out << "distinct ";
|
||||
else if (Node->isTemporary())
|
||||
Out << "<temporary!> "; // Handle broken code.
|
||||
|
||||
switch (Node->getMetadataID()) {
|
||||
default:
|
||||
|
@ -251,6 +251,22 @@ TEST_F(MDNodeTest, Print) {
|
||||
EXPECT_EQ(Expected_, Actual_); \
|
||||
} 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) {
|
||||
Constant *C = ConstantInt::get(Type::getInt32Ty(Context), 7);
|
||||
MDString *S = MDString::get(Context, "foo");
|
||||
|
Loading…
x
Reference in New Issue
Block a user