Prev: [PATCH 1/2] parser: fix and simplify support of asm goto
Next: avoid NULL deference in ext2_xattr_get
From: Josh Triplett on 10 Jul 2010 05:10 On Sat, Jul 10, 2010 at 10:39:22AM +0200, Jiri Slaby wrote: > Gcc 4.5 defines > extern void __builtin_unreachable(void); > so, add it also to sparse. > > Signed-off-by: Jiri Slaby <jslaby(a)suse.cz> > --- > lib.c | 1 + > 1 files changed, 1 insertions(+), 0 deletions(-) > > diff --git a/lib.c b/lib.c > index a218bfc..ae6a20c 100644 > --- a/lib.c > +++ b/lib.c > @@ -740,6 +740,7 @@ void declare_builtin_functions(void) > add_pre_buffer ("extern char * __builtin___strncpy_chk(char *, const char *, __SIZE_TYPE__, __SIZE_TYPE__);\n"); > add_pre_buffer ("extern int __builtin___vsprintf_chk(char *, int, __SIZE_TYPE__, const char *, __builtin_va_list);\n"); > add_pre_buffer ("extern int __builtin___vsnprintf_chk(char *, __SIZE_TYPE__, int, __SIZE_TYPE__, const char *, __builtin_va_list ap);\n"); > + add_pre_buffer ("extern void __builtin_unreachable(void);\n"); __builtin_unreachable has special semantics beyond just a function. This definition will suffice to allow compilation, but __builtin_unreachable should have the same effect in sparse that it does in GCC: mark the point (and the remainder of the basic block) as unreachable. Something like the mechanism used for handling noreturn would work here as well; declaring the function to have attribute noreturn would probably have almost the right semantics. - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Chris Li on 13 Jul 2010 04:00 On Sat, Jul 10, 2010 at 2:07 AM, Josh Triplett <josh(a)joshtriplett.org> wrote: > __builtin_unreachable has special semantics beyond just a function. > This definition will suffice to allow compilation, but > __builtin_unreachable should have the same effect in sparse that it does > in GCC: mark the point (and the remainder of the basic block) as > unreachable. �Something like the mechanism used for handling noreturn > would work here as well; declaring the function to have attribute > noreturn would probably have almost the right semantics. > The attribute noreturn will apply to the whole function. The function NEVER returns. __builtin_unreachable only apply to current basic block. e.g. some error handling path like panic. The function can still return a value on the normal path. It has different meaning than attribute noreturn. So I don't think automatically give the function noreturn attribute is the right thing to do. I will apply the patch until we got better way to handle this. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Josh Triplett on 13 Jul 2010 14:20 On Tue, Jul 13, 2010 at 12:52:48AM -0700, Chris Li wrote: > On Sat, Jul 10, 2010 at 2:07 AM, Josh Triplett <josh(a)joshtriplett.org> wrote: > > __builtin_unreachable has special semantics beyond just a function. > > This definition will suffice to allow compilation, but > > __builtin_unreachable should have the same effect in sparse that it does > > in GCC: mark the point (and the remainder of the basic block) as > > unreachable. �Something like the mechanism used for handling noreturn > > would work here as well; declaring the function to have attribute > > noreturn would probably have almost the right semantics. > > > > The attribute noreturn will apply to the whole function. The function > NEVER returns. > __builtin_unreachable only apply to current basic block. e.g. some > error handling path like panic. The function can still return a value on the > normal path. It has different meaning than attribute noreturn. So I don't think > automatically give the function noreturn attribute is the right thing to do. No, I didn't mean that using __builtin_unreachable should mark the function calling it as noreturn. I meant that as an approximation to the right behavior, __builtin_unreachable *itself* could have attribute noreturn. - Josh Triplett -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
From: Chris Li on 13 Jul 2010 14:50
On Tue, Jul 13, 2010 at 11:12 AM, Josh Triplett <josh(a)joshtriplett.org> wrote: > No, I didn't mean that using __builtin_unreachable should mark the > function calling it as noreturn. �I meant that as an approximation to > the right behavior, __builtin_unreachable *itself* could have attribute > noreturn. Ah, that make sense. Chris -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo(a)vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ |