Allow .alt_entry symbols to pass the .cfi nesting check#82268
Merged
Conversation
Member
|
@llvm/pr-subscribers-mc @llvm/pr-subscribers-backend-aarch64 Author: Jon Roelofs (jroelofs) ChangesFixes: #82261 Full diff: https://github.com/llvm/llvm-project/pull/82268.diff 2 Files Affected:
diff --git a/llvm/lib/MC/MCParser/AsmParser.cpp b/llvm/lib/MC/MCParser/AsmParser.cpp
index 8e508dbdb1c69b..e8dc078c9610c2 100644
--- a/llvm/lib/MC/MCParser/AsmParser.cpp
+++ b/llvm/lib/MC/MCParser/AsmParser.cpp
@@ -44,6 +44,7 @@
#include "llvm/MC/MCSection.h"
#include "llvm/MC/MCStreamer.h"
#include "llvm/MC/MCSymbol.h"
+#include "llvm/MC/MCSymbolMachO.h"
#include "llvm/MC/MCTargetOptions.h"
#include "llvm/MC/MCValue.h"
#include "llvm/Support/Casting.h"
@@ -1950,7 +1951,9 @@ bool AsmParser::parseStatement(ParseStatementInfo &Info,
Lex();
}
- if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc && Sym->isExternal())
+ if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc &&
+ Sym->isExternal() &&
+ (!isa<MCSymbolMachO>(Sym) || !cast<MCSymbolMachO>(Sym)->isAltEntry()))
return Error(StartTokLoc, "non-private labels cannot appear between "
".cfi_startproc / .cfi_endproc pairs") &&
Error(*CFIStartProcLoc, "previous .cfi_startproc was here");
diff --git a/llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s b/llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s
index 235b7d44809929..6a4dda3a77f05a 100644
--- a/llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s
+++ b/llvm/test/MC/AArch64/cfi-bad-nesting-darwin.s
@@ -8,6 +8,8 @@
.p2align 2
_locomotive:
.cfi_startproc
+ .alt_entry _engineer
+_engineer:
ret
; It is invalid to have a non-private label between .cfi_startproc and
@@ -17,7 +19,7 @@ _locomotive:
.p2align 2
_caboose:
; DARWIN: [[#@LINE-1]]:1: error: non-private labels cannot appear between .cfi_startproc / .cfi_endproc pairs
-; DARWIN: [[#@LINE-10]]:2: error: previous .cfi_startproc was here
+; DARWIN: [[#@LINE-12]]:2: error: previous .cfi_startproc was here
ret
.cfi_endproc
|
MaskRay
reviewed
Feb 24, 2024
| if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc && Sym->isExternal()) | ||
| if (MAI.hasSubsectionsViaSymbols() && CFIStartProcLoc && | ||
| Sym->isExternal() && | ||
| (!isa<MCSymbolMachO>(Sym) || !cast<MCSymbolMachO>(Sym)->isAltEntry())) |
Member
There was a problem hiding this comment.
Since only MCAsmInfoDarwin sets hasSubsectionsViaSymbols. The isa<MCSymbolMachO>(Sym) check is unneeded.
MaskRay
approved these changes
Feb 24, 2024
| .p2align 2 | ||
| _locomotive: | ||
| .cfi_startproc | ||
| .alt_entry _engineer |
Member
There was a problem hiding this comment.
Add a comment that a N_ALT_ENTRY symbol can be in the middle of a subsection?
Member
|
This is a good candidate for release/18.x |
Contributor
Author
|
/cherry-pick 5b91647 |
Member
Error: Command failed due to missing milestone. |
Contributor
Author
|
/cherry-pick 5b91647 |
llvmbot
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Feb 28, 2024
A symbol with an `N_ALT_ENTRY` attribute may be defined in the middle of
a subsection, so it is reasonable to opt them out of the
`.cfi_{start,end}proc` nesting check.
Fixes: llvm#82261
(cherry picked from commit 5b91647)
Member
|
/pull-request #83336 |
llvmbot
pushed a commit
to llvmbot/llvm-project
that referenced
this pull request
Mar 11, 2024
A symbol with an `N_ALT_ENTRY` attribute may be defined in the middle of
a subsection, so it is reasonable to opt them out of the
`.cfi_{start,end}proc` nesting check.
Fixes: llvm#82261
(cherry picked from commit 5b91647)
Closed
MaskRay
added a commit
that referenced
this pull request
Jul 2, 2024
The current `setAtom` is inaccurate: a `.alt_entry` label can also be recognized as an atom. This is mostly benign, but might cause two locations only separated by an `.alt_entry` to have different atoms. https://reviews.llvm.org/D153167 changed a `evaluateKnownAbsolute` to `evaluateAsAbsolute` and would not fold `A-B` even if they are only separated by a `.alt_entry` label, leading to a spurious error `invalid CFI advance_loc expression`. The fix is similar to #82268: add a special case for `.alt_entry`. Fix #97116 Pull Request: #97479
mylai-mtk
pushed a commit
to mylai-mtk/llvm-project
that referenced
this pull request
Jul 12, 2024
A symbol with an `N_ALT_ENTRY` attribute may be defined in the middle of
a subsection, so it is reasonable to opt them out of the
`.cfi_{start,end}proc` nesting check.
Fixes: llvm#82261
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
A symbol with an
N_ALT_ENTRYattribute may be defined in the middle of a subsection, so it is reasonable to opt them out of the.cfi_{start,end}procnesting check.Fixes: #82261