Skip to content

Commit 52be47b

Browse files
authored
[BOLT][DWARF] Add support to create path (#73884)
When option --dwarf-output-path is specified, if the path does not exist BOLT will now create it. This is what also happens when --plugin-opt=dwo_dir=<value> is specified to LLD.
1 parent 5b72950 commit 52be47b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

bolt/lib/Rewrite/DWARFRewriter.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -679,6 +679,8 @@ void DWARFRewriter::updateDebugInfo() {
679679
assert(CompDirAttrInfo && "DW_AT_comp_dir is not in Skeleton CU.");
680680

681681
if (!opts::DwarfOutputPath.empty()) {
682+
if (!sys::fs::exists(opts::DwarfOutputPath))
683+
sys::fs::create_directory(opts::DwarfOutputPath);
682684
addStringHelper(DIEBldr, UnitDIE, Unit, CompDirAttrInfo,
683685
opts::DwarfOutputPath.c_str());
684686
}

bolt/test/X86/dwarf5-df-output-dir-same-name.test

+16
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,19 @@
2121
; BOLT: split.dwo1.dwo
2222
; BOLT: DW_AT_dwo_name ("split.dwo0.dwo")
2323
; BOLT: DW_AT_dwo_name ("split.dwo1.dwo")
24+
25+
; Tests that when --dwarf-output-path is specified, but path do not exist BOLT creates it.
26+
27+
; RUN: rm -rf dwo
28+
; RUN: llvm-bolt main.exe -o main.exe.bolt --update-debug-sections --dwarf-output-path=%t/dwo
29+
; RUN: ls -l %t/dwo > log
30+
; RUN: llvm-dwarfdump --debug-info main.exe.bolt >> log
31+
; RUN: cat log | FileCheck -check-prefix=BOLT1 %s
32+
33+
; Tests that BOLT handles correctly writing out .dwo files to the same directory when input has input where part of path
34+
; is in DW_AT_dwo_name and the .dwo file names are the same.
35+
36+
; BOLT1: split.dwo0.dwo
37+
; BOLT1: split.dwo1.dwo
38+
; BOLT1: DW_AT_dwo_name ("split.dwo0.dwo")
39+
; BOLT1: DW_AT_dwo_name ("split.dwo1.dwo")

0 commit comments

Comments
 (0)