[llvm] 30f2170 - Revert "[DebugInfo] Fix potential CU mismatch for attachRangesOrLowHighPC"

via llvm-commits llvm-commits at lists.llvm.org
Wed Jul 26 04:59:16 PDT 2023


Author: DianQK
Date: 2023-07-26T19:58:00+08:00
New Revision: 30f2170a78e7c67a9d870ba9615d0c4c472cedbf

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

LOG: Revert "[DebugInfo] Fix potential CU mismatch for attachRangesOrLowHighPC"

This reverts commit d20e4a1d68aa8e14c4e524e4d4eeb4445acac401.
After committing 2ee4d0386c783f58abe708298228de648239b435, We don't support subprogram definitions nested within `DICompositeType` when doing LTO builds.
For a detailed discussion, see https://reviews.llvm.org/D152095.

Added: 
    

Modified: 
    llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
    llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h

Removed: 
    llvm/test/DebugInfo/Generic/cross-cu-inlining-ranges.ll


################################################################################
diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
index 58ed21379d29be..5697037e06e220 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.cpp
@@ -458,15 +458,6 @@ void DwarfCompileUnit::attachLowHighPC(DIE &D, const MCSymbol *Begin,
     addLabelDelta(D, dwarf::DW_AT_high_pc, End, Begin);
 }
 
-// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
-// and DW_AT_high_pc attributes. If there are global variables in this
-// scope then create and insert DIEs for these variables.
-DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
-  DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
-  auto *ContextCU = static_cast<DwarfCompileUnit *>(SPDie->getUnit());
-  return ContextCU->updateSubprogramScopeDIEImpl(SP, SPDie);
-}
-
 // Add info for Wasm-global-based relocation.
 // 'GlobalIndex' is used for split dwarf, which currently relies on a few
 // assumptions that are not guaranteed in a formal way but work in practice.
@@ -500,8 +491,11 @@ void DwarfCompileUnit::addWasmRelocBaseGlobal(DIELoc *Loc, StringRef GlobalName,
   }
 }
 
-DIE &DwarfCompileUnit::updateSubprogramScopeDIEImpl(const DISubprogram *SP,
-                                                    DIE *SPDie) {
+// Find DIE for the given subprogram and attach appropriate DW_AT_low_pc
+// and DW_AT_high_pc attributes. If there are global variables in this
+// scope then create and insert DIEs for these variables.
+DIE &DwarfCompileUnit::updateSubprogramScopeDIE(const DISubprogram *SP) {
+  DIE *SPDie = getOrCreateSubprogramDIE(SP, includeMinimalInlineScopes());
   SmallVector<RangeSpan, 2> BB_List;
   // If basic block sections are on, ranges for each basic block section has
   // to be emitted separately.
@@ -1065,7 +1059,6 @@ sortLocalVars(SmallVectorImpl<DbgVariable *> &Input) {
 DIE &DwarfCompileUnit::constructSubprogramScopeDIE(const DISubprogram *Sub,
                                                    LexicalScope *Scope) {
   DIE &ScopeDIE = updateSubprogramScopeDIE(Sub);
-  auto *ContextCU = static_cast<DwarfCompileUnit *>(ScopeDIE.getUnit());
 
   if (Scope) {
     assert(!Scope->getInlinedAt());
@@ -1073,10 +1066,8 @@ DIE &DwarfCompileUnit::constructSubprogramScopeDIE(const DISubprogram *Sub,
     // Collect lexical scope children first.
     // ObjectPointer might be a local (non-argument) local variable if it's a
     // block's synthetic this pointer.
-    if (DIE *ObjectPointer =
-            ContextCU->createAndAddScopeChildren(Scope, ScopeDIE))
-      ContextCU->addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer,
-                             *ObjectPointer);
+    if (DIE *ObjectPointer = createAndAddScopeChildren(Scope, ScopeDIE))
+      addDIEEntry(ScopeDIE, dwarf::DW_AT_object_pointer, *ObjectPointer);
   }
 
   // If this is a variadic function, add an unspecified parameter.

diff  --git a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
index 6ef73ebd4f7f22..71f65f44c0f1a5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfCompileUnit.h
@@ -193,7 +193,6 @@ class DwarfCompileUnit final : public DwarfUnit {
   /// variables in this scope then create and insert DIEs for these
   /// variables.
   DIE &updateSubprogramScopeDIE(const DISubprogram *SP);
-  DIE &updateSubprogramScopeDIEImpl(const DISubprogram *SP, DIE *SPDie);
 
   void constructScopeDIE(LexicalScope *Scope, DIE &ParentScopeDIE);
 

diff  --git a/llvm/test/DebugInfo/Generic/cross-cu-inlining-ranges.ll b/llvm/test/DebugInfo/Generic/cross-cu-inlining-ranges.ll
deleted file mode 100644
index 17ec503c4f5f9c..00000000000000
--- a/llvm/test/DebugInfo/Generic/cross-cu-inlining-ranges.ll
+++ /dev/null
@@ -1,61 +0,0 @@
-; RUN: %llc_dwarf %s -O0 -filetype=obj -o %t.o
-; RUN: llvm-dwarfdump %t.o --debug-info --verify
-
-; We want to check that when the CU attaches ranges use the correct ContextCU.
-; In the following example, after accessing `@foo`, `bar` an `inlined_baz` are created in `foo.swift` CU.
-; Setting ranges in `@bar` will then use `bar.swift` CU.
-; An incorrect address is eventually calculated based on Base.
-
-; The origin code is:
-; foo.swift
-; import AppKit.NSLayoutConstraint
-; public class Foo {
-;     public var c: Int {
-;         get {
-;             Int(NSLayoutConstraint().constant)
-;         }
-;         set {
-;         }
-;     }
-; }
-; main.swift
-; // no mapping for range
-; let f: Foo! = nil
-
-; After LTO, `main.swift` will create a global variable, then `Foo` (and relative DIE) created in `main.swift` CU.
-
-define void @foo() !dbg !6 {
-  ret void, !dbg !9
-}
-
-define void @bar(ptr %0) !dbg !15 {
-  store i32 1, ptr %0, align 4, !dbg !16
-  store i32 1, ptr %0, align 4, !dbg !21
-  ret void, !dbg !16
-}
-
-!llvm.dbg.cu = !{!0, !2}
-!llvm.module.flags = !{!4, !5}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !1, isOptimized: true, runtimeVersion: 5, emissionKind: FullDebug)
-!1 = !DIFile(filename: "foo.swift", directory: "")
-!2 = distinct !DICompileUnit(language: DW_LANG_Swift, file: !3, isOptimized: true, runtimeVersion: 5, emissionKind: FullDebug)
-!3 = !DIFile(filename: "bar.swift", directory: "")
-!4 = !{i32 7, !"Dwarf Version", i32 4}
-!5 = !{i32 2, !"Debug Info Version", i32 3}
-!6 = distinct !DISubprogram(name: "foo", scope: !0, type: !7, spFlags: DISPFlagDefinition, unit: !0)
-!7 = !DISubroutineType(types: !8)
-!8 = !{}
-!9 = !DILocation(line: 0, scope: !10, inlinedAt: !13)
-!10 = distinct !DISubprogram(name: "init", scope: !12, file: !11, type: !7, spFlags: DISPFlagDefinition, unit: !0)
-!11 = !DIFile(filename: "<compiler-generated>", directory: "")
-!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, name: "Type", file: !3, runtimeLang: DW_LANG_Swift, identifier: "Type")
-!13 = !DILocation(line: 0, scope: !14)
-!14 = distinct !DILexicalBlock(scope: !6, file: !1)
-!15 = distinct !DISubprogram(name: "bar", scope: !12, type: !7, spFlags: DISPFlagDefinition, unit: !2)
-!16 = !DILocation(line: 0, scope: !17, inlinedAt: !19)
-!17 = distinct !DILexicalBlock(scope: !18, file: !3)
-!18 = distinct !DISubprogram(name: "inlined_baz", scope: !12, file: !3, type: !7, spFlags: DISPFlagDefinition, unit: !2)
-!19 = !DILocation(line: 0, scope: !20)
-!20 = distinct !DILexicalBlock(scope: !15, file: !3)
-!21 = !DILocation(line: 0, scope: !15)


        


More information about the llvm-commits mailing list