Skip to content

[CodeGen][Remarks] Add the function name to the stack size remark #69346

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
Oct 22, 2023

Conversation

jroelofs
Copy link
Contributor

It is already present in the yaml, but missing from the printed diagnostics.

@llvmbot
Copy link
Member

llvmbot commented Oct 17, 2023

@llvm/pr-subscribers-backend-x86

@llvm/pr-subscribers-backend-aarch64

Author: Jon Roelofs (jroelofs)

Changes

It is already present in the yaml, but missing from the printed diagnostics.


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

3 Files Affected:

  • (modified) llvm/lib/CodeGen/PrologEpilogInserter.cpp (+2-1)
  • (modified) llvm/test/CodeGen/AArch64/prologue-epilogue-remarks.mir (+9-3)
  • (modified) llvm/test/CodeGen/X86/prologue-epilogue-remarks.mir (+9-3)
diff --git a/llvm/lib/CodeGen/PrologEpilogInserter.cpp b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
index 9514a0875a7854b..dd33b47a02609ff 100644
--- a/llvm/lib/CodeGen/PrologEpilogInserter.cpp
+++ b/llvm/lib/CodeGen/PrologEpilogInserter.cpp
@@ -337,7 +337,8 @@ bool PEI::runOnMachineFunction(MachineFunction &MF) {
     return MachineOptimizationRemarkAnalysis(DEBUG_TYPE, "StackSize",
                                              MF.getFunction().getSubprogram(),
                                              &MF.front())
-           << ore::NV("NumStackBytes", StackSize) << " stack bytes in function";
+           << ore::NV("NumStackBytes", StackSize) << " stack bytes in function '"
+           << ore::NV("Function", MF.getFunction().getName()) << "'";
   });
 
   delete RS;
diff --git a/llvm/test/CodeGen/AArch64/prologue-epilogue-remarks.mir b/llvm/test/CodeGen/AArch64/prologue-epilogue-remarks.mir
index 4bc1b968d17089e..223719d44d169d8 100644
--- a/llvm/test/CodeGen/AArch64/prologue-epilogue-remarks.mir
+++ b/llvm/test/CodeGen/AArch64/prologue-epilogue-remarks.mir
@@ -11,7 +11,9 @@ stack:
 # CHECK:      Function:        fun0
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '16'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun0
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 constants:
 body:             |
@@ -29,7 +31,9 @@ stack:
 # CHECK:      Function:        fun1
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '32'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun1
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 constants:
 body:             |
@@ -47,7 +51,9 @@ stack:
 # CHECK:      Function:        fun2
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '1040'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun2
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 constants:
 body:             |
diff --git a/llvm/test/CodeGen/X86/prologue-epilogue-remarks.mir b/llvm/test/CodeGen/X86/prologue-epilogue-remarks.mir
index f0c6121bd98e775..39d06c2909f9e0b 100644
--- a/llvm/test/CodeGen/X86/prologue-epilogue-remarks.mir
+++ b/llvm/test/CodeGen/X86/prologue-epilogue-remarks.mir
@@ -17,7 +17,9 @@ stack:
 # CHECK-NEXT: Function:        fun0
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '8'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun0
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 
 constants:
@@ -36,7 +38,9 @@ stack:
 # CHECK-NEXT: Function:        fun1
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '20'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun1
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 constants:
 body:             |
@@ -54,7 +58,9 @@ stack:
 # CHECK-NEXT: Function:        fun2
 # CHECK-NEXT: Args:
 # CHECK-NEXT:   - NumStackBytes:   '1024'
-# CHECK-NEXT:   - String:          ' stack bytes in function'
+# CHECK-NEXT:   - String:          ' stack bytes in function '''
+# CHECK-NEXT:   - Function: fun2
+# CHECK-NEXT:   - String: ''''
 # CHECK-NEXT: ...
 constants:
 body:             |

@github-actions
Copy link

github-actions bot commented Oct 17, 2023

✅ With the latest revision this PR passed the C/C++ code formatter.

It is already present in the yaml, but missing from the printed diagnostics.
@francisvm
Copy link
Collaborator

Isn't the diagnostic shown at the beginning of the function?

@jroelofs
Copy link
Contributor Author

Isn't the diagnostic shown at the beginning of the function?

If the function has debuginfo, it points at the { which might not be on the same line as the function name. So you get diagnostics like:

test.c:10:1: remark: 8 stack bytes in function [-Rpass-analysis=prologepilog]
{
^

Compiler-generated functions without debug info explaining where they came from are even worse:

note: could not determine the original source location for test.c:0:0
remark: 16 stack bytes in function [-Rpass-analysis=prologepilog]
note: could not determine the original source location for test.c:0:0

Copy link
Collaborator

@francisvm francisvm left a comment

Choose a reason for hiding this comment

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

LGTM then, thanks

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