LLVM: lib/DebugInfo/LogicalView/Core/LVScope.cpp Source File (original) (raw)

1

2

3

4

5

6

7

8

9

10

11

12

21

22using namespace llvm;

24

25#define DEBUG_TYPE "Scope"

26

27namespace {

28const char *const KindArray = "Array";

29const char *const KindBlock = "Block";

30const char *const KindCallSite = "CallSite";

31const char *const KindClass = "Class";

32const char *const KindCompileUnit = "CompileUnit";

33const char *const KindEnumeration = "Enumeration";

34const char *const KindFile = "File";

35const char *const KindFunction = "Function";

36const char *const KindInlinedFunction = "InlinedFunction";

37const char *const KindNamespace = "Namespace";

38const char *const KindStruct = "Struct";

39const char *const KindTemplateAlias = "TemplateAlias";

40const char *const KindTemplatePack = "TemplatePack";

41const char *const KindUndefined = "Undefined";

42const char *const KindUnion = "Union";

43}

44

45

46

47

48

50 const char *Kind = KindUndefined;

51 if (getIsArray())

52 Kind = KindArray;

53 else if (getIsBlock())

54 Kind = KindBlock;

55 else if (getIsCallSite())

56 Kind = KindCallSite;

57 else if (getIsCompileUnit())

58 Kind = KindCompileUnit;

59 else if (getIsEnumeration())

60 Kind = KindEnumeration;

61 else if (getIsInlinedFunction())

62 Kind = KindInlinedFunction;

63 else if (getIsNamespace())

64 Kind = KindNamespace;

65 else if (getIsTemplatePack())

66 Kind = KindTemplatePack;

67 else if (getIsRoot())

68 Kind = KindFile;

69 else if (getIsTemplateAlias())

70 Kind = KindTemplateAlias;

71 else if (getIsClass())

72 Kind = KindClass;

73 else if (getIsFunction())

74 Kind = KindFunction;

75 else if (getIsStructure())

76 Kind = KindStruct;

77 else if (getIsUnion())

78 Kind = KindUnion;

80}

81

105

108 Children = std::make_unique();

110}

111

114 if (Element->getIsType())

116 else if (Element->getIsScope())

118 else if (Element->getIsSymbol())

120 else if (Element->getIsLine())

122 else

124}

125

126

129 assert(Line->getParent() && "Line already inserted");

131 Lines = std::make_unique();

132

133

135 Line->setParent(this);

136

137

139

140

141

142

143

144

145

146

147 traverseParents(&LVScope::getHasLines, &LVScope::setHasLines);

148}

149

150

153 assert(Location->getParent() && "Location already inserted");

155 Ranges = std::make_unique();

156

157

160

162 setHasRanges();

163}

164

165

170 Scopes = std::make_unique();

171

172

176

177

179

180

181

182

183 if (Scope->getIsGlobalReference())

184 traverseParents(&LVScope::getHasGlobals, &LVScope::setHasGlobals);

185 else

186 traverseParents(&LVScope::getHasLocals, &LVScope::setHasLocals);

187

188

189 traverseParents(&LVScope::getHasScopes, &LVScope::setHasScopes);

190}

191

192

197 Symbols = std::make_unique();

198

199

203

204

206

207

208

209

210 if (Symbol->getIsGlobalReference())

211 traverseParents(&LVScope::getHasGlobals, &LVScope::setHasGlobals);

212 else

213 traverseParents(&LVScope::getHasLocals, &LVScope::setHasLocals);

214

215

216 traverseParents(&LVScope::getHasSymbols, &LVScope::setHasSymbols);

217}

218

219

222 assert(Type->getParent() && "Type already inserted");

224 Types = std::make_unique();

225

226

229 Type->setParent(this);

230

231

233

234

235

236

237 if (Type->getIsGlobalReference())

238 traverseParents(&LVScope::getHasGlobals, &LVScope::setHasGlobals);

239 else

240 traverseParents(&LVScope::getHasLocals, &LVScope::setHasLocals);

241

242

243 traverseParents(&LVScope::getHasTypes, &LVScope::setHasTypes);

244}

245

246

248

250 Location->setLowerAddress(LowerAddress);

251 Location->setUpperAddress(UpperAddress);

252 Location->setIsAddressRange();

253

255}

256

260 };

261 auto RemoveElement = [Element, Predicate](auto &Container) -> bool {

262 auto Iter = std::remove_if(Container->begin(), Container->end(), Predicate);

263 if (Iter != Container->end()) {

264 Container->erase(Iter, Container->end());

266 return true;

267 }

268 return false;

269 };

270

271

272

273 if (Element->getIsLine())

274 return RemoveElement(Lines);

275

276 if (RemoveElement(Children)) {

277 if (Element->getIsSymbol())

278 return RemoveElement(Symbols);

279 if (Element->getIsType())

280 return RemoveElement(Types);

281 if (Element->getIsScope())

282 return RemoveElement(Scopes);

284 }

285

286 return false;

287}

288

290 setAddedMissing();

292 return;

293

294

296 if (!ReferenceSymbols)

297 return;

298

300 References.append(ReferenceSymbols->begin(), ReferenceSymbols->end());

301

302

303

306 if (Symbol->getHasReferenceAbstract())

308

309

310

311 if (References.size()) {

313 dbgs() << "Insert Missing Inlined Elements\n"

316 << "\n";

317 });

321 << "\n";

322 });

323

324

325

326

330 Symbol->setIsOptimized();

332

333

335 Symbol->setIsConstant();

336 else if (Reference->getIsParameter())

337 Symbol->setIsParameter();

338 else if (Reference->getIsVariable())

339 Symbol->setIsVariable();

340 else

342 }

343 }

344}

345

347

348

350

351

355

356

359 Line->updateLevel(this, Moved);

360}

361

363 if (getIsResolved())

364 return;

365

366

368

369

372 if (getIsGlobalReference())

373

374 Element->setIsGlobalReference();

376 }

377}

378

380 if (getIsResolvedName())

381 return;

382 setIsResolvedName();

383

384

385

386 if (getIsTemplate())

388 else {

392 }

393 }

394

395

396

397

399 if (getIsArtificial())

401 else

403 }

404

406

407

409}

410

412

413

414

415

416

417

418

419

420

421

425

427 }

428

429

431

432

435}

436

438

440 return;

441

446

448 }

449}

450

452

453

454 if (getHasReference() && isNamed())

456

458}

459

460

462

463

464

467 if (Type->getIsTemplateParam()) {

468 Type->resolve();

470 }

471

472 return !Params.empty();

473}

474

475

477 if (getIsTemplateResolved())

478 return;

479 setIsTemplateResolved();

480

481

482 if (options().getAttributeEncoded()) {

485 std::string EncodedArgs;

486

487

490 }

491 }

492}

493

494

496 if (getIsRoot() || getIsCompileUnit())

497 return;

498

504}

505

506

508

509

510

511

512

513

514

515

516

517

518

519

520 std::string BaseName;

522 if (getIsTemplateResolved())

523 Name.append(BaseName);

524}

525

528

529 Name.append("<");

530

531

533 bool AddComma = false;

535 if (AddComma)

536 Name.append(", ");

537 Type->encodeTemplateArgument(Name);

538 AddComma = true;

539 }

540 }

541

542 Name.append(">");

543}

544

545bool LVScope::resolvePrinting() const {

546

547

548

549 if (options().getPrintWarnings() && (getIsRoot() || getIsCompileUnit()))

550 return true;

551

552

553

554

555 if (options().getSelectExecute()) {

556 return getIsRoot() || getIsCompileUnit() || getHasPattern();

557 }

558

559 bool Globals = options().getAttributeGlobal();

560 bool Locals = options().getAttributeLocal();

561 if ((Globals && Locals) || (!Globals && !Locals)) {

562

563 } else {

564

565 if ((Globals && !(getHasGlobals() || getIsGlobalReference())) ||

566 (Locals && !(getHasLocals() || !getIsGlobalReference())))

567 return false;

568 }

569

570

571 if (getIsFunction() && getIsArtificial() &&

572 options().getAttributeGenerated())

573 return false;

574

575 return true;

576}

577

579 bool Full) const {

580

581

583

584

585 if (getIsSystem() && options().getAttributeSystem())

587

588

589

590 if (getIsCompileUnit()) {

593 std::string ScopeName(getName());

594 if (std::error_code EC =

597 ScopeName.c_str());

599 }

600 }

601

602

603 bool DoPrint = (options().getAttributeDiscarded()) ? true : !getIsDiscarded();

604

605

606

607

608

609 if (DoPrint) {

610 DoPrint =

611 getIsInCompare() ? options().getReportExecute() : resolvePrinting();

612 }

613

614

615

616

617 DoPrint = DoPrint && (Print || options().getOutputSplit());

618

619 if (DoPrint) {

620

622

623

624

625 if ((getIsRoot() || options().getPrintAnyElement()) &&

626 options().getPrintFormatting() &&

628

632 continue;

635 return Err;

636 }

637

638

641 if (Match && Line->getHasPattern())

642 continue;

645 return Err;

646 }

647

648

649 if (options().getPrintWarnings())

651 }

652 }

653

654

655

656 if (getIsCompileUnit()) {

657 if (options().getPrintSummary())

659 if (options().getPrintSizes())

664 }

665 }

666

667 if (getIsRoot() && options().getPrintWarnings()) {

669 }

670

672}

673

675

677 if (SortFunction) {

680 auto Traverse = [&](auto &Set, LVSortFunction SortFunction) {

681 if (Set)

682 std::stable_sort(Set->begin(), Set->end(), SortFunction);

683 };

684 Traverse(Parent->Types, SortFunction);

685 Traverse(Parent->Symbols, SortFunction);

686 Traverse(Parent->Scopes, SortFunction);

688 Traverse(Parent->Children, SortFunction);

689

692 Sort(Scope, SortFunction);

693 };

694

695

696 Sort(this, SortFunction);

697 }

698}

699

702

704 while (Parent) {

705

706 if ((Parent->*GetFunction)())

707 break;

708 (Parent->*SetFunction)();

710 }

711}

712

715 if (options().getReportParents()) {

716

718 while (Parent) {

719

720 if ((Parent->*GetFunction)())

721 break;

722 (Parent->*SetFunction)();

724 }

725 }

726

728 auto Traverse = [&](const auto *Set) {

729 if (Set)

730 for (const auto &Entry : *Set)

731 (Entry->*SetFunction)();

732 };

733

734 (Scope->*SetFunction)();

735

739

742 TraverseChildren(Scope);

743 };

744

745 if (options().getReportChildren())

746 TraverseChildren(this);

747}

748

749

750

751

752

755

762}

763

764

765

766

767

770

771 if (getIsDiscarded())

772 return;

773

774

777

778 if (!(Location->*ValidLocation)() && RecordInvalid)

780 }

781

782

783 calculateCoverage();

784 }

785

786

789 Scope->getRanges(LocationList, ValidLocation, RecordInvalid);

790}

791

792

794

795 if (getIsDiscarded())

796 return;

797

803}

804

807 while (Parent) {

809 if (ParentRanges)

812 return Parent;

814 }

815 return Parent;

816}

817

819 if (!Targets)

820 return nullptr;

821

822

823

824

829

831 if (!Candidates.empty()) {

832 dbgs() << "\n[LVScope::findIn]\n"

833 << "Reference: "

834 << "Offset = " << hexSquareString(getOffset()) << ", "

835 << "Level = " << getLevel() << ", "

836 << "Kind = " << formattedKind(kind()) << ", "

837 << "Name = " << formattedName(getName()) << "\n";

838 for (const LVScope *Candidate : Candidates)

839 dbgs() << "Candidate: "

840 << "Offset = " << hexSquareString(Candidate->getOffset()) << ", "

841 << "Level = " << Candidate->getLevel() << ", "

842 << "Kind = " << formattedKind(Candidate->kind()) << ", "

843 << "Name = " << formattedName(Candidate->getName()) << "\n";

844 }

845 });

846

847 if (!Candidates.empty())

848 return (Candidates.size() == 1)

849 ? (equals(Candidates[0]) ? Candidates[0] : nullptr)

851

852 return nullptr;

853}

854

856

857

858 return !(

860 (options().getCompareSymbols() &&

864}

865

867 auto SetCompareState = [&](auto &Container) {

868 if (Container)

869 for (auto *Entry : *Container)

870 Entry->setIsInCompare();

871 };

872 SetCompareState(Types);

873 SetCompareState(Symbols);

874 SetCompareState(Lines);

875 SetCompareState(Scopes);

876

877

878

887 TraverseChildren);

888}

889

892 bool TraverseChildren) {

893 if (!(References && Targets))

894 return;

895

897 dbgs() << "\n[LVScope::markMissingParents]\n";

899 dbgs() << "References: "

901 << "Level = " << Reference->getLevel() << ", "

905 dbgs() << "Targets : "

907 << "Level = " << Target->getLevel() << ", "

910 });

911

913

915 continue;

916

918 dbgs() << "\nSearch Reference: "

921 });

925 dbgs() << "\nFound Target: "

928 });

929 if (TraverseChildren)

931 } else {

933 dbgs() << "Missing Reference: "

936 });

937 Reference->markBranchAsMissing();

938 }

939 }

940}

941

944 return false;

945

946 if (getIsLexicalBlock() && Scope->getIsLexicalBlock())

948 return true;

949}

950

952 assert(Scopes && "Scopes must not be nullptr");

956 return nullptr;

957}

958

960 if (!References && !Targets)

961 return true;

962 if (References && Targets && References->size() == Targets->size()) {

965 return false;

966 return true;

967 }

968 return false;

969}

970

977

982}

983

985 if (options().getPrintFormatting() && options().getAttributeRange() &&

989 }

990}

991

993 if (options().getPrintFormatting() && options().getAttributeEncoded())

995 getEncodedArgs(), false, false);

996}

997

999 if (getIncludeInPrint() && getReader().doPrintScope(this)) {

1000

1001

1002 if (!(getIsRoot() || (getIsCompileUnit() && options().getSelectExecute())))

1006 }

1007}

1008

1011

1012 if (!getIsBlock()) {

1014 if (!getIsAggregate())

1017 }

1018 OS << "\n";

1019

1020

1021 if (Full && getIsBlock())

1023}

1024

1025

1026

1027

1030 return false;

1031

1033 return false;

1034

1035

1037 return false;

1038

1040

1042 return false;

1043

1044 return true;

1045}

1046

1048 assert(Scopes && "Scopes must not be nullptr");

1052 return nullptr;

1053}

1054

1058 if (getIsTemplateResolved())

1063 }

1064}

1065

1066

1067

1068

1071 return false;

1073}

1074

1079}

1080

1081

1082

1083

1085

1086

1087

1088 if (getIsArrayResolved())

1089 return;

1090 setIsArrayResolved();

1091

1092

1093

1094

1095

1096

1097

1098

1099

1100

1101

1102

1103

1104

1105

1106

1107

1108

1109

1113 if (Type->getIsSubrange()) {

1114 Type->resolve();

1116 }

1117

1118

1119

1123 }

1124

1125

1126 std::stringstream ArrayInfo;

1129

1130 for (const LVType *Type : Subranges) {

1131 if (Type->getIsSubrangeCount())

1132

1133 ArrayInfo << "[" << Type->getCount() << "]";

1134 else {

1135

1136 unsigned LowerBound;

1137 unsigned UpperBound;

1138 std::tie(LowerBound, UpperBound) = Type->getBounds();

1139

1140

1141

1142

1143

1144 if (LowerBound)

1145 ArrayInfo << "[" << LowerBound << ".." << UpperBound << "]";

1146 else

1147 ArrayInfo << "[" << UpperBound + 1 << "]";

1148 }

1149 }

1150

1151

1152 setName(ArrayInfo.str());

1153}

1154

1157 return false;

1158

1160 return false;

1161

1162

1163

1165 return false;

1166

1167 return true;

1168}

1169

1173}

1174

1175

1176

1177

1182 "CU [0x%08" PRIx64 "], Scope [0x%08" PRIx64 "], Range [0x%08" PRIx64

1183 ":0x%08" PRIx64 "], Size = %" PRId64 "\n",

1185 });

1186

1187

1188

1191 if (this == Scope)

1192

1193 CUContributionSize = Size;

1194}

1195

1196

1198

1199

1200

1201

1202 if (options().getSelectExecute())

1203 return;

1204

1205 if (MatchedScopes.size()) {

1208 &LVScope::setHasPattern);

1209 } else {

1210

1211

1212 setHasPattern();

1213 }

1214}

1215

1218 if (options().getAttributeRange()) {

1219

1221 bool RecordInvalid = options().getWarningRanges();

1223

1224

1225 if (RecordInvalid)

1228 }

1229

1230 if (options().getAttributeLocation()) {

1231

1233 bool RecordInvalid = options().getWarningLocations();

1235

1236

1237 if (RecordInvalid)

1240 }

1241}

1242

1245 SectionMappings.add(SectionIndex, Address, Line);

1246}

1247

1251 LVAddressToLine *Map = SectionMappings.findMap(SectionIndex);

1252 if (!Map || Map->empty())

1253 return nullptr;

1254 LVAddressToLine::const_iterator Iter = Map->lower_bound(Address);

1255 return (Iter != Map->end()) ? Iter->second : nullptr;

1256}

1257

1261 LVAddressToLine *Map = SectionMappings.findMap(SectionIndex);

1262 if (!Map || Map->empty())

1263 return nullptr;

1264 LVAddressToLine::const_iterator Iter = Map->upper_bound(Address);

1265 if (Iter != Map->begin())

1266 Iter = std::prev(Iter);

1267 return Iter->second;

1268}

1269

1271

1275 LVLine *LowLine = lineLowerBound(Location->getLowerAddress(), Parent);

1276 LVLine *HighLine = lineUpperBound(Location->getUpperAddress(), Parent);

1278}

1279

1281 if (Index <= 0 || Index > Filenames.size())

1284}

1285

1288 return false;

1289

1291}

1292

1295}

1298}

1301}

1304}

1305

1306

1308 if (Line->getIncludeInPrint())

1309 ++Allocated.Lines;

1310}

1312 if (Scope->getIncludeInPrint())

1314}

1316 if (Symbol->getIncludeInPrint())

1318}

1320 if (Type->getIncludeInPrint())

1321 ++Allocated.Types;

1322}

1323

1324

1325

1326

1330}

1334}

1338}

1342}

1343

1344

1346 addItem<LVTagOffsetsMap, dwarf::Tag, LVOffset>(&DebugTags, Target, Offset);

1347}

1348

1349

1351 if (WarningOffsets.find(Offset) == WarningOffsets.end())

1353}

1354

1355

1358 if (InvalidCoverages.find(Offset) == InvalidCoverages.end())

1360}

1361

1362

1364 addInvalidLocationOrRange(Location, Location->getParentSymbol(),

1365 &InvalidLocations);

1366}

1367

1368

1370 addInvalidLocationOrRange(Location, Location->getParentScope(),

1371 &InvalidRanges);

1372}

1373

1374

1379 addItem<LVOffsetLinesMap, LVOffset, LVLine *>(&LinesZero, Offset, Line);

1380}

1381

1383 if (options().getPrintFormatting())

1384 return;

1385

1386

1390

1391 enum class Option { Directory, File };

1392 auto PrintNames = [&](Option Action) {

1393 StringRef Kind = Action == Option::Directory ? "Directory" : "File";

1394 std::setstd::string UniqueNames;

1395 for (size_t Index : Filenames) {

1396

1397

1399 size_t Pos = Name.rfind('/');

1400 if (Pos != std:🧵:npos)

1401 Name = (Action == Option::File) ? Name.substr(Pos + 1)

1402 : Name.substr(0, Pos);

1403

1404 UniqueNames.insert(std::string(Name));

1405 }

1406 for (const std::string &Name : UniqueNames)

1409 };

1410

1411 if (options().getAttributeDirectories())

1412 PrintNames(Option::Directory);

1413 if (options().getAttributeFiles())

1414 PrintNames(Option::File);

1415 if (options().getAttributePublics()) {

1417

1418

1419 using OffsetSorted = std::map<LVAddress, LVPublicNames::const_iterator>;

1420 OffsetSorted SortedNames;

1421 for (LVPublicNames::const_iterator Iter = PublicNames.begin();

1422 Iter != PublicNames.end(); ++Iter)

1423 SortedNames.emplace(Iter->first->getOffset(), Iter);

1424

1425 LVPublicNames::const_iterator Iter;

1426 for (OffsetSorted::reference Entry : SortedNames) {

1427 Iter = Entry.second;

1430 if (options().getAttributeOffset()) {

1432 size_t Size = (*Iter).second.second;

1434 << "]";

1435 }

1436 OS << "\n";

1437 }

1438 }

1439}

1440

1442 auto PrintHeader = [&](const char *Header) { OS << "\n" << Header << ":\n"; };

1443 auto PrintFooter = [&](auto &Set) {

1444 if (Set.empty())

1445 OS << "None\n";

1446 };

1447 auto PrintOffset = [&](unsigned &Count, LVOffset Offset) {

1448 if (Count == 5) {

1449 Count = 0;

1450 OS << "\n";

1451 }

1452 ++Count;

1454 };

1456 LVOffsetElementMap::const_iterator Iter = Map.find(Offset);

1457 LVElement *Element = Iter != Map.end() ? Iter->second : nullptr;

1462 OS << "\n";

1463 };

1465 const char *Header) {

1466 PrintHeader(Header);

1467 for (LVOffsetLocationsMap::const_reference Entry : Map) {

1468 PrintElement(WarningOffsets, Entry.first);

1471 << Location->getIntervalInfo() << "\n";

1472 }

1473 PrintFooter(Map);

1474 };

1475

1476 if (options().getInternalTag() && getReader().isBinaryTypeELF()) {

1477 PrintHeader("Unsupported DWARF Tags");

1478 for (LVTagOffsetsMap::const_reference Entry : DebugTags) {

1479 OS << format("\n0x%02x", (unsigned)Entry.first) << ", "

1481 unsigned Count = 0;

1483 PrintOffset(Count, Offset);

1484 OS << "\n";

1485 }

1486 PrintFooter(DebugTags);

1487 }

1488

1489 if (options().getWarningCoverages()) {

1490 PrintHeader("Symbols Invalid Coverages");

1491 for (LVOffsetSymbolMap::const_reference Entry : InvalidCoverages) {

1492

1498 }

1499 PrintFooter(InvalidCoverages);

1500 }

1501

1502 if (options().getWarningLines()) {

1503 PrintHeader("Lines Zero References");

1504 for (LVOffsetLinesMap::const_reference Entry : LinesZero) {

1505 PrintElement(WarningOffsets, Entry.first);

1506 unsigned Count = 0;

1507 for (const LVLine *Line : Entry.second)

1508 PrintOffset(Count, Line->getOffset());

1509 OS << "\n";

1510 }

1511 PrintFooter(LinesZero);

1512 }

1513

1514 if (options().getWarningLocations())

1515 PrintInvalidLocations(InvalidLocations, "Invalid Location Ranges");

1516

1517 if (options().getWarningRanges())

1518 PrintInvalidLocations(InvalidRanges, "Invalid Code Ranges");

1519}

1520

1521void LVScopeCompileUnit::printTotals(raw_ostream &OS) const {

1522 OS << "\nTotals by lexical level:\n";

1523 for (size_t Index = 1; Index <= MaxSeenLevel; ++Index)

1524 OS << format("[%03d]: %10d (%6.2f%%)\n", Index, Totals[Index].first,

1525 Totals[Index].second);

1526}

1527

1528void LVScopeCompileUnit::printScopeSize(const LVScope *Scope, raw_ostream &OS) {

1529 LVSizesMap::const_iterator Iter = Sizes.find(Scope);

1530 if (Iter != Sizes.end()) {

1532 assert(CUContributionSize && "Invalid CU contribution size.");

1533

1534

1535 float Percentage =

1536 rint((float(Size) / CUContributionSize) * 100.0 * 100.0) / 100.0;

1537 OS << format("%10" PRId64 " (%6.2f%%) : ", Size, Percentage);

1539

1540

1542 if (Level > MaxSeenLevel)

1543 MaxSeenLevel = Level;

1544 if (Level >= Totals.size())

1545 Totals.resize(2 * Level);

1547 Totals[Level].second += Percentage;

1548 }

1549}

1550

1552

1553 std::function<void(const LVScope *Scope)> PrintScope =

1555

1556 if (options().getSelectExecute() && options().getReportAnyView()) {

1559 printScopeSize(Scope, OS);

1560 return;

1561 }

1565 printScopeSize(Scope, OS);

1566 PrintScope(Scope);

1567 }

1568 }

1569 };

1570

1571 bool PrintScopes = options().getPrintScopes();

1572 if (!PrintScopes)

1573 options().setPrintScopes();

1575

1576 OS << "\nScope Sizes:\n";

1577 options().resetPrintFormatting();

1578 options().setPrintOffset();

1579

1580

1581

1582 printScopeSize(this, OS);

1583 PrintScope(this);

1584

1585

1586 printTotals(OS);

1587

1588 options().resetPrintOffset();

1589 options().setPrintFormatting();

1590

1591 if (!PrintScopes)

1592 options().resetPrintScopes();

1593}

1594

1597}

1598

1599

1601 const char *Header) const {

1602 std::string Separator = std::string(29, '-');

1603 auto PrintSeparator = [&]() { OS << Separator << "\n"; };

1604 auto PrintHeadingRow = [&](const char *T, const char *U, const char *V) {

1605 OS << format("%-9s%9s %9s\n", T, U, V);

1606 };

1607 auto PrintDataRow = [&](const char *T, unsigned U, unsigned V) {

1608 OS << format("%-9s%9d %9d\n", T, U, V);

1609 };

1610

1611 OS << "\n";

1612 PrintSeparator();

1613 PrintHeadingRow("Element", "Total", Header);

1614 PrintSeparator();

1615 PrintDataRow("Scopes", Allocated.Scopes, Counter.Scopes);

1616 PrintDataRow("Symbols", Allocated.Symbols, Counter.Symbols);

1617 PrintDataRow("Types", Allocated.Types, Counter.Types);

1618 PrintDataRow("Lines", Allocated.Lines, Counter.Lines);

1619 PrintSeparator();

1620 PrintDataRow(

1621 "Total",

1624}

1625

1627 bool UseMatchedElements) {

1629 if (SortFunction)

1630 std::stable_sort(MatchedElements.begin(), MatchedElements.end(),

1631 SortFunction);

1632

1633

1634

1635

1636 if (options().getPrintAnyElement()) {

1637 if (UseMatchedElements)

1638 OS << "\n";

1640

1641 if (UseMatchedElements) {

1642

1645 } else {

1646

1647 for (const LVScope *Scope : MatchedScopes) {

1652 }

1653 }

1654

1655

1656 if (options().getPrintSummary()) {

1657

1658

1659

1660 if (options().getReportList()) {

1662 if (Element->getIncludeInPrint())

1663 continue;

1664 if (Element->getIsType())

1666 else if (Element->getIsSymbol())

1668 else if (Element->getIsScope())

1670 else if (Element->getIsLine())

1672 else

1674 }

1675 }

1677 }

1678 }

1679

1680

1681

1682 if (options().getPrintSizes()) {

1683 OS << "\n";

1685

1686 OS << "\nScope Sizes:\n";

1687 printScopeSize(this, OS);

1689 if (Element->getIsScope())

1690

1692

1693 printTotals(OS);

1694 }

1695}

1696

1698

1701

1703 OS << "\n";

1704

1706}

1707

1710 if (options().getPrintFormatting() && options().getAttributeProducer())

1713 true,

1714 false);

1715

1716

1718

1719

1723 }

1724}

1725

1726

1727

1728

1731 return false;

1733}

1734

1736

1737 OS << formattedKind(kind()) << " " << (getIsEnumClass() ? "class " : "")

1739 if (getHasType())

1742 OS << "\n";

1743}

1744

1745

1746

1747

1750 return false;

1752}

1753

1756}

1757

1758

1759

1760

1762

1763

1764

1765 if (options().getAttributeInserted() && getHasReferenceAbstract() &&

1766 !getAddedMissing()) {

1767

1771 if (Scope->getHasReferenceAbstract() && Scope->getAddedMissing())

1773 }

1774

1776

1777

1778

1779

1780

1781

1782

1783

1784

1785

1786

1787 if (getHasReferenceSpecification()) {

1791 setIsExternal();

1792 }

1793 }

1794

1795

1799}

1800

1803

1805}

1806

1808

1809 if (getIsTemplate())

1811}

1812

1815 return false;

1816

1817

1819 return false;

1820

1821

1823 return false;

1824

1825

1827 return false;

1828

1829

1831 return false;

1832

1833

1834 if (options().getCompareLines() &&

1836 return false;

1837

1838

1840 return false;

1841

1843 return false;

1844

1845 return true;

1846}

1847

1849 assert(Scopes && "Scopes must not be nullptr");

1850

1852

1855 return nullptr;

1856}

1857

1860

1861

1864

1865

1867 if (getIsMember())

1870

1872 getIsCallSite()

1873 ? ""

1876

1880

1881

1883 if (getIsTemplateResolved())

1891 }

1892}

1893

1894

1895

1896

1898

1899 if (getIsTemplate())

1901}

1902

1905 return false;

1906

1907

1908 if (getHasDiscriminator() && Scope->getHasDiscriminator())

1910 return false;

1911

1912

1915 return false;

1916

1917 return true;

1918}

1919

1922}

1923

1926}

1927

1928

1929

1930

1931

1933 if (getIsMemberPointerResolved())

1934 return;

1935 setIsMemberPointerResolved();

1936

1937

1939 Name.append(" (*)");

1940 Name.append("(");

1941

1942

1944 bool AddComma = false;

1946 if (Symbol->getIsParameter()) {

1949 Type->resolveName();

1950 if (AddComma)

1951 Name.append(", ");

1953 AddComma = true;

1954 }

1955 }

1956

1957 Name.append(")");

1958

1959

1961}

1962

1963

1964

1965

1968 return false;

1969

1971 return false;

1972

1973

1975 return false;

1976

1978 return false;

1979

1980 return true;

1981}

1982

1984 assert(Scopes && "Scopes must not be nullptr");

1985

1989 return nullptr;

1990}

1991

1994

1995

1998

2001 }

2002}

2003

2004

2005

2006

2008 if (options().getAttributeAnyLocation())

2009 return;

2010

2016 CompileUnit->processRangeLocationCoverage();

2017 }

2018}

2019

2021

2022 std::function<void(LVScope * Parent)> TraverseScope = [&](LVScope *Parent) {

2023 auto Traverse = [&](const auto *Set) {

2024 if (Set)

2025 for (const auto &Entry : *Set)

2026 Entry->setInnerComponent();

2027 };

2031 TraverseScope(Scope);

2032 }

2034 Traverse(Parent->getTypes());

2035 Traverse(Parent->getLines());

2036 };

2037

2038

2039 TraverseScope(this);

2040}

2041

2044}

2045

2047 OS << "\nLogical View:\n";

2049}

2050

2053 if (options().getAttributeFormat())

2055 OS << "\n";

2056}

2057

2059 bool UseMatchedElements) const {

2060

2061

2063

2065 if (UseMatchedElements)

2066 options().resetPrintFormatting();

2068

2071

2072

2073

2076 if (std::error_code EC =

2079 ScopeName.c_str());

2081 }

2082

2084

2085

2089 }

2090 }

2091 if (UseMatchedElements)

2092 options().setPrintFormatting();

2093 }

2094

2096}

2097

2098

2099

2100

2103 return false;

2105}

2106

2109}

assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())

Lightweight error class with error context and mandatory checking.

static ErrorSuccess success()

Create a success value.

Pass interface - Implemented by all 'passes'.

void append(ItTy in_start, ItTy in_end)

Add the specified range to the end of the SmallVector.

void push_back(const T &Elt)

StringRef - Represent a constant reference to a string, i.e.

std::string str() const

str - Get the contents as an std::string.

Target - Wrapper for Target specific information.

const char * getName() const

getName - Get the target name.

The instances of the Type class are immutable: once they are created, they are never changed.

Stores all information relating to a compile unit, be it in its original instance in the object file ...

void printItem(LVElement *Element, LVComparePass Pass)

void push(LVScope *Scope)

size_t getNameIndex() const

std::string discriminatorAsString() const

StringRef getQualifiedName() const

void resolveFullname(LVElement *BaseType, StringRef Name=emptyString())

virtual size_t getCallFilenameIndex() const

virtual void updateLevel(LVScope *Parent, bool Moved=false)

virtual void resolveName()

StringRef virtualityString(uint32_t Virtuality=dwarf::DW_VIRTUALITY_none) const

uint32_t getInlineCode() const

StringRef typeAsString() const

virtual uint32_t getDiscriminator() const

StringRef externalString() const

virtual StringRef getLinkageName() const

void setName(StringRef ElementName) override

StringRef getName() const override

LVElement * getType() const

bool referenceMatch(const LVElement *Element) const

virtual uint32_t getCallLineNumber() const

void setFile(LVElement *Reference=nullptr)

void setType(LVElement *Element=nullptr)

StringRef getTypeName() const

void printLinkageName(raw_ostream &OS, bool Full, LVElement *Parent, LVScope *Scope) const

StringRef getTypeQualifiedName() const

virtual void report(LVComparePass Pass)

StringRef accessibilityString(uint32_t Access=dwarf::DW_ACCESS_private) const

bool equals(const LVElement *Element) const

StringRef inlineCodeString(uint32_t Code) const

size_t getFilenameIndex() const

std::string typeOffsetAsString() const

virtual size_t getLinkageNameIndex() const

bool isNamed() const override

void printReference(raw_ostream &OS, bool Full, LVElement *Parent) const

static void markMissingParents(const LVLines *References, const LVLines *Targets)

virtual bool equals(const LVLine *Line) const

virtual Error doPrint(bool Split, bool Match, bool Print, raw_ostream &OS, bool Full=true) const

virtual const char * kind() const

LVScope * getParentScope() const

std::string indentAsString() const

virtual void print(raw_ostream &OS, bool Full=true) const

void setLevel(LVLevel Level)

void printAttributes(raw_ostream &OS, bool Full=true) const

virtual std::string lineNumberAsString(bool ShowZero=false) const

void setParent(LVScope *Scope)

void setOffset(LVOffset DieOffset)

LVOffset getOffset() const

LVElement * getParent() const

size_t indentationSize() const

void resetFilenameIndex()

void resolvePatternMatch(LVLine *Line)

void addEntry(LVScope *Scope, LVAddress LowerAddress, LVAddress UpperAddress)

void notifyAddedElement(LVLine *Line)

raw_ostream & outputStream()

virtual bool isSystemEntry(LVElement *Element, StringRef Name={}) const

virtual LVSectionIndex getSectionIndex(LVScope *Scope)

void setCompileUnit(LVScope *Scope)

bool doPrintScope(const LVScope *Scope) const

virtual void printRecords(raw_ostream &OS) const

void printExtra(raw_ostream &OS, bool Full=true) const override

LVScope * getReference() const override

bool equals(const LVScope *Scope) const override

LVScope * findEqualScope(const LVScopes *Scopes) const override

bool equals(const LVScope *Scope) const override

void printExtra(raw_ostream &OS, bool Full=true) const override

void resolveExtra() override

bool equals(const LVScope *Scope) const override

void printExtra(raw_ostream &OS, bool Full=true) const override

void propagatePatternMatch()

void addDebugTag(dwarf::Tag Target, LVOffset Offset)

void printSummary(raw_ostream &OS) const override

void addedElement(LVLine *Line)

void printExtra(raw_ostream &OS, bool Full=true) const override

void printMatchedElements(raw_ostream &OS, bool UseMatchedElements) override

LVLineRange lineRange(LVLocation *Location) const

void addMapping(LVLine *Line, LVSectionIndex SectionIndex)

void addInvalidLocation(LVLocation *Location)

void incrementPrintedScopes()

void increment(LVLine *Line)

void addLineZero(LVLine *Line)

void addInvalidOffset(LVOffset Offset, LVElement *Element)

void addInvalidCoverage(LVSymbol *Symbol)

void addSize(LVScope *Scope, LVOffset Lower, LVOffset Upper)

void processRangeLocationCoverage(LVValidLocation ValidLocation=&LVLocation::validateRanges)

void incrementPrintedLines()

StringRef getFilename(size_t Index) const

void print(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

void printSizes(raw_ostream &OS) const override

void addInvalidRange(LVLocation *Location)

void printLocalNames(raw_ostream &OS, bool Full=true) const

StringRef getProducer() const override

void incrementPrintedSymbols()

void incrementPrintedTypes()

void printWarnings(raw_ostream &OS, bool Full=true) const override

void printExtra(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

void printExtra(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

LVScope * findEqualScope(const LVScopes *Scopes) const override

uint32_t getCallLineNumber() const override

void resolveExtra() override

bool equals(const LVScope *Scope) const override

uint32_t getDiscriminator() const override

size_t getCallFilenameIndex() const override

void printExtra(raw_ostream &OS, bool Full=true) const override

void resolveExtra() override

void setName(StringRef ObjectName) override

LVScope * getReference() const override

LVScope * findEqualScope(const LVScopes *Scopes) const override

size_t getLinkageNameIndex() const override

void printExtra(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

void resolveReferences() override

void resolveExtra() override

void printExtra(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

LVScope * findEqualScope(const LVScopes *Scopes) const override

LVScope * getReference() const override

void processRangeInformation()

void transformScopedName()

void printExtra(raw_ostream &OS, bool Full=true) const override

StringRef getFileFormatName() const

Error doPrintMatches(bool Split, raw_ostream &OS, bool UseMatchedElements) const

void print(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

void printExtra(raw_ostream &OS, bool Full=true) const override

bool equals(const LVScope *Scope) const override

virtual LVScope * getReference() const

void addElement(LVElement *Element)

void traverseParentsAndChildren(LVObjectGetFunction GetFunction, LVObjectSetFunction SetFunction)

const LVLines * getLines() const

virtual void printSummary(raw_ostream &OS) const

StringRef resolveReferencesChain()

void printExtra(raw_ostream &OS, bool Full=true) const override

void report(LVComparePass Pass) override

const char * kind() const override

virtual LVScope * findEqualScope(const LVScopes *Scopes) const

const LVScopes * getScopes() const

void print(raw_ostream &OS, bool Full=true) const override

void resolveName() override

void printActiveRanges(raw_ostream &OS, bool Full=true) const

size_t scopeCount() const

const LVSymbols * getSymbols() const

virtual void printMatchedElements(raw_ostream &OS, bool UseMatchedElements)

virtual void setEncodedArgs(StringRef EncodedArgs)

void printEncodedArgs(raw_ostream &OS, bool Full) const

void updateLevel(LVScope *Parent, bool Moved) override

LVScope * outermostParent(LVAddress Address)

std::unique_ptr< LVLocations > Ranges

void addToChildren(LVElement *Element)

static void markMissingParents(const LVScopes *References, const LVScopes *Targets, bool TraverseChildren)

std::unique_ptr< LVSymbols > Symbols

const LVTypes * getTypes() const

void encodeTemplateArguments(std::string &Name) const

void addObject(LVLocation *Location)

const LVElements * getChildren() const

virtual void printSizes(raw_ostream &OS) const

std::unique_ptr< LVElements > Children

std::unique_ptr< LVTypes > Types

virtual bool equals(const LVScope *Scope) const

bool getTemplateParameterTypes(LVTypes &Params)

virtual StringRef getEncodedArgs() const

std::unique_ptr< LVLines > Lines

void getLocations(LVLocations &LocationList, LVValidLocation ValidLocation, bool RecordInvalid=false)

Error doPrint(bool Split, bool Match, bool Print, raw_ostream &OS, bool Full=true) const override

virtual bool equalNumberOfChildren(const LVScope *Scope) const

void addMissingElements(LVScope *Reference)

virtual void printWarnings(raw_ostream &OS, bool Full=true) const

void resolveReferences() override

std::unique_ptr< LVScopes > Scopes

const LVLocations * getRanges() const

size_t symbolCount() const

bool removeElement(LVElement *Element) override

StringRef getString(size_t Index) const

void getLocations(LVLocations &LocationList, LVValidLocation ValidLocation, bool RecordInvalid=false)

static void markMissingParents(const LVSymbols *References, const LVSymbols *Targets)

float getCoveragePercentage() const

void setReference(LVSymbol *Symbol) override

const char * kind() const override

static bool parametersMatch(const LVSymbols *References, const LVSymbols *Targets)

LVSymbol * getReference() const

virtual bool equals(const LVType *Type) const

static bool parametersMatch(const LVTypes *References, const LVTypes *Targets)

static void markMissingParents(const LVTypes *References, const LVTypes *Targets)

This class implements an extremely fast bulk output stream that can only output to a stream.

StringRef TagString(unsigned Tag)

#define llvm_unreachable(msg)

Marks that the current location is not supposed to be reachable.

std::string hexString(uint64_t Value, size_t Width=HEX_WIDTH)

std::string formattedNames(StringRef Name1, StringRef Name2)

std::map< LVOffset, LVElement * > LVOffsetElementMap

LVStringPool & getStringPool()

std::pair< LVLine *, LVLine * > LVLineRange

std::map< LVScopeKind, LVScopeGetFunction > LVScopeDispatch

std::string formattedKind(StringRef Kind)

std::map< LVOffset, LVLocations > LVOffsetLocationsMap

LVScopeCompileUnit * getReaderCompileUnit()

LVSortValue compareRange(const LVObject *LHS, const LVObject *RHS)

bool(LVObject::*)() const LVObjectGetFunction

std::string hexSquareString(uint64_t Value)

bool(LVScope::*)() const LVScopeGetFunction

bool(LVLocation::*)() LVValidLocation

LVSplitContext & getReaderSplitContext()

LVSortFunction getSortFunction()

std::string formattedName(StringRef Name)

void(LVObject::*)() LVObjectSetFunction

LVSortValue(*)(const LVObject *LHS, const LVObject *RHS) LVSortFunction

std::string formatAttributes(const StringRef First, Args... Others)

void(LVScope::*)() LVScopeSetFunction

LVCompare & getComparator()

This is an optimization pass for GlobalISel generic memory operations.

Error createStringError(std::error_code EC, char const *Fmt, const Ts &... Vals)

Create formatted StringError object.

void erase(Container &C, ValueType V)

Wrapper function to remove a value from a container:

raw_ostream & dbgs()

dbgs() - This returns a reference to a raw_ostream for debugging messages.

format_object< Ts... > format(const char *Fmt, const Ts &... Vals)

These are helper functions used to produce formatted output.