[PATCH] D155199: [NFC][XCOFF] Use common function to calculate file offset

Stephen Peckham via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jul 14 09:15:08 PDT 2023


stephenpeckham added inline comments.


================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:125
 
+  virtual void advanceFileOffset(const uint64_t MaxRawDataSize,
+                                 uint64_t &RawPointer) {
----------------
Would it make more sense for this function to return the new RawPointer instead of using reference to the variable? 


================
Comment at: llvm/lib/MC/XCOFFObjectWriter.cpp:200
 
+  void advanceFileOffset(const uint64_t MaxRawDataSize,
+                         uint64_t &RawPointer) override {
----------------
I think this special treatment of Dwarf sections is unnecessary, but changing it probably needs a separate patch.  Loadable sections (e.g., .text, .data) may need to be aligned.  Other sections generally don't need any alignment, but if they're aligned, the RawPointer should be adjusted before writing the section. Then a dwarf-specific function wouldn't be needed. Also when compiling in 64-bit mode, the assert can never be triggered, because MaxRawDataSize is UINT64_MAX.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155199/new/

https://reviews.llvm.org/D155199



More information about the llvm-commits mailing list