[X86AsmParser] IntelExpression: End of Statement should check for valid end state
The following commit bfb7099eeb9b6f62510b1db0cb93a8c3cfa68236 added a special case for End of Statement that doesn't check if the state machine is rightfully in a state where ending is valid.
This PR suggest to revert this change to make EndOfStatement processed as any other tokens that are not consumable by the state machine.
Fixes https://github.com/llvm/llvm-project/issues/94446
Thank you for submitting a Pull Request (PR) to the LLVM Project!
This PR will be automatically labeled and the relevant teams will be notified.
If you wish to, you can add reviewers by using the "Reviewers" section on this page.
If this is not working for you, it is probably because you do not have write
permissions for the repository. In which case you can instead tag reviewers by
name in a comment by using @ followed by their GitHub username.
If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.
If you have further questions, they may be answered by the LLVM GitHub User Guide.
You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.
@llvm/pr-subscribers-mc
@llvm/pr-subscribers-backend-x86
Author: None (v01dXYZ)
Changes
The following commit bfb7099eeb9b6f62510b1db0cb93a8c3cfa68236 added a special case for End of Statement that doesn't check if the state machine is rightfully in a state where ending is valid.
This PR suggest to revert this change to make EndOfStatement processed as any other tokens that are not consumable by the state machine.
Fixes https://github.com/llvm/llvm-project/issues/94446
Full diff: https://github.com/llvm/llvm-project/pull/95677.diff
1 Files Affected:
- (modified) llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp (+2-4)
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index 6623106109316..d338607acbabe 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -473,7 +473,8 @@ class X86AsmParser : public MCTargetAsmParser {
unsigned getLength() const { return CurType.Length; }
int64_t getImm() { return Imm + IC.execute(); }
bool isValidEndState() const {
- return State == IES_RBRAC || State == IES_INTEGER;
+ return State == IES_RBRAC || State == IES_RPAREN ||
+ State == IES_INTEGER || State == IES_REGISTER;
}
// Is the intel expression appended after an operand index.
@@ -1897,9 +1898,6 @@ bool X86AsmParser::ParseIntelExpression(IntelExprStateMachine &SM, SMLoc &End) {
case AsmToken::Error:
return Error(getLexer().getErrLoc(), getLexer().getErr());
break;
- case AsmToken::EndOfStatement:
- Done = true;
- break;
case AsmToken::Real:
// DotOperator: [ebx].0
UpdateLocLex = false;
FYI, linux CI fails because of a (flaky ?) lldb test with a timeout.
I repush the same commit to relaunch the CI. If you know a way to relaunch a failed CI pipeline, I want to know it too.
Ping
AsmParser is shared by assembler and fronr-end. Could you add a .s test to show what you fixed?
Ping.
I added the case from the issue.
I wonder if a customised AsmParser could potentially do it. Is it possible and worth it according to you ? There is certainly a reason why this machinery was not used at the time.
I wonder if a customised
AsmParsercould potentially do it. Is it possible and worth it according to you ? There is certainly a reason why this machinery was not used at the time.
TBH, I am not clear about the history. This is a good wish of myself.
FYI I don't have merge rights. if you consider the patch good enough, could you merge it on my behalf ?
I'll take a look at trying to replace some parts of the custom Expression Parser by the generic AsmParser at the beginning of next month as it is an interesting task about a very specific part of LLVM (thus perfect for a beginner like me). The code I'll write won't matter as much as the documentation about the suggestions.
FYI I don't have merge rights. if you consider the patch good enough, could you merge it on my behalf ?
Sure.
@v01dXYZ Congratulations on having your first Pull Request (PR) merged into the LLVM Project!
Your changes will be combined with recent changes from other authors, then tested by our build bots. If there is a problem with a build, you may receive a report in an email or a comment on this PR.
Please check whether problems have been caused by your change specifically, as the builds can include changes from many authors. It is not uncommon for your change to be included in a build that fails due to someone else's changes, or infrastructure issues.
How to do this, and the rest of the post-merge process, is covered in detail here.
If your change does cause a problem, it may be reverted, or you can revert it yourself. This is a normal part of LLVM development. You can fix your changes and open a new PR to merge them again.
If you don't get any reports, no action is required from you. Your changes are working as expected, well done!
LLVM Buildbot has detected a new failure on builder llvm-clang-aarch64-darwin running on doug-worker-4 while building llvm at step 6 "test-build-unified-tree-check-all".
Full details are available at: https://lab.llvm.org/buildbot/#/builders/190/builds/1904
Here is the relevant piece of the build log for the reference:
Step 6 (test-build-unified-tree-check-all) failure: test (failure)
******************** TEST 'LLVM :: Analysis/StructuralHash/structural-hash-printer.ll' FAILED ********************
Exit Code: 1
Command Output (stderr):
--
RUN: at line 1: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt -passes='print<structural-hash>' -disable-output /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt '-passes=print<structural-hash>' -disable-output /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
RUN: at line 2: /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt -passes='print<structural-hash><detailed>' -disable-output /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll 2>&1 | /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll -check-prefix=DETAILED-HASH
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/opt '-passes=print<structural-hash><detailed>' -disable-output /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
+ /Users/buildbot/buildbot-root/aarch64-darwin/build/bin/FileCheck /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll -check-prefix=DETAILED-HASH
[1m/Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll:21:18: [0m[0;1;31merror: [0m[1mDETAILED-HASH: expected string not found in input
[0m; DETAILED-HASH: Module Hash: {{([a-z0-9]{14,})}}
[0;1;32m ^
[0m[1m<stdin>:1:1: [0m[0;1;30mnote: [0m[1mscanning from here
[0mModule Hash: 8d6dc22990ebe
[0;1;32m^
[0m
Input file: <stdin>
Check file: /Users/buildbot/buildbot-root/aarch64-darwin/llvm-project/llvm/test/Analysis/StructuralHash/structural-hash-printer.ll
-dump-input=help explains the following input dump.
Input was:
<<<<<<
[1m[0m[0;1;30m 1: [0m[1m[0;1;46mModule Hash: 8d6dc22990ebe [0m
[0;1;31mcheck:21 X~~~~~~~~~~~~~~~~~~~~~~~~~~ error: no match found
[0m[0;1;30m 2: [0m[1m[0;1;46mFunction f1 Hash: 7062c67049c6f99c [0m
[0;1;31mcheck:21 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[0m[0;1;30m 3: [0m[1m[0;1;46mFunction f2 Hash: 1e47c72d08a2afcd [0m
[0;1;31mcheck:21 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[0m>>>>>>
--
********************