Skip to content

DebugInfo: Avoid some MMI::hasDebugInfo checks #100333

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 26, 2024

Conversation

arsenm
Copy link
Contributor

@arsenm arsenm commented Jul 24, 2024

I assume getSubprogram will do the correct thing in hasDebugInfo,
and this is redundant with the debug_compile_units distance check.
This is in preparation for removing the field.

Copy link
Contributor Author

arsenm commented Jul 24, 2024

@arsenm arsenm marked this pull request as ready for review July 24, 2024 09:14
@llvmbot
Copy link
Member

llvmbot commented Jul 24, 2024

@llvm/pr-subscribers-llvm-selectiondag
@llvm/pr-subscribers-backend-nvptx
@llvm/pr-subscribers-debuginfo

@llvm/pr-subscribers-backend-x86

Author: Matt Arsenault (arsenm)

Changes

I assume getSubprogram will do the correct thing in hasDebugInfo,
and this is redundant with the debug_compile_units distance check.
This is in preparation for removing the field.


Full diff: https://github.com/llvm/llvm-project/pull/100333.diff

2 Files Affected:

  • (modified) llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp (+3-6)
  • (modified) llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp (+4-3)
diff --git a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
index 6c70c47de8822..ed99eb3c459e5 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DebugHandlerBase.cpp
@@ -241,10 +241,7 @@ bool DebugHandlerBase::isUnsignedDIType(const DIType *Ty) {
          Ty->getTag() == dwarf::DW_TAG_unspecified_type;
 }
 
-static bool hasDebugInfo(const MachineModuleInfo *MMI,
-                         const MachineFunction *MF) {
-  if (!MMI->hasDebugInfo())
-    return false;
+static bool hasDebugInfo(const MachineFunction *MF) {
   auto *SP = MF->getFunction().getSubprogram();
   if (!SP)
     return false;
@@ -258,7 +255,7 @@ static bool hasDebugInfo(const MachineModuleInfo *MMI,
 void DebugHandlerBase::beginFunction(const MachineFunction *MF) {
   PrevInstBB = nullptr;
 
-  if (!Asm || !hasDebugInfo(MMI, MF)) {
+  if (!Asm || !hasDebugInfo(MF)) {
     skippedNonDebugFunction();
     return;
   }
@@ -415,7 +412,7 @@ void DebugHandlerBase::endInstruction() {
 }
 
 void DebugHandlerBase::endFunction(const MachineFunction *MF) {
-  if (Asm && hasDebugInfo(MMI, MF))
+  if (Asm && hasDebugInfo(MF))
     endFunctionImpl(MF);
   DbgValues.clear();
   DbgLabels.clear();
diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
index 5f1f315c5ab24..fbce7e92b7781 100644
--- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp
@@ -1148,14 +1148,15 @@ sortGlobalExprs(SmallVectorImpl<DwarfCompileUnit::GlobalExpr> &GVEs) {
 void DwarfDebug::beginModule(Module *M) {
   DebugHandlerBase::beginModule(M);
 
-  if (!Asm || !MMI->hasDebugInfo())
+  if (!Asm)
     return;
 
   unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
                                        M->debug_compile_units_end());
+  if (NumDebugCUs == 0)
+    return;
+
   assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");
-  assert(MMI->hasDebugInfo() &&
-         "DebugInfoAvailabilty unexpectedly not initialized");
   SingleCU = NumDebugCUs == 1;
   DenseMap<DIGlobalVariable *, SmallVector<DwarfCompileUnit::GlobalExpr, 1>>
       GVMap;

@arsenm arsenm force-pushed the users/arsenm/remove-disable-debug-info-print branch from df45fdf to 752f021 Compare July 24, 2024 11:17
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from cdc7ef3 to 442532e Compare July 24, 2024 11:17
@arsenm arsenm force-pushed the users/arsenm/remove-disable-debug-info-print branch from 752f021 to a0ea675 Compare July 24, 2024 11:54
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 442532e to 1e3fdb2 Compare July 24, 2024 11:54
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Jul 24, 2024
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 1e3fdb2 to 6367409 Compare July 24, 2024 11:56
@arsenm arsenm force-pushed the users/arsenm/remove-disable-debug-info-print branch from a0ea675 to 167cea6 Compare July 24, 2024 15:38
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 6367409 to 47fbdca Compare July 24, 2024 15:39
@arsenm arsenm force-pushed the users/arsenm/remove-disable-debug-info-print branch from 167cea6 to 6f82349 Compare July 24, 2024 18:30
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 47fbdca to 0d0fe00 Compare July 24, 2024 18:30
@arsenm arsenm force-pushed the users/arsenm/remove-disable-debug-info-print branch from 6f82349 to 50c0a81 Compare July 25, 2024 07:10
Base automatically changed from users/arsenm/remove-disable-debug-info-print to main July 25, 2024 12:39
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 0d0fe00 to f3cbd76 Compare July 26, 2024 06:37
@arsenm arsenm changed the base branch from main to users/arsenm/move-current-call-site-out-of-mmi July 26, 2024 06:37
@arsenm arsenm force-pushed the users/arsenm/move-current-call-site-out-of-mmi branch from 0df69b8 to 4f683ee Compare July 26, 2024 07:27
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from f3cbd76 to 9f6b09e Compare July 26, 2024 07:31
return;

unsigned NumDebugCUs = std::distance(M->debug_compile_units_begin(),
M->debug_compile_units_end());
if (NumDebugCUs == 0)
return;

assert(NumDebugCUs > 0 && "Asm unexpectedly initialized");
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Redundant with the above check.

Copy link
Contributor Author

arsenm commented Jul 26, 2024

Merge activity

  • Jul 26, 4:56 AM EDT: @arsenm started a stack merge that includes this pull request via Graphite.
  • Jul 26, 5:03 AM EDT: Graphite rebased this pull request as part of a merge.
  • Jul 26, 5:06 AM EDT: @arsenm merged this pull request with Graphite.

@arsenm arsenm force-pushed the users/arsenm/move-current-call-site-out-of-mmi branch from 2844209 to 0db6ff6 Compare July 26, 2024 08:58
Base automatically changed from users/arsenm/move-current-call-site-out-of-mmi to main July 26, 2024 09:02
I assume getSubprogram will do the correct thing in hasDebugInfo,
and this is redundant with the debug_compile_units distance check.
This is in preparation for removing the field.
@arsenm arsenm force-pushed the users/arsenm/avoid-checking-mmi-hasdebuginfo branch from 9f6b09e to 0f250dc Compare July 26, 2024 09:02
@arsenm arsenm merged commit 4ce3993 into main Jul 26, 2024
4 of 6 checks passed
@arsenm arsenm deleted the users/arsenm/avoid-checking-mmi-hasdebuginfo branch July 26, 2024 09:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants