Author: David Blaikie
Date: 2019-11-22T17:16:35-08:00
New Revision: e956952edec140d2475aa7c8cbe20fbdd3320634

URL: 
https://github.com/llvm/llvm-project/commit/e956952edec140d2475aa7c8cbe20fbdd3320634
DIFF: 
https://github.com/llvm/llvm-project/commit/e956952edec140d2475aa7c8cbe20fbdd3320634.diff

LOG: 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)

Added: 
    

Modified: 
    clang/lib/CodeGen/CodeGenModule.cpp
    clang/test/CodeGen/dwarf-version.c

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 0e561693f20c..25268efff61b 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -470,9 +470,7 @@ void CodeGenModule::Release() {
                               CodeGenOpts.NumRegisterParameters);
 
   if (CodeGenOpts.DwarfVersion) {
-    // We actually want the latest version when there are conflicts.
-    // We can change from Warning to Latest if such mode is supported.
-    getModule().addModuleFlag(llvm::Module::Warning, "Dwarf Version",
+    getModule().addModuleFlag(llvm::Module::Max, "Dwarf Version",
                               CodeGenOpts.DwarfVersion);
   }
   if (CodeGenOpts.EmitCodeView) {

diff  --git a/clang/test/CodeGen/dwarf-version.c 
b/clang/test/CodeGen/dwarf-version.c
index 10add21d88dd..87143ee13118 100644
--- a/clang/test/CodeGen/dwarf-version.c
+++ b/clang/test/CodeGen/dwarf-version.c
@@ -38,10 +38,10 @@ int main (void) {
 
 // NOCODEVIEW-NOT: !"CodeView"
 
-// VER2: !{i32 2, !"Dwarf Version", i32 2}
-// VER3: !{i32 2, !"Dwarf Version", i32 3}
-// VER4: !{i32 2, !"Dwarf Version", i32 4}
-// VER5: !{i32 2, !"Dwarf Version", i32 5}
+// VER2: !{i32 7, !"Dwarf Version", i32 2}
+// VER3: !{i32 7, !"Dwarf Version", i32 3}
+// VER4: !{i32 7, !"Dwarf Version", i32 4}
+// VER5: !{i32 7, !"Dwarf Version", i32 5}
 
 // NODWARF-NOT: !"Dwarf Version"
 // CODEVIEW: !{i32 2, !"CodeView", i32 1}


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to