[PATCH] D107048: [dwarf][bugfix] Recompute the size of block before getting it's BestForm

Kan Shengchen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 29 02:37:54 PDT 2021


skan created this revision.
Herald added a subscriber: hiraditya.
skan requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

http://www.dwarfstd.org/doc/DWARF4.pdf

DWARF blocks come in four forms:

- DW_FORM_block1 : A 1-byte length followed by 0 to 255 contiguous information bytes
- DW_FORM_block2 : A 2-byte length followed by 0 to 65,535 contiguous information bytes
- DW_FORM_block4 : A 4-byte length followed by 0 to 4,294,967,295 contiguous information bytes
- DW_FORM_block : An unsigned LEB128 length followed by the number of bytes specified by the length

In LLVM, the form is selected by function DIEBlock::BestForm(). The size of the block need to be
recomputed before determing the BestForm, And the function `DwarfUnit::addBlock(DIE&,Attribute,DIEBlock*)`
forgot to do that.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107048

Files:
  llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp


Index: llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
===================================================================
--- llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -407,6 +407,7 @@
 
 void DwarfUnit::addBlock(DIE &Die, dwarf::Attribute Attribute,
                          DIEBlock *Block) {
+  Block->ComputeSize(Asm);
   addBlock(Die, Attribute, Block->BestForm(), Block);
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107048.362688.patch
Type: text/x-patch
Size: 428 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210729/d14e7318/attachment.bin>


More information about the llvm-commits mailing list