@@ -601,31 +601,41 @@ class SILPrinter : public SILInstructionVisitor<SILPrinter> {
601601 if (BB->args_empty ())
602602 return ;
603603
604- for (SILValue V : BB->getArguments ()) {
605- if (V->use_empty ())
606- continue ;
607- *this << " // " << Ctx.getID (V);
608- PrintState.OS .PadToColumn (50 );
609- *this << " // user" ;
610- if (std::next (V->use_begin ()) != V->use_end ())
611- *this << ' s' ;
612- *this << " : " ;
604+ for (SILArgument *arg : BB->getArguments ()) {
605+ StringRef name;
606+ if (arg->getDecl () && arg->getDecl ()->hasName ())
607+ name = arg->getDecl ()->getBaseName ().userFacingName ();
613608
614- llvm::SmallVector<ID, 32 > UserIDs;
615- for (auto *Op : V->getUses ())
616- UserIDs.push_back (Ctx.getID (Op->getUser ()));
609+ if (arg->use_empty () && name.empty ())
610+ continue ;
617611
618- // Display the user ids sorted to give a stable use order in the
619- // printer's output if we are asked to do so. This makes diffing large
620- // sections of SIL significantly easier at the expense of not showing
621- // the _TRUE_ order of the users in the use list.
622- if (Ctx.sortSIL ()) {
623- std::sort (UserIDs.begin (), UserIDs.end ());
612+ *this << " // " << Ctx.getID (arg);
613+ if (!name.empty ()) {
614+ *this << " \" " << name << ' \" ' ;
624615 }
616+ if (!arg->use_empty ()) {
617+ PrintState.OS .PadToColumn (50 );
618+ *this << " // user" ;
619+ if (std::next (arg->use_begin ()) != arg->use_end ())
620+ *this << ' s' ;
621+ *this << " : " ;
622+
623+ llvm::SmallVector<ID, 32 > UserIDs;
624+ for (auto *Op : arg->getUses ())
625+ UserIDs.push_back (Ctx.getID (Op->getUser ()));
626+
627+ // Display the user ids sorted to give a stable use order in the
628+ // printer's output if we are asked to do so. This makes diffing large
629+ // sections of SIL significantly easier at the expense of not showing
630+ // the _TRUE_ order of the users in the use list.
631+ if (Ctx.sortSIL ()) {
632+ std::sort (UserIDs.begin (), UserIDs.end ());
633+ }
625634
626- interleave (UserIDs.begin (), UserIDs.end (),
627- [&] (ID id) { *this << id; },
628- [&] { *this << " , " ; });
635+ interleave (UserIDs.begin (), UserIDs.end (),
636+ [&] (ID id) { *this << id; },
637+ [&] { *this << " , " ; });
638+ }
629639 *this << ' \n ' ;
630640 }
631641 }
0 commit comments