[llvm] [DWARF] Use ULEB128 and not just one byte for directory indices (PR #109067)

Ellis Hoag via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 17 17:15:05 PDT 2024


================
@@ -0,0 +1,2631 @@
+; RUN: rm -rf %t && mkdir -p %t
+; RUN: %llc_dwarf -o %t/all.o -filetype=obj %s
+; Dummy debug map to get the results. Bare object doesn't seem to work
+; RUN: echo "---" > %t/debug.map
+; RUN: echo "triple: 'x86_64-apple-darwin'" >> %t/debug.map
+; RUN: echo "objects:" >> %t/debug.map
+; RUN: echo "  - filename: %t/all.o" >> %t/debug.map
+; RUN: echo "    symbols:" >> %t/debug.map
+; RUN: echo "      - { sym: _all, objAddr: 0x0, binAddr: 0x0, size: 0x0 }" >> %t/debug.map
+; RUN: echo "..." >> %t/debug.map
+; RUN: dsymutil -f -y %t/debug.map -o - | llvm-dwarfdump -debug-line - | FileCheck %s
+; RUN: dsymutil --linker parallel -f -y %t/debug.map -o - | llvm-dwarfdump -debug-line - | tee %t/output.txt | FileCheck %s
+
+; CHECK:      include_directories[255] = "/tmp/tmp.0HPkdttdoU/d254"
+; CHECK-NEXT: include_directories[256] = "/tmp/tmp.0HPkdttdoU/d255"
+; CHECK-NEXT: include_directories[257] = "/tmp/tmp.0HPkdttdoU/d256"
+
+; CHECK: dir_index: 255
+; CHECK: dir_index: 256
+; CHECK: dir_index: 257
+
+; ---
+; Generated doing (fish shell):
+; - for cnt in (seq 0 256); mkdir -p d$cnt ; printf "void func$cnd() {}\n#define FUNC$cnt func$cnt()\n" >> d$cnt/f$cnt.c ; end
+; - for cnt in (seq 0 256); printf "#include \"f$cnt.c\"" >> all.c ; end
+; - printf "void all() {\n" >> all.c
+; - for cnt in (seq 0 256); printf "FUNC$cnt;\n" >> all.c ; end
+; - printf "}\n" >> all.c
+; - clang -target x86_64-apple-macos -S -emit-llvm -gdwarf-5 -o all.ll all.c (for cnt in (seq 0 256); echo "-Id$cnt"; end)
+; - Edit all.ll manually and change all DIFile so the directory in filename is
+;   moved into the directory field.
----------------
ellishg wrote:

It would be nice to use Python to generate this `.ll` file so we don't have to checkin such a large file. Here is an example where I've done this.

https://github.com/ellishg/llvm-project/blob/e40915b7407eda4b370658da5c9606e310b55d19/lld/test/MachO/bp-section-orderer-stress.s#L5-L17

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


More information about the llvm-commits mailing list