[clang] 8805465 - [RemoveDIs][Clang] Resolve DILocalVariables used by DbgRecords (#90882)

via cfe-commits cfe-commits at lists.llvm.org
Thu May 2 12:20:45 PDT 2024


Author: Stephen Tozer
Date: 2024-05-02T20:20:40+01:00
New Revision: 8805465e1d5b1a97dfea21f4c68ee6bb4f208eb7

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

LOG: [RemoveDIs][Clang] Resolve DILocalVariables used by DbgRecords (#90882)

This patch fixes debug records in clang, by adding support for debug
records to the only remaining place that refers to DbgVariableIntrinsics
directly and does not handle DbgVariableRecords.

Added: 
    

Modified: 
    clang/lib/CodeGen/CGVTables.cpp
    clang/test/CodeGenCXX/tmp-md-nodes2.cpp

Removed: 
    


################################################################################
diff  --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index 862369ae009f48..8d9c22546b4208 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -131,6 +131,12 @@ static void resolveTopLevelMetadata(llvm::Function *Fn,
   // they are referencing.
   for (auto &BB : *Fn) {
     for (auto &I : BB) {
+      for (llvm::DbgVariableRecord &DVR :
+           llvm::filterDbgVars(I.getDbgRecordRange())) {
+        auto *DILocal = DVR.getVariable();
+        if (!DILocal->isResolved())
+          DILocal->resolve();
+      }
       if (auto *DII = dyn_cast<llvm::DbgVariableIntrinsic>(&I)) {
         auto *DILocal = DII->getVariable();
         if (!DILocal->isResolved())

diff  --git a/clang/test/CodeGenCXX/tmp-md-nodes2.cpp b/clang/test/CodeGenCXX/tmp-md-nodes2.cpp
index e50220cfb7c370..e88fb79b777ff6 100644
--- a/clang/test/CodeGenCXX/tmp-md-nodes2.cpp
+++ b/clang/test/CodeGenCXX/tmp-md-nodes2.cpp
@@ -1,6 +1,8 @@
 // REQUIRES: asserts
 // RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm %s -o - | \
 // RUN: FileCheck %s
+// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm -mllvm --experimental-debuginfo-iterators=true %s -o - | \
+// RUN: FileCheck %s
 
 // This test simply checks that the varargs thunk is created. The failing test
 // case asserts.


        


More information about the cfe-commits mailing list