[llvm] [llvm][DebugInfo][ObjC] Make sure we link backing ivars to their DW_TAG_APPLE_property (PR #165409)
Michael Buch via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 29 02:09:24 PDT 2025
https://github.com/Michael137 updated https://github.com/llvm/llvm-project/pull/165409
>From 93fa594efb77397891f9c02d22b716ac152550c8 Mon Sep 17 00:00:00 2001
From: Michael Buch <michaelbuch12 at gmail.com>
Date: Tue, 28 Oct 2025 14:27:46 +0000
Subject: [PATCH] [llvm][DebugInfo][ObjC] Make sure we link backing ivars to
their DW_TAG_APPLE_property
Depends on:
* https://github.com/llvm/llvm-project/pull/165373
When an Objective-C property has a backing ivar, we would previously not add a `DW_AT_APPLE_property` to the ivar's `DW_TAG_member`. This is what was intended based on the [Objective-C DebugInfo docs](https://github.com/llvm/llvm-project/blob/main/llvm/docs/SourceLevelDebugging.rst#proposal) but is not what LLVM currently generates.
LLDB currently doesn't ever try linking the `ObjCPropertyDecl`s to their `ObjCIvarDecl`s, but if we wanted to, this debug-info patch is a pre-requisite.
---
llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp | 2 +-
llvm/test/DebugInfo/Generic/objc-property.ll | 26 ++++++++++++--------
2 files changed, 17 insertions(+), 11 deletions(-)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
index e40fb768027b8..7d7588c89fae2 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfUnit.cpp
@@ -1109,7 +1109,7 @@ void DwarfUnit::constructTypeDIE(DIE &Buffer, const DICompositeType *CTy) {
constructMemberDIE(Buffer, DDTy);
}
} else if (auto *Property = dyn_cast<DIObjCProperty>(Element)) {
- DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer);
+ DIE &ElemDie = createAndAddDIE(Property->getTag(), Buffer, Property);
StringRef PropertyName = Property->getName();
addString(ElemDie, dwarf::DW_AT_APPLE_property_name, PropertyName);
if (Property->getType())
diff --git a/llvm/test/DebugInfo/Generic/objc-property.ll b/llvm/test/DebugInfo/Generic/objc-property.ll
index 6dd0e01017780..d624f69d97b04 100644
--- a/llvm/test/DebugInfo/Generic/objc-property.ll
+++ b/llvm/test/DebugInfo/Generic/objc-property.ll
@@ -3,20 +3,20 @@
; CHECK: DW_TAG_structure_type
; CHECK: DW_AT_name ("Foo")
;
-; CHECK: DW_TAG_APPLE_property
+; CHECK: 0x[[AUTO_SYNTH:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("autoSynthProp")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
-; CHECK: DW_TAG_APPLE_property
+; CHECK: 0x[[SYNTH:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("synthProp")
; CHECK: DW_AT_APPLE_property_attribute
; CHECK-SAME: DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; FIXME: this should have a DW_AT_APPLE_property_getter tag
-; CHECK: DW_TAG_APPLE_property
+; CHECK: 0x[[GET:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customGetterProp")
; CHECK: DW_AT_APPLE_property_setter ("customGetter")
; CHECK: DW_AT_APPLE_property_attribute
@@ -24,7 +24,7 @@
; CHECK-SAME: DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; FIXME: this should have a DW_AT_APPLE_property_setter tag
-; CHECK: DW_TAG_APPLE_property
+; CHECK: 0x[[SET:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customSetterProp")
; CHECK: DW_AT_APPLE_property_getter ("customSetter:")
; CHECK: DW_AT_APPLE_property_attribute
@@ -32,7 +32,7 @@
; CHECK-SAME: DW_APPLE_PROPERTY_setter, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
; FIXME: the DW_AT_APPLE_property_(getter|setter) values are inverted
-; CHECK: DW_TAG_APPLE_property
+; CHECK: 0x[[ACCESSORS:[0-9a-f]+]]: DW_TAG_APPLE_property
; CHECK: DW_AT_APPLE_property_name ("customAccessorsProp")
; CHECK: DW_AT_APPLE_property_getter ("customSetter:")
; CHECK: DW_AT_APPLE_property_setter ("customGetter")
@@ -40,15 +40,21 @@
; CHECK-SAME: DW_APPLE_PROPERTY_getter, DW_APPLE_PROPERTY_assign, DW_APPLE_PROPERTY_readwrite,
; CHECK-SAME: DW_APPLE_PROPERTY_setter, DW_APPLE_PROPERTY_atomic, DW_APPLE_PROPERTY_unsafe_unretained
;
-; FIXME: missing link between DW_TAG_member and the associated DW_TAG_APPLE_property
; CHECK: DW_TAG_member
-; CHECK-NOT: DW_AT_APPLE_property
+; CHECK: DW_AT_name ("someBackingIvar")
+; CHECK: DW_AT_APPLE_property (0x[[SYNTH]])
+;
; CHECK: DW_TAG_member
-; CHECK-NOT: DW_AT_APPLE_property
+; CHECK: DW_AT_name ("_autoSynthProp")
+; CHECK: DW_AT_APPLE_property (0x[[AUTO_SYNTH]])
+;
; CHECK: DW_TAG_member
-; CHECK-NOT: DW_AT_APPLE_property
+; CHECK: DW_AT_name ("_customGetterProp")
+; CHECK: DW_AT_APPLE_property (0x[[GET]])
+;
; CHECK: DW_TAG_member
-; CHECK-NOT: DW_AT_APPLE_property
+; CHECK: DW_AT_name ("_customSetterProp")
+; CHECK: DW_AT_APPLE_property (0x[[SET]])
!llvm.module.flags = !{!0, !1}
!llvm.dbg.cu = !{!2}
More information about the llvm-commits
mailing list