Skip to content

Conversation

@aemerson
Copy link
Contributor

[ARM] Fix not saving FP when required to in frame-pointer=non-leaf.

When the stars align to conspire against stack alignment, when we have
frame-pointer=non-leaf we can incorrectly skip preserving fp/r7 in the prolog.
The fix here first makes sure we're using the right frame pointer register in
the context of preserving the incoming FP, and then make sure that we save
the FP when re-alignment is known to be necessary.

rdar://162462271

[MC] Fix accidentally eating the newline when handling a comment char at the end of the line.

If we have a target where both # and ## are valid comment strings,
a line ending in # would trigger the lexer to eat 2 characters
and therefore lex the next line as a comment. Oops. This was introduced
in 4946db1

Copy link
Contributor Author

This stack of pull requests is managed by Graphite. Learn more about stacking.

… at the end of the line.

If we have a target where both # and ## are valid comment strings,
a line ending in # would trigger the lexer to eat 2 characters
and therefore lex the *next* line as a comment. Oops. This was introduced
in 4946db1
@aemerson aemerson force-pushed the users/amara/asmlexer-comment branch from 07be0d3 to f528592 Compare October 26, 2025 03:26
@github-actions
Copy link

⚠️ C/C++ code formatter, clang-format found issues in your code. ⚠️

You can test this locally with the following command:
git-clang-format --diff origin/main HEAD --extensions cpp -- llvm/lib/MC/MCParser/AsmLexer.cpp llvm/lib/Target/ARM/ARMFrameLowering.cpp --diff_from_common_commit

⚠️
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing origin/main to the base branch/commit you want to compare against.
⚠️

View the diff from clang-format here.
diff --git a/llvm/lib/MC/MCParser/AsmLexer.cpp b/llvm/lib/MC/MCParser/AsmLexer.cpp
index 8062ce88a..a6188f067 100644
--- a/llvm/lib/MC/MCParser/AsmLexer.cpp
+++ b/llvm/lib/MC/MCParser/AsmLexer.cpp
@@ -836,9 +836,9 @@ AsmToken AsmLexer::LexToken() {
 
   if (isAtStartOfComment(TokStart)) {
     StringRef CommentString = MAI.getCommentString();
-    // For multi-char comment strings, advance CurPtr only if we matched the full
-    // string. This stops us from accidentally eating the newline if the current
-    // line ends in a single comment char.
+    // For multi-char comment strings, advance CurPtr only if we matched the
+    // full string. This stops us from accidentally eating the newline if the
+    // current line ends in a single comment char.
     if (CommentString.size() > 1 &&
         StringRef(TokStart, CommentString.size()) == CommentString) {
       CurPtr += CommentString.size() - 1;

@aemerson aemerson closed this Oct 26, 2025
@aemerson aemerson deleted the users/amara/asmlexer-comment branch October 26, 2025 03:27
@aemerson aemerson restored the users/amara/asmlexer-comment branch October 26, 2025 03:28
@aemerson aemerson changed the title [ARM] Fix not saving FP when required to in frame-pointer=non-leaf. [Ignore] Oct 26, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants