-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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
improve warning #75762
Closed
MaskRay
wants to merge
1
commit into
users/MaskRay/spr/main.improve-warning
from
users/MaskRay/spr/improve-warning
Closed
improve warning #75762
MaskRay
wants to merge
1
commit into
users/MaskRay/spr/main.improve-warning
from
users/MaskRay/spr/improve-warning
Conversation
This file contains 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
Created using spr 1.3.4
@llvm/pr-subscribers-mc Author: Fangrui Song (MaskRay) ChangesFull diff: https://github.com/llvm/llvm-project/pull/75762.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index ef622e08606cbf..1d40ce35c1b416 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3079,12 +3079,14 @@ bool X86AsmParser::ParseMemOperand(unsigned SegReg, const MCExpr *Disp,
" is not within [-2147483648, 2147483647]");
} else if (!Is16) {
if (!isUInt<32>(Imm < 0 ? -uint64_t(Imm) : uint64_t(Imm))) {
- Warning(BaseLoc,
- "displacement " + Twine(Imm) + " shortened to signed 32-bit");
+ Warning(BaseLoc, "displacement " + Twine(Imm) +
+ " shortened to 32-bit signed " +
+ Twine(static_cast<int32_t>(Imm)));
}
} else if (!isUInt<16>(Imm < 0 ? -uint64_t(Imm) : uint64_t(Imm))) {
- Warning(BaseLoc,
- "displacement " + Twine(Imm) + " shortened to signed 16-bit");
+ Warning(BaseLoc, "displacement " + Twine(Imm) +
+ " shortened to 16-bit signed " +
+ Twine(static_cast<int16_t>(Imm)));
}
}
}
diff --git a/llvm/test/MC/X86/displacement-overflow.s b/llvm/test/MC/X86/displacement-overflow.s
index 626003a29109ea..2882147af48280 100644
--- a/llvm/test/MC/X86/displacement-overflow.s
+++ b/llvm/test/MC/X86/displacement-overflow.s
@@ -15,11 +15,13 @@ leaq -0x80000001(%rip), %rax
movl 0xffffffff(%eax), %eax
leal -0xffffffff(%eax), %eax
-# CHECK: [[#@LINE+1]]:19: warning: displacement 4294967296 shortened to signed 32-bit
+# CHECK: [[#@LINE+1]]:19: warning: displacement 4294967296 shortened to 32-bit signed 0
movl 0xffffffff+1(%eax), %eax
-# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967296 shortened to signed 32-bit
+# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967296 shortened to 32-bit signed 0
leal -0xffffffff-1(%eax), %eax
+# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967297 shortened to 32-bit signed -1
+leal -0xffffffff-2(%eax), %eax
{disp8} leal 0x100(%ebx), %eax
{disp8} leal -0x100(%ebx), %eax
@@ -29,8 +31,8 @@ leal -0xffffffff-1(%eax), %eax
movw $0, 0xffff(%bp)
movw $0, -0xffff(%si)
-# 32: [[#@LINE+1]]:19: warning: displacement 65536 shortened to signed 16-bit
+# 32: [[#@LINE+1]]:19: warning: displacement 65536 shortened to 16-bit signed 0
movw $0, 0xffff+1(%bp)
-# 32: [[#@LINE+1]]:20: warning: displacement -65536 shortened to signed 16-bit
+# 32: [[#@LINE+1]]:20: warning: displacement -65536 shortened to 16-bit signed 0
movw $0, -0xffff-1(%si)
.endif
|
@llvm/pr-subscribers-backend-x86 Author: Fangrui Song (MaskRay) ChangesFull diff: https://github.com/llvm/llvm-project/pull/75762.diff 2 Files Affected:
diff --git a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
index ef622e08606cbf..1d40ce35c1b416 100644
--- a/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
+++ b/llvm/lib/Target/X86/AsmParser/X86AsmParser.cpp
@@ -3079,12 +3079,14 @@ bool X86AsmParser::ParseMemOperand(unsigned SegReg, const MCExpr *Disp,
" is not within [-2147483648, 2147483647]");
} else if (!Is16) {
if (!isUInt<32>(Imm < 0 ? -uint64_t(Imm) : uint64_t(Imm))) {
- Warning(BaseLoc,
- "displacement " + Twine(Imm) + " shortened to signed 32-bit");
+ Warning(BaseLoc, "displacement " + Twine(Imm) +
+ " shortened to 32-bit signed " +
+ Twine(static_cast<int32_t>(Imm)));
}
} else if (!isUInt<16>(Imm < 0 ? -uint64_t(Imm) : uint64_t(Imm))) {
- Warning(BaseLoc,
- "displacement " + Twine(Imm) + " shortened to signed 16-bit");
+ Warning(BaseLoc, "displacement " + Twine(Imm) +
+ " shortened to 16-bit signed " +
+ Twine(static_cast<int16_t>(Imm)));
}
}
}
diff --git a/llvm/test/MC/X86/displacement-overflow.s b/llvm/test/MC/X86/displacement-overflow.s
index 626003a29109ea..2882147af48280 100644
--- a/llvm/test/MC/X86/displacement-overflow.s
+++ b/llvm/test/MC/X86/displacement-overflow.s
@@ -15,11 +15,13 @@ leaq -0x80000001(%rip), %rax
movl 0xffffffff(%eax), %eax
leal -0xffffffff(%eax), %eax
-# CHECK: [[#@LINE+1]]:19: warning: displacement 4294967296 shortened to signed 32-bit
+# CHECK: [[#@LINE+1]]:19: warning: displacement 4294967296 shortened to 32-bit signed 0
movl 0xffffffff+1(%eax), %eax
-# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967296 shortened to signed 32-bit
+# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967296 shortened to 32-bit signed 0
leal -0xffffffff-1(%eax), %eax
+# CHECK: [[#@LINE+1]]:20: warning: displacement -4294967297 shortened to 32-bit signed -1
+leal -0xffffffff-2(%eax), %eax
{disp8} leal 0x100(%ebx), %eax
{disp8} leal -0x100(%ebx), %eax
@@ -29,8 +31,8 @@ leal -0xffffffff-1(%eax), %eax
movw $0, 0xffff(%bp)
movw $0, -0xffff(%si)
-# 32: [[#@LINE+1]]:19: warning: displacement 65536 shortened to signed 16-bit
+# 32: [[#@LINE+1]]:19: warning: displacement 65536 shortened to 16-bit signed 0
movw $0, 0xffff+1(%bp)
-# 32: [[#@LINE+1]]:20: warning: displacement -65536 shortened to signed 16-bit
+# 32: [[#@LINE+1]]:20: warning: displacement -65536 shortened to 16-bit signed 0
movw $0, -0xffff-1(%si)
.endif
|
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.
No description provided.