[llvm] [mlir] [DebugInfo] Add symbolic branches to DIExpression (PR #210850)
Aman LaChapelle via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 20 22:03:14 PDT 2026
================
@@ -69,11 +90,36 @@ void DIEDwarfExpression::enableTemporaryBuffer() {
void DIEDwarfExpression::disableTemporaryBuffer() { IsBuffering = false; }
unsigned DIEDwarfExpression::getTemporaryBufferSize() {
- return TmpDIE.computeSize(AP.getDwarfFormParams());
+ unsigned Size = 0;
+ for (const DIEValue &V : TmpDIE.values())
+ Size += V.sizeOf(AP.getDwarfFormParams());
+ return Size;
}
void DIEDwarfExpression::commitTemporaryBuffer() { OutDIE.takeValues(TmpDIE); }
+void DIEDwarfExpression::replaceTemporaryBufferData(unsigned Offset,
+ uint64_t Value,
+ unsigned Size) {
+ dwarf::Form Form = getDataForm(Size);
+ // Keep the form so replacing the value doesn't move later labels.
+ unsigned CurrentOffset = 0;
+ for (DIEValue &V : TmpDIE.values()) {
+ unsigned ValueSize = V.sizeOf(AP.getDwarfFormParams());
+ if (Offset < CurrentOffset + ValueSize) {
+ assert(Offset == CurrentOffset && ValueSize == Size &&
+ V.getType() == DIEValue::isInteger && V.getForm() == Form &&
+ V.getDIEInteger().getValue() == 0 &&
+ "symbolic branch fixup does not match its placeholder");
+ V = DIEValue(V.getAttribute(), V.getForm(),
+ DIEInteger(getDataValue(Value, Size)));
+ return;
+ }
+ CurrentOffset += ValueSize;
+ }
+ llvm_unreachable("invalid temporary DIE offset");
----------------
bzcheeseman wrote:
This control flow feels off - what is the expected behavior if one of the TmpDIE values hits the `if (Offset < CurrentOffset + ValueSize)` branch before you've resolved all the fixups? Or alternatively, what if TmpDIE has entries that don't require fixups?
https://github.com/llvm/llvm-project/pull/210850
More information about the llvm-commits
mailing list