Re: MC/DC support for gcov?
On 3/31/22 16:55, Sebastian Huber wrote: Hello, gcov supports currently branch coverage. Some projects require modified condition/decision coverage (MC/DC): https://en.wikipedia.org/wiki/Modified_condition/decision_coverage In general, 100% branch coverage does not imply 100% MC/DC coverage: https://www.adacore.com/uploads_gems/Couverture_ERTS-2012.pdf The paper contains a criterion under which 100% branch coverage implies 100% MC/DC coverage: "Theorem 1 If the BDD of a decision D is a tree (with only one path from the root to any condition node), then BDD edge coverage implies MCDC" The BDD is the Binary Decision Diagram. I have no idea how the compiler and the coverage supports works in GCC. Is this BDD available for the coverage support and could the coverage support check for this property and then for example add it to the gcov information? If the BDD of a decision is not a tree, then we would have to record which paths through the BDD are covered to get the MC/DC coverage. This would require extra storage and instrumentation. According to the paper, the BDD is usually a tree in real world applications. Does this sound like feasible feature for GCC? Could it be even a GSoC project? Kind regards, Sebastian Hi. There's a patch review for the feature: https://gcc.gnu.org/pipermail/gcc-patches/2022-March/592065.html Martin
[PATCH] arm64/io: Remind compiler that there is a memory side effect
The relaxed variants of read/write macros are only declared as `asm volatile()` which forces the compiler to generate the instruction in the code path as intended. The only problem is that it doesn't also tell the compiler that there may be memory side effects. Meaning that if a function is comprised entirely of relaxed io operations, the compiler may think that it only has register side effects and doesn't need to be called. For an example function look at bcmgenet_enable_dma(), before the relaxed variants were removed. When built with gcc12 the code contains the asm blocks as expected, but then the function is never called. Signed-off-by: Jeremy Linton --- arch/arm64/include/asm/io.h | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h index 7fd836bea7eb..3cceda7948a0 100644 --- a/arch/arm64/include/asm/io.h +++ b/arch/arm64/include/asm/io.h @@ -24,25 +24,25 @@ #define __raw_writeb __raw_writeb static inline void __raw_writeb(u8 val, volatile void __iomem *addr) { - asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr)); + asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); } #define __raw_writew __raw_writew static inline void __raw_writew(u16 val, volatile void __iomem *addr) { - asm volatile("strh %w0, [%1]" : : "rZ" (val), "r" (addr)); + asm volatile("strh %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); } #define __raw_writel __raw_writel static __always_inline void __raw_writel(u32 val, volatile void __iomem *addr) { - asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr)); + asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); } #define __raw_writeq __raw_writeq static inline void __raw_writeq(u64 val, volatile void __iomem *addr) { - asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr)); + asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); } #define __raw_readb __raw_readb -- 2.35.1
Re: [PATCH] arm64/io: Remind compiler that there is a memory side effect
Hi Jeremy, Thanks for raising this. On Fri, Apr 01, 2022 at 11:44:06AM -0500, Jeremy Linton wrote: > The relaxed variants of read/write macros are only declared > as `asm volatile()` which forces the compiler to generate the > instruction in the code path as intended. The only problem > is that it doesn't also tell the compiler that there may > be memory side effects. Meaning that if a function is comprised > entirely of relaxed io operations, the compiler may think that > it only has register side effects and doesn't need to be called. As I mentioned on a private mail, I don't think that reasoning above is correct, and I think this is a miscompilation (i.e. a compiler bug). The important thing is that any `asm volatile` may have a side effects generally outside of memory or GPRs, and whether the assembly contains a memory load/store is immaterial. We should not need to add a memory clobber in order to retain the volatile semantic. See: https://gcc.gnu.org/onlinedocs/gcc/Extended-Asm.html#Volatile ... and consider the x86 example that reads rdtsc, or an arm64 sequence like: | void do_sysreg_thing(void) | { | unsigned long tmp; | | tmp = read_sysreg(some_reg); | tmp |= SOME_BIT; | write_sysreg(some_reg); | } ... where there's no memory that we should need to hazard against. This patch might workaround the issue, but I don't believe it is a correct fix. > For an example function look at bcmgenet_enable_dma(), before the > relaxed variants were removed. When built with gcc12 the code > contains the asm blocks as expected, but then the function is > never called. So it sounds like this is a regression in GCC 12, which IIUC isn't released yet per: https://gcc.gnu.org/gcc-12/changes.html ... which says: | Note: GCC 12 has not been released yet Surely we can fix it prior to release? Thanks, Mark. > > Signed-off-by: Jeremy Linton > --- > arch/arm64/include/asm/io.h | 8 > 1 file changed, 4 insertions(+), 4 deletions(-) > > diff --git a/arch/arm64/include/asm/io.h b/arch/arm64/include/asm/io.h > index 7fd836bea7eb..3cceda7948a0 100644 > --- a/arch/arm64/include/asm/io.h > +++ b/arch/arm64/include/asm/io.h > @@ -24,25 +24,25 @@ > #define __raw_writeb __raw_writeb > static inline void __raw_writeb(u8 val, volatile void __iomem *addr) > { > - asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr)); > + asm volatile("strb %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); > } > > #define __raw_writew __raw_writew > static inline void __raw_writew(u16 val, volatile void __iomem *addr) > { > - asm volatile("strh %w0, [%1]" : : "rZ" (val), "r" (addr)); > + asm volatile("strh %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); > } > > #define __raw_writel __raw_writel > static __always_inline void __raw_writel(u32 val, volatile void __iomem > *addr) > { > - asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr)); > + asm volatile("str %w0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); > } > > #define __raw_writeq __raw_writeq > static inline void __raw_writeq(u64 val, volatile void __iomem *addr) > { > - asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr)); > + asm volatile("str %x0, [%1]" : : "rZ" (val), "r" (addr) : "memory"); > } > > #define __raw_readb __raw_readb > -- > 2.35.1 >
Various errors encountered while compiling gcj.
While attempting to compile gcc with gcj re-added, the compilation fails on a varying number of errors. I have solved most of the errors, but these are the remaining ones I am stuck on. The code I am building from is available here: https://github.com/Zopolis4/gcj/tree/gcjmainbuild . My apologies for log dumping. ../.././gcc/java/jcf-depend.cc: In function ‘void jcf_dependency_reset()’: ../.././gcc/java/jcf-depend.cc:66:18: error: cannot convert ‘deps*’ to ‘mkdeps*’ 66 | deps_free (dependencies); | ^~~~ | | | deps* In file included from ../.././gcc/java/jcf-depend.cc:30: ../.././gcc/../libcpp/include/mkdeps.h:37:24: note: initializing argument 1 of ‘void deps_free(mkdeps*)’ 37 | extern void deps_free (class mkdeps *); |^~ ../.././gcc/java/jcf-depend.cc:37:7: note: class type ‘deps’ is incomplete 37 | class deps *dependencies; | ^~~~ ../.././gcc/java/jcf-depend.cc: In function ‘void jcf_dependency_set_target(const char*)’: ../.././gcc/java/jcf-depend.cc:76:22: error: cannot convert ‘deps*’ to ‘mkdeps*’ 76 | deps_add_target (dependencies, name, 1); | ^~~~ | | | deps* ../.././gcc/../libcpp/include/mkdeps.h:48:30: note: initializing argument 1 of ‘void deps_add_target(mkdeps*, const char*, int)’ 48 | extern void deps_add_target (class mkdeps *, const char *, int); | ^~ ../.././gcc/java/jcf-depend.cc:37:7: note: class type ‘deps’ is incomplete 37 | class deps *dependencies; | ^~~~ ../.././gcc/java/jcf-depend.cc: In function ‘void jcf_dependency_add_target(const char*)’: ../.././gcc/java/jcf-depend.cc:83:22: error: cannot convert ‘deps*’ to ‘mkdeps*’ 83 | deps_add_target (dependencies, name, 1); | ^~~~ | | | deps* ../.././gcc/../libcpp/include/mkdeps.h:48:30: note: initializing argument 1 of ‘void deps_add_target(mkdeps*, const char*, int)’ 48 | extern void deps_add_target (class mkdeps *, const char *, int); | ^~ ../.././gcc/java/jcf-depend.cc:37:7: note: class type ‘deps’ is incomplete 37 | class deps *dependencies; | ^~~~ ../.././gcc/java/jcf-depend.cc: In function ‘void jcf_dependency_init(int)’: ../.././gcc/java/jcf-depend.cc:119:28: error: cannot convert ‘mkdeps*’ to ‘deps*’ in assignment 119 | dependencies = deps_init (); | ~~^~ || |mkdeps* In file included from ../.././gcc/../libcpp/include/mkdeps.h:26: ../.././gcc/../libcpp/include/cpplib.h:1043:14: note: class type ‘mkdeps’ is incomplete 1043 | extern class mkdeps *cpp_get_deps (cpp_reader *) ATTRIBUTE_PURE; | ^~ ../.././gcc/java/jcf-depend.cc: In function ‘void jcf_dependency_write()’: ../.././gcc/java/jcf-depend.cc:138:47: error: expected primary-expression before ‘.’ token 138 | CPP_OPTION (dependencies, deps.phony_targets) 72); | ^ ../.././gcc/java/jcf-depend.cc:138:17: error: ‘CPP_OPTION’ was not declared in this scope 138 | CPP_OPTION (dependencies, deps.phony_targets) 72); | ^~ ../.././gcc/java/jcf-depend.cc:140:17: error: cannot convert ‘deps*’ to ‘const cpp_reader*’ 140 | deps_write (dependencies, dep_out, 72); | ^~~~ | | | deps* ../.././gcc/../libcpp/include/mkdeps.h:69:25: note: initializing argument 1 of ‘void deps_write(const cpp_reader*, FILE*, unsigned int)’ 69 | extern void deps_write (const cpp_reader *, FILE *, unsigned int); | ^~ ../.././gcc/java/jcf-depend.cc:37:7: note: class type ‘deps’ is incomplete 37 | class deps *dependencies; | ^~~~ make[3]: *** [Makefile:1143: java/jcf-depend.o] Error 1 make[3]: *** Waiting for unfinished jobs In file included from ../.././gcc/java/jvspec.cc:29: ../.././gcc/gcc.h:61:3: error: ‘option_proposer’ does not name a type 61 | option_proposer m_option_proposer; | ^~~ make[3]: *** [Makefile:1143: java/jvspec.o] Error 1 ../.././gcc/java/expr.cc: In function ‘void expand_java_return(tree)’: ../.././gcc/java/expr.cc:1303:15: error: no match for ‘operator<’ (operand types are ‘poly_uint16’ {aka ‘poly_int<1, short unsigned int>’} and ‘poly_uint16’ {aka ‘poly_int<1, short unsigned int>’}) 1302 | && (GET_MODE_SIZE (TYPE_MODE (TREE_TYPE (res))) | ~~~ | | | poly_int<[...],[...]> 1303 |
gcc-10-20220401 is now available
Snapshot gcc-10-20220401 is now available on https://gcc.gnu.org/pub/gcc/snapshots/10-20220401/ and on various mirrors, see http://gcc.gnu.org/mirrors.html for details. This snapshot has been generated from the GCC 10 git branch with the following options: git://gcc.gnu.org/git/gcc.git branch releases/gcc-10 revision 4805a45c66aa96a5ee434fc5e92c59fbbaf5546b You'll find: gcc-10-20220401.tar.xz Complete GCC SHA256=6b8992577a8e2aa05551000b78aebff77a308580b7295649028de1f4e6a50b0c SHA1=01456f8be7be4ebf5a2f491a7420376ebf59bb84 Diffs from 10-20220325 are available in the diffs/ subdirectory. When a particular snapshot is ready for public consumption the LATEST-10 link is updated and a message is sent to the gcc list. Please do not use a snapshot before it has been announced that way.