Skip to content

Commit e956952

Browse files
committed
DebugInfo: Flag Dwarf Version metadata for merging during LTO
When the Dwarf Version metadata was initially added (r184276) there was no support for Module::Max - though the comment suggested that was the desired behavior. The original behavior was Module::Warn which would warn and then pick whichever version came first - which is pretty arbitrary/luck-based if the consumer has some need for one version or the other. Now that the functionality's been added (r303590) this change updates the implementation to match the desired goal. The general logic here is - if you compile /some/ of your program with a more recent DWARF version, you must have a consumer that can handle it, so might as well use it for /everything/. The only place where this might fall down is if you have a need to use an old tool (supporting only the older DWARF version) for some subset of your program. In which case now it'll all be the higher version. That seems pretty narrow (& the inverse could happen too - you specifically /need/ the higher DWARF version for some extra expressivity, etc, in some part of the program)
1 parent 019779d commit e956952

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -470,9 +470,7 @@ void CodeGenModule::Release() {
470470
CodeGenOpts.NumRegisterParameters);
471471

472472
if (CodeGenOpts.DwarfVersion) {
473-
// We actually want the latest version when there are conflicts.
474-
// We can change from Warning to Latest if such mode is supported.
475-
getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
473+
getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version",
476474
CodeGenOpts.DwarfVersion);
477475
}
478476
if (CodeGenOpts.EmitCodeView) {

clang/test/CodeGen/dwarf-version.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,10 +38,10 @@ int main (void) {
3838

3939
// NOCODEVIEW-NOT: !"CodeView"
4040

41-
// VER2: !{i32 2, !"Dwarf Version", i32 2}
42-
// VER3: !{i32 2, !"Dwarf Version", i32 3}
43-
// VER4: !{i32 2, !"Dwarf Version", i32 4}
44-
// VER5: !{i32 2, !"Dwarf Version", i32 5}
41+
// VER2: !{i32 7, !"Dwarf Version", i32 2}
42+
// VER3: !{i32 7, !"Dwarf Version", i32 3}
43+
// VER4: !{i32 7, !"Dwarf Version", i32 4}
44+
// VER5: !{i32 7, !"Dwarf Version", i32 5}
4545

4646
// NODWARF-NOT: !"Dwarf Version"
4747
// CODEVIEW: !{i32 2, !"CodeView", i32 1}

0 commit comments

Comments
 (0)