[PATCH] D150644: [lld][ELF] Implement –print-memory-usage

Peter Smith via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 16 03:11:05 PDT 2023


peter.smith added a comment.

Looks like a useful feature to add, and I agree that keeping the same syntax as GNU is worthwhile.



================
Comment at: lld/ELF/LinkerScript.cpp:1450
+    printSize(usedLength);
+    uint64_t length = (m->length)().getValue();
+    if (length != 0) {
----------------
Wondering whether it is worth making `length()` and `usedLength()` member functions of MemoryRegion. I think the `(m->length)().getValue()` is used at least once in LinkerScript.cpp.

Not got a strong opinion here, it would just hide a bit of the code needed to access the expression.


================
Comment at: lld/test/ELF/linkerscript/print-memory-usage1.s:3
+
+# RUN: llvm-mc -filetype=obj -triple=x86_64-unknown-linux %s -o %t.o
+# RUN: echo "MEMORY { \
----------------
More recent tests have used the `split-file` command to have the linker script and the assembler in the same file without needing a large echo command. This makes a bit easier to edit.

Will be worth checking with MaskRay to see his preference is though. 


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D150644



More information about the llvm-commits mailing list