MCPcopy Create free account
hub / github.com/NVIDIA/cuda-tile / DebugInfoWriter

Class DebugInfoWriter

lib/Bytecode/Writer/BytecodeWriter.cpp:581–906  ·  view source on GitHub ↗

This class manages writing debug info attributes to bytecode format.

Source from the content-addressed store, hash-verified

579
580/// This class manages writing debug info attributes to bytecode format.
581class DebugInfoWriter {
582public:
583 DebugInfoWriter(StringManager &strMgr) : strMgr(strMgr) {}
584
585 /// This method gets or creates an index for an operation.
586 uint64_t getOpIndex(Operation *op) {
587 auto it = opIndexMap.find(op);
588 if (it != opIndexMap.end())
589 return it->second;
590
591 // Check if the operation location has a reserved index and return it.
592 auto reserved = getDebugReserved(op->getLoc());
593 if (reserved != Bytecode::DebugReserved::SIZE)
594 return static_cast<uint64_t>(reserved);
595
596 // Adjust the index to account for reserved indices.
597 uint64_t opIndex = opIndexMap.size() +
598 static_cast<uint64_t>(Bytecode::DebugReserved::SIZE);
599
600 opIndexMap[op] = opIndex;
601 return opIndex;
602 }
603
604 /// This method adds a debug info attribute to an operation.
605 void addDebugInfo(uint64_t opIndex, Attribute attr) {
606 // Nothing to do if the operation has a reserved index.
607 if (opIndex < static_cast<uint64_t>(Bytecode::DebugReserved::SIZE))
608 return;
609
610 // Adjust the index to account for reserved indices.
611 opIndex -= static_cast<uint64_t>(Bytecode::DebugReserved::SIZE);
612
613 if (opIndex >= debuginfoIndices.size())
614 debuginfoIndices.resize(opIndex + 1);
615 debuginfoIndices[opIndex].push_back(getDebugInfoIndex(attr));
616 }
617
618 // debuginfo-section =:
619 // diOpsNum[varint] // Total number of operations with debug info
620 // padding[bytes] // Align to 4 bytes
621 // diIndexOffsets[uint32_t] // Per op offset into the debug info indices
622 // diIndicesNum[varint] // Total number of debug info indices
623 // padding[bytes] // Align to 8 bytes
624 // diIndices[uint64_t] // Array of debug indices to debug info
625 // attributes diAttrNum[varint] // Total number of debug info
626 // attributes padding[bytes] // Align to 4 bytes
627 // diOffsets[uint32_t] // Per debug info attribute offset into the
628 // debug info data diData[bytes] // Data for each debug info
629 // attribute
630 //
631 // diData =:
632 // DebugTag[byte] // Indicates the debug info attribute type
633 // debuginfo-encoding // Format depends on DebugTag
634 LogicalResult writeDebugInfoSection(raw_ostream &stream) {
635 // Skip writing the section if there are no debug info attributes.
636 if (debuginfoIndices.empty() && debuginfoList.empty())
637 return success();
638

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected