[PATCH] D47483: [AArch64][AsmParser] Fix segfault on illegal fpimm.
Sander de Smalen via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue May 29 09:00:41 PDT 2018
sdesmalen created this revision.
sdesmalen added reviewers: rengolin, fhahn, samparker, SjoerdMeijer.
Herald added a reviewer: javed.absar.
Herald added a subscriber: kristof.beyls.
Floating point immediate combining a negative sign and
a hexadecimal number, e.g. #-0x0 caused the compiler to crash.
https://reviews.llvm.org/D47483
Files:
lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
test/MC/AArch64/neon-diagnostics.s
Index: test/MC/AArch64/neon-diagnostics.s
===================================================================
--- test/MC/AArch64/neon-diagnostics.s
+++ test/MC/AArch64/neon-diagnostics.s
@@ -279,10 +279,15 @@
//----------------------------------------------------------------------
// invalid vector type (2s, 4s, 2d)
fmov v0.4h, #1.0
+ // invalid immediate (negative hexadecimal encoding)
+ fmov v0.4s, #-0x0
// CHECK:ERROR: error: invalid operand for instruction
// CHECK:ERROR: fmov v0.4h, #1.0
// CHECK:ERROR: ^
+// CHECK-ERROR: error: encoded floating point value out of range
+// CHECK-ERROR: fmov v0.4s, #-0x0
+// CHECK-ERROR: ^
//----------------------------------------------------------------------
// Vector Move - register
Index: lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
===================================================================
--- lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
+++ lib/Target/AArch64/AsmParser/AArch64AsmParser.cpp
@@ -2282,9 +2282,9 @@
const AsmToken &Tok = Parser.getTok();
if (Tok.is(AsmToken::Real) || Tok.is(AsmToken::Integer)) {
int64_t Val;
- if (Tok.is(AsmToken::Integer) && !isNegative && Tok.getString().startswith("0x")) {
+ if (Tok.is(AsmToken::Integer) && Tok.getString().startswith("0x")) {
Val = Tok.getIntVal();
- if (Val > 255 || Val < 0) {
+ if (Val > 255 || isNegative) {
TokError("encoded floating point value out of range");
return MatchOperand_ParseFail;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D47483.148920.patch
Type: text/x-patch
Size: 1587 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180529/e9acb636/attachment.bin>
More information about the llvm-commits
mailing list