Skip to content

Conversation

dzhidzhoev
Copy link
Member

After #139914, DIBilder::finalize() finalizes both declaration and definition DISubprograms.
Therefore, there is no need to call DIBuilder::finalizeSubprogram() right before DIBilder::finalize().

After llvm#139914, `DIBilder::finalize()` finalizes both declaration
and definition DISubprograms. Therefore, there is no need to call
`DIBuilder::finalizeSubprogram()` right before `DIBilder::finalize()`.
@llvmbot
Copy link
Member

llvmbot commented Aug 27, 2025

@llvm/pr-subscribers-llvm-transforms

@llvm/pr-subscribers-debuginfo

Author: Vladislav Dzhidzhoev (dzhidzhoev)

Changes

After #139914, DIBilder::finalize() finalizes both declaration and definition DISubprograms.
Therefore, there is no need to call DIBuilder::finalizeSubprogram() right before DIBilder::finalize().


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

3 Files Affected:

  • (modified) llvm/lib/CodeGen/MachineOutliner.cpp (-3)
  • (modified) llvm/lib/Transforms/IPO/IROutliner.cpp (-3)
  • (modified) llvm/lib/Transforms/Utils/Debugify.cpp (-1)
diff --git a/llvm/lib/CodeGen/MachineOutliner.cpp b/llvm/lib/CodeGen/MachineOutliner.cpp
index b0bce2c21a470..c7f09d577c4fa 100644
--- a/llvm/lib/CodeGen/MachineOutliner.cpp
+++ b/llvm/lib/CodeGen/MachineOutliner.cpp
@@ -1017,9 +1017,6 @@ MachineFunction *MachineOutliner::createOutlinedFunction(
         /* Outlined code is optimized code by definition. */
         DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
 
-    // Don't add any new variables to the subprogram.
-    DB.finalizeSubprogram(OutlinedSP);
-
     // Attach subprogram to the function.
     F->setSubprogram(OutlinedSP);
     // We're done with the DIBuilder.
diff --git a/llvm/lib/Transforms/IPO/IROutliner.cpp b/llvm/lib/Transforms/IPO/IROutliner.cpp
index c57981ae4ca0d..fdf0c3ac8007d 100644
--- a/llvm/lib/Transforms/IPO/IROutliner.cpp
+++ b/llvm/lib/Transforms/IPO/IROutliner.cpp
@@ -686,9 +686,6 @@ Function *IROutliner::createFunction(Module &M, OutlinableGroup &Group,
         /* Outlined code is optimized code by definition. */
         DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
 
-    // Don't add any new variables to the subprogram.
-    DB.finalizeSubprogram(OutlinedSP);
-
     // Attach subprogram to the function.
     F->setSubprogram(OutlinedSP);
     // We're done with the DIBuilder.
diff --git a/llvm/lib/Transforms/Utils/Debugify.cpp b/llvm/lib/Transforms/Utils/Debugify.cpp
index 7063cde5263b4..5a09b7385f2be 100644
--- a/llvm/lib/Transforms/Utils/Debugify.cpp
+++ b/llvm/lib/Transforms/Utils/Debugify.cpp
@@ -254,7 +254,6 @@ bool llvm::applyDebugifyMetadata(
     }
     if (ApplyToMF)
       ApplyToMF(DIB, F);
-    DIB.finalizeSubprogram(SP);
   }
   DIB.finalize();
 

Copy link
Member

@jmorse jmorse left a comment

Choose a reason for hiding this comment

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

LGTM; as with the other patch, do keep an eye on whether there's a compile time consequence (it seems very unlikely).

@dzhidzhoev dzhidzhoev merged commit 1b79150 into llvm:main Aug 27, 2025
13 checks passed
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