[llvm] [BOLT][DWARF] Add support for .debug_names (PR #81062)

Amir Ayupov via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 22 12:21:25 PST 2024


================
@@ -378,11 +377,13 @@ getUnitForOffset(DIEBuilder &Builder, DWARFContext &DWCtx,
   return nullptr;
 }
 
-uint32_t DIEBuilder::computeDIEOffset(const DWARFUnit &CU, DIE &Die,
+uint32_t DIEBuilder::computeDIEOffset(DWARFUnit &CU, DIE &Die,
----------------
aaupov wrote:

I hope you understand why I'm raising this issue – that if the method is called `computeDIEOffset`, it's reasonable that CU is passed as a const ref.

Dropping the const qualifier is a symptom of a larger issue: that a parameter that's not supposed to be modified starts to be modified. I understand that it's not possible/practical to add a const-qualified method, that's ok. I suggested moving the modifications to CU/calling non-const stuff outside of this method – what do you think about that?
As a final resort, you can rename the method to `computeDIEOffsetAndAddAccelTableEntry` and drop const.

https://github.com/llvm/llvm-project/pull/81062


More information about the llvm-commits mailing list