disas/libvixl: Fix VIXL_FALLTHROUGH macro for QEMU
PATCH 1/1 disas/libvixl: Fix VIXL_FALLTHROUGH macro for QEMU
It now prevents compiler warnings (enabled with -Wimplicit-fallthrough= or -Wextra) as intended.
---
I suggest to add and use a similar macro QEMU_FALLTHROUGH() for the rest of the code and can provide a patch if that's fine for everyone.
Regards
Stefan
disas/libvixl/vixl/globals.h | 2 ++ 1 file changed, 2 insertions(+)
disas/libvixl/vixl/globals.h +2 -0
@@ -112,6 +112,8 @@ inline void USE(T1, T2, T3, T4) {}// C++11(201103L). #if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L#define VIXL_FALLTHROUGH () [[clang::fallthrough]] //NOLINT +#elif defined(__GNUC__) +#define VIXL_FALLTHROUGH () __attribute__((fallthrough))#else #define VIXL_FALLTHROUGH () do {} while (0)#endif
Signature · 1 line
2.11.0
Am 13.05.2018 um 11:06 schrieb Stefan Weil:
Quoted 21 lines
It now prevents compiler warnings (enabled with -Wimplicit-fallthrough= or -Wextra) as intended.
Signed-off-by Stefan Weil <[email protected]>---
I suggest to add and use a similar macro
QEMU_FALLTHROUGH()for the rest of the code and can provide a patch if that's fine for everyone.Regards
Stefandisas/libvixl/vixl/globals.h | 2 ++ 1 file changed, 2 insertions(+)disas/libvixl/vixl/globals.h +0
-0
disas/libvixl/vixl/globals.h inline void USE(T1, T2, T3, T4) {} · line 119
Quoted 8 lines
disas/libvixl/vixl/globals.h +2
-0@@ -112,6 +112,8 @@ inline void USE(T1, T2, T3, T4) {}// C++11(201103L). #if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L#define VIXL_FALLTHROUGH () [[clang::fallthrough]] //NOLINT +#elif defined(__GNUC__) +#define VIXL_FALLTHROUGH () __attribute__((fallthrough))#else #define VIXL_FALLTHROUGH () do {} while (0)#endif
Even with the above patch, disas/libvixl raises a compiler warning for a fall through case. The patch below fixes that warning, but I am not sure whether a fall through is correct there.
Stefan
(quoted diff) +0 -0
b/disas/libvixl/vixl/a64/disasm-a64.cc
index 7a58a5c087..5481d94209 100644
disas/libvixl/vixl/a64/disasm-a64.cc +0 -0
@@ -2986,6 +2986,7 @@ int Disassembler::SubstituteImmediateField(const
Instruction* instr,
return 3;
}
}
+ VIXL_FALLTHROUGH(); // ???
}
case 'C': { // ICondB - Immediate Conditional Branch.
int64_t offset = instr->ImmCondBranch() << 2;Quoted 27 lines · Stefan Weil
Am 13.05.2018 um 11:06 schrieb Stefan Weil:
Quoted 26 lines
It now prevents compiler warnings (enabled with -Wimplicit-fallthrough= or -Wextra) as intended.
Signed-off-by Stefan Weil <[email protected]>---
I suggest to add and use a similar macro
QEMU_FALLTHROUGH()for the rest of the code and can provide a patch if that's fine for everyone.Regards
Stefandisas/libvixl/vixl/globals.h | 2 ++ 1 file changed, 2 insertions(+)disas/libvixl/vixl/globals.h +2
-0@@ -112,6 +112,8 @@ inline void USE(T1, T2, T3, T4) {}// C++11(201103L). #if __has_warning("-Wimplicit-fallthrough") && __cplusplus >= 201103L#define VIXL_FALLTHROUGH () [[clang::fallthrough]] //NOLINT +#elif defined(__GNUC__) +#define VIXL_FALLTHROUGH () __attribute__((fallthrough))
Quoted 8 lines
disas/libvixl/vixl/globals.h inline void USE(T1, T2, T3, T4) {} · line 119
Quoted 3 lines
disas/libvixl/vixl/globals.h +0
-0#else #define VIXL_FALLTHROUGH () do {} while (0)#endif Even with the above patch, disas/libvixl raises a compiler warning for a fall through case. The patch below fixes that warning, but I am not sure whether a fall through is correct there.
This sort of question is probably best asked of upstream VIXL, rather than here...
thanks
-- PMM
Quoted 20 lines · Stefan Weil
Even with the above patch, disas/libvixl raises a compiler warning for a fall through case. The patch below fixes that warning, but I am not sure whether a fall through is correct there.
Stefan
disas/libvixl/vixl/a64/disasm-a64.cc +1
-0@@ -2986,6 +2986,7 @@ int Disassembler::SubstituteImmediateField(const Instruction* instr, return 3; } } + VIXL_FALLTHROUGH(); // ??? } case 'C': { // ICondB - Immediate Conditional Branch.
Quoted 1 line
int64_t offset = instr->ImmCondBranch() << 2;
This is fixed in upstream vixl, in fact:
https://git.linaro.org/arm/vixl.git/commit/?id=de326f850f736c3a337fda52845ed3d2e620cc02
thanks
-- PMM
Am 15.05.2018 um 14:13 schrieb Peter Maydell:
Quoted 24 lines · Stefan Weil
Quoted 20 lines
Even with the above patch, disas/libvixl raises a compiler warning for a fall through case. The patch below fixes that warning, but I am not sure whether a fall through is correct there.
Stefan
disas/libvixl/vixl/a64/disasm-a64.cc +1
-0@@ -2986,6 +2986,7 @@ int Disassembler::SubstituteImmediateField(const Instruction* instr, return 3; } } + VIXL_FALLTHROUGH(); // ??? } case 'C': { // ICondB - Immediate Conditional Branch.Quoted 1 line
int64_t offset = instr->ImmCondBranch() << 2;This is fixed in upstream vixl, in fact:
Quoted 4 lines
https://git.linaro.org/arm/vixl.git/commit/?id=de326f850f736c3a337fda52845ed3d2e620cc02
thanks
-- PMM
That fix will work for the moment, but is not sufficient for the future because it only supports gcc 7.x, but not gcc 8.x or later:
+#elif __GNUC__ == 7
How do we proceed with the code in QEMU? Do you have a plan to update the vixl code? As vixl is obviously no longer maintained on GitHub, I am not sure whom I could contact.
And what about my other question / suggestion:
"I suggest to add and use a similar macro QEMU_FALLTHROUGH() for the rest of the code and can provide a patch if that's fine for everyone."
gcc gives lots of fallthrough warnings, and many code locations don't contain a comment stating that the fall through is fine.
Thanks
Stefan
Quoted 4 lines · Stefan Weil
This is fixed in upstream vixl, in fact:
https://git.linaro.org/arm/vixl.git/commit/?id=de326f850f736c3a337fda52845ed3d2e620cc02
Quoted 8 lines
That fix will work for the moment, but is not sufficient for the future because it only supports gcc 7.x, but not gcc 8.x or later:
+#elif
__GNUC__== 7How do we proceed with the code in QEMU? Do you have a plan to update the vixl code? As vixl is obviously no longer maintained on GitHub, I am not sure whom I could contact.
The github page points you to the linaro repo which is the new upstream. That said, I think we're planning to deprecate vixl now we have the capstone support. Richard, what's the status here? Could we just remove the vixl code now?
Quoted 7 lines
And what about my other question / suggestion:
"I suggest to add and use a similar macro
QEMU_FALLTHROUGH()for the rest of the code and can provide a patch if that's fine for everyone."gcc gives lots of fallthrough warnings, and many code locations don't contain a comment stating that the fall through is fine.
I guess that having the compiler check is better than finding them later with coverity. It's a shame gcc doesn't support the standard mechanism of using /* fallthrough */ to mark these, though.
thanks
-- PMM
Quoted 10 lines · Peter Maydell
Quoted 9 lines · Stefan Weil
This is fixed in upstream vixl, in fact:
https://git.linaro.org/arm/vixl.git/commit/?id=de326f850f736c3a337fda52845ed3d2e620cc02
That fix will work for the moment, but is not sufficient for the future because it only supports gcc 7.x, but not gcc 8.x or later:
+#elif
__GNUC__== 7
Quoted 8 lines
Quoted 3 lines
How do we proceed with the code in QEMU? Do you have a plan to update the vixl code? As vixl is obviously no longer maintained on GitHub, I am not sure whom I could contact.
The github page points you to the linaro repo which is the new upstream. That said, I think we're planning to deprecate vixl now we have the capstone support. Richard, what's the status here? Could we just remove the vixl code now?
We could just remove vixl, yes. I'd like to see updates to capstone to support instructions post v8.0, but it's not like we have those with vixl either...
Quoted 3 lines
I guess that having the compiler check is better than finding them later with coverity. It's a shame gcc doesn't support the standard mechanism of using /* fallthrough */ to mark these, though.
It does. Apparently not by default anymore, however:
@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular expression, any comment is used as fallthrough comment.
@item @option{-Wimplicit-fallthrough=2} case insensitively matches @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the following regular expressions:
...
I think either =2 or =1 would work for us in QEMU.
r~
Quoted 12 lines · Richard Henderson
Quoted 3 lines · Peter Maydell
I guess that having the compiler check is better than finding them later with coverity. It's a shame gcc doesn't support the standard mechanism of using /* fallthrough */ to mark these, though.
It does. Apparently not by default anymore, however:
@item @option{-Wimplicit-fallthrough=0} disables the warning altogether.
@item @option{-Wimplicit-fallthrough=1} matches @code{.*} regular expression, any comment is used as fallthrough comment.
Quoted 8 lines
@item @option{-Wimplicit-fallthrough=2} case insensitively matches @code{.*falls?[ \t-]*thr(ough|u).*} regular expression.
@item @option{-Wimplicit-fallthrough=3} case sensitively matches one of the following regular expressions:
...I think either =2 or =1 would work for us in QEMU.
1 sounds too broad, we don't want any old comment to count. 2 is probably what we want.
thanks
-- PMM
Quoted 7 lines · Richard Henderson
Quoted 3 lines · Peter Maydell
That said, I think we're planning to deprecate vixl now we have the capstone support. Richard, what's the status here? Could we just remove the vixl code now?
We could just remove vixl, yes. I'd like to see updates to capstone to support instructions post v8.0, but it's not like we have those with vixl either...
Just to check my understanding: with QEMU at the moment, you always get the capstone disassembler unless you specifically turn it off by passing --disable-capstone to configure, right (since we provide it as a submodule)?
We put that in in September last year, and we haven't had a pile of complaints about the disassembly (or indeed any complaints that I can recall), so I think we can consider it a success, and remove both vixl and the ancient binutils arm disassembler.
It would also be interesting to try interacting with capstone upstream about adding support for newer instructions (for instance they don't do the v8M insns). Do you know if capstone deals with new insns via resync from LLVM or if they've entirely forked and just make changes locally by hand?
thanks
-- PMM
Quoted 6 lines · Peter Maydell
Quoted 5 lines · Richard Henderson
Quoted 3 lines · Peter Maydell
That said, I think we're planning to deprecate vixl now we have the capstone support. Richard, what's the status here? Could we just remove the vixl code now?
Quoted 7 lines
Quoted 2 lines
We could just remove vixl, yes. I'd like to see updates to capstone to support instructions post v8.0, but it's not like we have those with vixl either...
Just to check my understanding: with QEMU at the moment, you always get the capstone disassembler unless you specifically turn it off by passing --disable-capstone to configure, right (since we provide it as a submodule)?
Correct.
Quoted 5 lines
We put that in in September last year, and we haven't had a pile of complaints about the disassembly (or indeed any complaints that I can recall), so I think we can consider it a success, and remove both vixl and the ancient binutils arm disassembler.
Yep.
Quoted 5 lines
It would also be interesting to try interacting with capstone upstream about adding support for newer instructions (for instance they don't do the v8M insns). Do you know if capstone deals with new insns via resync from LLVM or if they've entirely forked and just make changes locally by hand?
They seem to have entirely forked, but I'm not completely sure.
r~
Quoted 4 lines · Stefan Weil
That fix will work for the moment, but is not sufficient for the future because it only supports gcc 7.x, but not gcc 8.x or later:
+#elif
__GNUC__== 7
Fix to make that use >= is currently going through upstream vixl code review: https://review.linaro.org/#/c/25282/
thanks
-- PMM