[llvm] ec60fca - [CodeView] Use non-qualified names for static local variables

Steve Merritt via llvm-commits llvm-commits at lists.llvm.org
Tue Aug 16 07:34:00 PDT 2022


Author: Steve Merritt
Date: 2022-08-16T10:33:43-04:00
New Revision: ec60fca7527582cbd949aaeaf923fb710d7c3244

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

LOG: [CodeView] Use non-qualified names for static local variables

Static variables declared within a routine or lexical block should
be emitted with a non-qualified name.  This allows the variables to
be visible to the Visual Studio watch window.

Differential Revision: https://reviews.llvm.org/D131400

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
    llvm/test/DebugInfo/COFF/global_visibility.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
index f34e92278ad22..16213aff4788a 100644
--- a/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
@@ -3350,11 +3350,13 @@ void CodeViewDebug::emitDebugInfoForGlobal(const CVGlobalVariable &CVGV) {
   if (const auto *MemberDecl = dyn_cast_or_null<DIDerivedType>(
           DIGV->getRawStaticDataMemberDeclaration()))
     Scope = MemberDecl->getScope();
-  // For Fortran, the scoping portion is elided in its name so that we can
-  // reference the variable in the command line of the VS debugger.
+  // For static local variables and Fortran, the scoping portion is elided
+  // in its name so that we can reference the variable in the command line
+  // of the VS debugger.
   std::string QualifiedName =
-      (moduleIsInFortran()) ? std::string(DIGV->getName())
-                            : getFullyQualifiedName(Scope, DIGV->getName());
+      (moduleIsInFortran() || isa<DILocalScope>(Scope))
+          ? std::string(DIGV->getName())
+          : getFullyQualifiedName(Scope, DIGV->getName());
 
   if (const GlobalVariable *GV =
           CVGV.GVInfo.dyn_cast<const GlobalVariable *>()) {

diff  --git a/llvm/test/DebugInfo/COFF/global_visibility.ll b/llvm/test/DebugInfo/COFF/global_visibility.ll
index 4a5eff8a6b28f..fcb5239b8538d 100644
--- a/llvm/test/DebugInfo/COFF/global_visibility.ll
+++ b/llvm/test/DebugInfo/COFF/global_visibility.ll
@@ -53,12 +53,12 @@
 ; CHECK:     }
 ; CHECK:     DataSym {
 ; CHECK:       Kind: S_LDATA32 (0x110C)
-; CHECK:       DisplayName: foo::local_int
+; CHECK:       DisplayName: local_int
 ; CHECK:       LinkageName: ?local_int@?1??foo@@YAXXZ at 4HA
 ; CHECK:     }
 ; CHECK:     DataSym {
 ; CHECK:       Kind: S_LDATA32 (0x110C)
-; CHECK:       DisplayName: foo::nested_int
+; CHECK:       DisplayName: nested_int
 ; CHECK:       LinkageName: ?nested_int@?1??foo@@YAXXZ at 4HA
 ; CHECK:     }
 ; CHECK:     ProcEnd {
@@ -74,12 +74,12 @@
 ; CHECK:     }
 ; CHECK:     DataSym {
 ; CHECK:       Kind: S_LDATA32 (0x110C)
-; CHECK:       DisplayName: bar::local_int
+; CHECK:       DisplayName: local_int
 ; CHECK:       LinkageName: ?local_int@?1??bar@@YAXXZ at 4HA
 ; CHECK:     }
 ; CHECK:     DataSym {
 ; CHECK:       Kind: S_LDATA32 (0x110C)
-; CHECK:       DisplayName: bar::nested_int
+; CHECK:       DisplayName: nested_int
 ; CHECK:       LinkageName: ?nested_int@?1??bar@@YAXXZ at 4HA
 ; CHECK:     }
 ; CHECK:     ProcEnd {


        


More information about the llvm-commits mailing list