[DebugInfo] Add DIArgList MD to store multple values in DbgVariableIn… · llvm/llvm-project@65600cb (original) (raw)

`@@ -1239,8 +1239,9 @@ void SlotTracker::CreateFunctionSlot(const Value *V) {

`

1239

1239

`void SlotTracker::CreateMetadataSlot(const MDNode *N) {

`

1240

1240

` assert(N && "Can't insert a null Value into SlotTracker!");

`

1241

1241

``

1242

``

`-

// Don't make slots for DIExpressions. We just print them inline everywhere.

`

1243

``

`-

if (isa(N))

`

``

1242

`+

// Don't make slots for DIExpressions or DIArgLists. We just print them inline

`

``

1243

`+

// everywhere.

`

``

1244

`+

if (isa(N) || isa(N))

`

1244

1245

` return;

`

1245

1246

``

1246

1247

` unsigned DestSlot = mdnNext;

`

`@@ -2351,6 +2352,21 @@ static void writeDIExpression(raw_ostream &Out, const DIExpression *N,

`

2351

2352

` Out << ")";

`

2352

2353

`}

`

2353

2354

``

``

2355

`+

static void writeDIArgList(raw_ostream &Out, const DIArgList *N,

`

``

2356

`+

TypePrinting *TypePrinter, SlotTracker *Machine,

`

``

2357

`+

const Module *Context, bool FromValue = false) {

`

``

2358

`+

assert(FromValue &&

`

``

2359

`+

"Unexpected DIArgList metadata outside of value argument");

`

``

2360

`+

Out << "!DIArgList(";

`

``

2361

`+

FieldSeparator FS;

`

``

2362

`+

MDFieldPrinter Printer(Out, TypePrinter, Machine, Context);

`

``

2363

`+

for (Metadata *Arg : N->getArgs()) {

`

``

2364

`+

Out << FS;

`

``

2365

`+

WriteAsOperandInternal(Out, Arg, TypePrinter, Machine, Context, true);

`

``

2366

`+

}

`

``

2367

`+

Out << ")";

`

``

2368

`+

}

`

``

2369

+

2354

2370

`static void writeDIGlobalVariableExpression(raw_ostream &Out,

`

2355

2371

` const DIGlobalVariableExpression *N,

`

2356

2372

` TypePrinting *TypePrinter,

`

`@@ -2496,12 +2512,16 @@ static void WriteAsOperandInternal(raw_ostream &Out, const Metadata *MD,

`

2496

2512

` TypePrinting *TypePrinter,

`

2497

2513

` SlotTracker *Machine, const Module *Context,

`

2498

2514

` bool FromValue) {

`

2499

``

`-

// Write DIExpressions inline when used as a value. Improves readability of

`

2500

``

`-

// debug info intrinsics.

`

``

2515

`+

// Write DIExpressions and DIArgLists inline when used as a value. Improves

`

``

2516

`+

// readability of debug info intrinsics.

`

2501

2517

` if (const DIExpression *Expr = dyn_cast(MD)) {

`

2502

2518

` writeDIExpression(Out, Expr, TypePrinter, Machine, Context);

`

2503

2519

` return;

`

2504

2520

` }

`

``

2521

`+

if (const DIArgList *ArgList = dyn_cast(MD)) {

`

``

2522

`+

writeDIArgList(Out, ArgList, TypePrinter, Machine, Context, FromValue);

`

``

2523

`+

return;

`

``

2524

`+

}

`

2505

2525

``

2506

2526

` if (const MDNode *N = dyn_cast(MD)) {

`

2507

2527

` std::unique_ptr MachineStorage;

`

`@@ -3427,6 +3447,8 @@ void AssemblyWriter::printNamedMDNode(const NamedMDNode *NMD) {

`

3427

3447

` // Write DIExpressions inline.

`

3428

3448

` // FIXME: Ban DIExpressions in NamedMDNodes, they will serve no purpose.

`

3429

3449

` MDNode *Op = NMD->getOperand(i);

`

``

3450

`+

assert(!isa(Op) &&

`

``

3451

`+

"DIArgLists should not appear in NamedMDNodes");

`

3430

3452

` if (auto *Expr = dyn_cast(Op)) {

`

3431

3453

` writeDIExpression(Out, Expr, nullptr, nullptr, nullptr);

`

3432

3454

` continue;

`

`@@ -4697,7 +4719,7 @@ static void printMetadataImpl(raw_ostream &ROS, const Metadata &MD,

`

4697

4719

` /* FromValue */ true);

`

4698

4720

``

4699

4721

` auto *N = dyn_cast(&MD);

`

4700

``

`-

if (OnlyAsOperand || !N || isa(MD))

`

``

4722

`+

if (OnlyAsOperand || !N || isa(MD) || isa(MD))

`

4701

4723

` return;

`

4702

4724

``

4703

4725

` OS << " = ";

`