Age | Commit message (Collapse) | Author | Files | Lines |
|
Sparse emits a large number of warnings for the linux kernel source
tree of the form:
./arch/x86/include/asm/uaccess.h:735:18: \
warning: incorrect type in argument 1 (different modifiers)
./arch/x86/include/asm/uaccess.h:735:18: expected void *<noident>
./arch/x86/include/asm/uaccess.h:735:18: got void const *from
Fix by making the first parameter to __builtin_object_size()
type "const void *" instead of "void *", which is consistent with GCC
behavior (the prototype for this builtin in GCC documentation is evidently
incorrect).
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
We have been seeing errors like this for a while now in the sparse
Fedora package, when doing kernel builds:
./include/linux/err.h:53:25: warning: dereference of noderef expression
./include/linux/err.h:35:16: warning: dereference of noderef expression
This spews all over the build because this comes from IS_ERR(), which
is called everywhere. Even odder, it turns out that if we build the
package with -fpic turned off, then it works fine.
With some brute-force debugging, I think I've finally found the cause.
This array is missing the SForced element. When this is added then the
problem goes away.
As to why this goes away when -fpic is removed, I can only assume that
we get lucky with the memory layout and have a zeroed out region just
beyond the end of the array.
Fixes: 3829c4d8b097776e6b3472290a9fae08a705ab7a
Cc: Al Viro <viro@ftp.linux.org.uk>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Add attribute "no_sanitize_address" or "__no_sanitize_address__" as an ignored
attribute. Fixes this sparse warning:
include/linux/compiler.h:232:8: error: attribute 'no_sanitize_address': unknown attribute
Also add test case for 'no_sanitize_address': validation/attr-no_sanitize_address.c.
'make check' says for this test case:
TEST attribute no_sanitize_address (attr-no_sanitize_address.c)
Signed-off-by: Rui Teng <rui.teng@linux.vnet.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The __assume_aligned__ attribute can be safely ignored, add it
to the list of ignored attributes and add a test to verify that
this attribute is ignored.
Signed-off-by: Lance Richardson <lrichard@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
-pedantic in the llvm-config --cflags cause a lot of warning.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
With the following code:
typedef unsigned long __nocast cputime_t;
void task_cputime_adjusted(cputime_t *);
void current_task_runtime_100ns(void)
{
cputime_t utime;
task_cputime_adjusted(&utime);
}
sparse emits the following message:
x.c:16:32: warning: incorrect type in argument 1 (different modifiers)
x.c:16:32: expected unsigned long [nocast] [usertype] *<noident>
x.c:16:32: got unsigned long *<noident>
x.c:16:32: warning: implicit cast to nocast type
In other words, when taking the address of 'utime', sparse drops the 'nocast'
modifier and then complains that task_cputime_adjusted() is not given a
'nocast' pointer as expected ...
This feels wrong to me.
The proposed fix is to simply not dropping the 'nocast' modifier when
taking the address, like done for a normal type qualifier.
This gives very reasonable behaviour for all the test cases I could
think of:
- taking the address or dereferencing doesn't drop the nocast
- arithmetic operations on nocast give a nocast result.
- implicit to/from cast is OK only if the base type are the same
- implicit to/from pointer cast is OK only if the base type are the same
This still gives a "leaky" semantic: the nocast modifier can be lost via
an implicit cast to a non-qualified value.
Explicit cast to or from nocast values doesn't give any warning, maybe
it's OK, maybe it's not but it's orthogonal to the current issue.
Is this the wanted semantic for the nocast modifier?
Reported-by: Roman Kagan <rkagan@virtuozzo.com>
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This stops sparse from issuing the error message
"error: cannot size expression"
for code like:
static _Bool boolarray[] = {
0,
1,
};
static int n = sizeof(boolarray);
The fix consists of using array_element_offset() for calculating
the size of unsized arrays, like it is done elsewhere for sized ones.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Missing enum members in case statements in c2xml.c and parse.c were
causing compile time complaints by gcc 5.1.1. Adding a default case
satisfies the compiler and notifies the reviewer that there are
cases not explicitly mentioned being handled by the default case.
Signed-off-by: Tony Camuso <tcamuso@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Tony Camuso <tcamuso@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
If you call DELETE_CURRENT_PTR(), then you can sometimes end up with a
__list->nr that is zero. The FOR_EACH_PTR() macro can handle this but
the NEXT_PTR_LIST() macro returns ptr = 0xf0f0f0f0 which leads to a
segfault.
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
You can't pass function to LLVMConstNull(), according to
Constant::getNullValue, and sparse-llvm already handle functions differently
(i.e. there will be no call to LLVMConstNull(), but this is not true for
function prototypes, because of how linearize_fn() works:
```
static struct entrypoint *linearize_fn(...)
{
...
if (!base_type->stmt)
return NULL;
...
}
```
```
Constant *Constant::getNullValue(Type *Ty) {
switch (Ty->getTypeID()) {
...
default:
// Function, Label, or Opaque type?
llvm_unreachable("Cannot create a null constant of that type!");
}
}
```
Signed-off-by: Azat Khuzhin <a3at.mail@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
gcc knows about a new "hotpatch" attribute which sparse can safely ignore,
since it modifies only which code will be generated just like the
"no_instrument_function" attribute.
The gcc hotpatch feature patch:
https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=11762b8363737591bfb9c66093bc2edf289b917f
Currently the Linux kernel makes use of this attribute:
https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=61f552141c9c0e88b3fdc7046265781ffd8fa68a
Without this patch sparse will emit warnings like
"error: attribute 'hotpatch': unknown attribute"
Signed-off-by: Heiko Carstens <heiko.carstens@de.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Test file cross checked with
gcc -c -Wall -Werror -Wno-unused-variable validation/builtin_inf.c
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The pure attribute only take effect in function node.
There is no way to make a value itself pure.
Reported-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Michael Stefaniuc <mstefani@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
__COUNTER__ macro is expanded to a sequential number starting from 0.
This is sometimes used to declare unique variable names.
Implement support for __COUNTER__ in sparse including a set of
small test programs for the test suite.
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Tested-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The string is shared between different macro expand.
It is wrong to modify the string in place if the string
is used in a macro. Avoid overwriting the string in that
case.
Reported-by: Rasmus Villemoes <linux@rasmusvillemoes.dk>
Tested-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch fixes several issues when compiling code under s390x
(64bit) with cgcc, e.g.
/usr/include/gnu/stubs.h:8:12: error: unable to open 'gnu/stubs-32.h'
by providing the proper defines.
Signed-off-by: Christian Borntraeger <borntraeger@de.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The target buffer is overlapped with source buffer.
This cause the duplicate entry warning reported by Hans.
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Allow overriding pkg-config e.g. when cross-compiling.
Signed-off-by: Aaro Koskinen <aaro.koskinen@nsn.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Some versions of gcc (e.g. v4.8.2) complain about ignoring the return
value of a call to the write(2) system call, since the system header
files have marked its declaration with the warn_unused_result attribute.
In order to suppress the compiler warning, check the return value from
'write' and, if it indicates an error (a negative return value), exit
the process using 'die' to display an error message. Replace a second
call to 'write', which does not provoke a compiler warning, with similar
code for consistency.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Passing the '-Wsparse-error' to cgcc can cause that option to be
passed to the C compiler (usually gcc), if the given source file
does not provoke any sparse warnings, which in turn results in
a failure to compile that file.
In order to avoid passing this sparse option to the compiler, we
add the '-Wsparse-error' option to the regular expression check
in the 'check_only_option' function.
In addition, we replace the plain call to 'die' when sparse exits
with non-zero status (maybe due to -Wsparse-error), with a simple
'exit 1'. This suppresses an 'Died at ./cgcc line 86.' message on
exit from cgcc.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The use of the '==' operator in a test/[ conditional is a non-POSIX
bash extension. In order to avoid test failures on systems that do
not have bash as the system shell (/bin/sh), replace the use of the
'==' operator with the POSIX compatible '=' operator.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
I miss a spot when converting array size caculation using
array_element_offet(). "next_designators()" is still using
"n*bit_size" to caculate the element offset. It is wrong
for the case of bool array.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Capture the c-compiler command, in the $ccom variable, in order to
later invoke the compiler without extraneous command-line options.
In particular, use the $ccom variable in order to cleanly invoke the
compiler when setting the $gcc_base_dir variable.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
In particular, on systems which do not have 'llvm-config' installed,
every invocation of make issues the following messages:
/bin/sh: llvm-config: command not found
make: llvm-config: Command not found
A simple solution would be to suppress these messages by redirecting
stderr to the bit-bucket within the definitions of HAVE_LLVM_VERSION
and LLVM_VERSION.
As an alternative, however, we move the definition of LLVM_VERSION
down the file within the HAVE_LLVM conditional, which ensures that
the 'llvm-config' command exists. In addition, the HAVE_LLVM_VERSION
variable is replaced with an equivalent conditional expression.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This suppresses some "array subscript has type 'char'" warnings from
gcc (version 4.8.3). (see also, commit cf5114a1)
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Add some more ignored attributes which are used in glibc header files,
along with a simple test case which includes all three inline attributes
(__gnu_inline__, __always_inline__ and __noinline__).
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This code snippet:
static void bar(void const *arg)
{
int (*foo)(void) = arg;
}
produces the following warning:
test.c:4:28: warning: incorrect type in initializer (different modifiers)
test.c:4:28: expected int ( *foo )( ... )
test.c:4:28: got void const *arg
which is caused by the fact that the function pointer 'foo' is not annotated
as being a pointer to const data. However, dereferencing a function pointer
does not produce an lvalue, so a function pointer points to const data by
definition, and we should treat it accordingly.
To avoid producing a warning on the inverse case, i.e.,
static void bar(void)
{
void *foo = bar;
}
we only address the case where the function pointer is the target of
an assignment.
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Sparse is often share compile flags. So Werror is usually
mean gcc should treat warning as error. Apply the same
option to sparse will cause the Linux kernel checking fail
the build. We don't want that.
Rename the sparse option to -Wsparse-error. It allow caller
to control gcc and sparse behavior seperately.
It also make sparse return error status only when -Wsparse-error
is present.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Make sparse fail and return an error code if a warning is encountered
and -Werror is specified or a hard error is found. This allows to use
sparse in automated build systems to more easily catch new sparse
warnings.
The validation script is extended to parse the expected output message
for an error message and validate the a non zero return value if such
a error message is found.
Also changes cgcc to die if the checker fails.
Signed-off-by: Thomas Graf <tgraf@suug.ch>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Pavel Roskin <proski@gnu.org>
Reviewed-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
llvm-config 3.5 no longer lists the non-LLVM libraries needed for linkage when
passed --libs. The --system-libs flag was added for this purpose. This adds
these libraries while silently doing nothing for older versions of LLVM.
Signed-off-by: Omar Sandoval <osandov@osandov.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The "trivial fix" is to just save off the offset in check_designators
(add a new field to the "EXPR_IDENTIFIER" part of "struct expression"
and then pick up that offset in "convert_ident()"
However, that has exactly the same issue with the whole fake
EXPR_IDENTIFIER created by "next_designators()". Now we need to
initialize the offset field there too. And, for the same reason as
before, the field that "next_designator()" picks may not *have* an
identifier, because the next designator may in fact be an anonymous
union.
Anyway, with all that said, maybe this really confusing and hacky
patch would work. It passes my tests. The magic offset calculation in
next_designators() has a big comment about what the heck it is doing,
and otherwise it's a fairly straightforward case of "save offset from
check_designators() time to be used by convert_ident()".
My stupid test-case is this incredibly hacky thing:
struct A {
int aa;
int bb;
};
struct S {
int a;
union {
int b;
int c;
} u[10];
int dummy;
union {
int d;
int e;
};
};
int fn(void)
{
struct S s = {
.a = 1,
.u[2].b = 2,
.dummy = 1,
{ 3 }
};
return s.dummy*1000 + s.d*100 + s.u[2].b*10 + s.a; // 1321
}
where I use "./test-linearize" to verify that the initializer layout
matches the code generation layout (so that 'fn' function *should*
linearize to just a simple "ret.32 $1321", and with this patch it
does).
But I bet this misses some case. However, the current state wrt
initializer offsets really is very broken, so maybe it's ok.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Consider the following case, extern inline declare after
extern declare of the same function.
extern int g(int);
extern __inline__ int g(int x)
{
return x;
}
Sparse will give the first function global scope and
the second one file scope. Also the first one will get the
function body from the second one. That cause the failure
of the validation/extern-inlien.c
This change rebind the scope of the same_symbol chain to
the new scope. It will pass the extern-inline.c test case.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
We'd only match them with other symbols marked 'extern', but really, we
should match them with any top-level non-static symbol.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
When layout the array element, the element size should
round up to byte align.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Currently, sparse handles arrays of bools incorrectly. If you declare an
array of bools like this:
static _Bool boolarray[3] = {
[0] = 1,
[1] = 1,
};
...you get warnings like this (which are bogus):
./test.c:2:10: warning: Initializer entry defined twice
./test.c:3:10: also defined here
The problem is that bits_to_bytes rounds down instead of up, and sparse
defaults to _Bool being only 1 bit in size. This causes sparse to think
that they sit within the same byte, when they do not.
Fix bits_to_bytes to round up instead of down, and fix the call in
init_ctype to no longer correct for it. Also add a validation
test to ensure that we don't break this in the future.
Signed-off-by: Jeff Layton <jlayton@primarydata.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Remove the loop for short option.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Very dumb patch to just skip --param allow-store-data-races=0 introduced in
newer GCC versions.
Without this patch sparse recognizes parameter of the --param option as a file
name which obviously couldn't be found.
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The n1570 specifies (in 6.7.6.2.3) that either type-qualifiers
(ie: "restrict") come first and are followed by "static" or the
opposite ("static" then type-qualifiers).
Also add a test.
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Some systems have multiple llvm versions installed, and have prefixed
executables ("<exec>-<version>"). While we could require the user to
specify a variable for each executable (LLC, LLI), using llvm-config
--bindir to locate them and allowing them to override using LLVM_CONFIG
makes much less work.
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
On systems like ubuntu 12.04, llvm-config is llvm 2.9, but
llvm-config-3.0 and llvm-config-3.3 (for example) are versions 3.0 and
3.3 respectively. Allow overriding the name/path of the llvm-config
script so people can use these versioned config scripts
Signed-off-by: Cody P Schafer <cody@linux.vnet.ibm.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Ok, this fixes the warning, but we seem to still mess up the actual
initializer. It looks like some later phase gets the offset wrong, so
when we lay things out in memory, we'll put things at offset zero
(which is right for your test-case, but not if there was something
before that anonymous union).
Regardless, that only matters for real code generation, not for using
sparse as a semantic checker, so this patch is correct and is an
improvement.
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Running sparse over this gives:
error: bad integer constant expression
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Has report this bug which fix by Linus in the previous commit.
Sparse will report "cannot size expression" on the array size.
It is cause by the second extern declare with imcompleted size.
Signed-off-by: Hans Verkuil <hans.verkuil@cisco.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
When we size a symbol, we only have one initializer per symbol, but we
may have multiple symbol declarations for the same symbol. So make sure
to walk the "same_symbol" chain to find the initializer, rather than
assuming it is attached to the current declaration.
Reported-by: Hans Verkuil <hverkuil@xs4all.nl>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Noticed this while looking at an independent bug reported by Hans
Verkuil.
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This stops warnings in code using socket operations with a modern glibc,
which otherwise result in warnings of the form:
warning: incorrect type in argument 2 (invalid types)
expected union __CONST_SOCKADDR_ARG [usertype] __addr
got struct sockaddr *<noident>
Since transparent unions are only applicable to function arguments, we
create a new function to check that the types are compatible
specifically in this context.
Also change the wording of the existing warning slightly since sparse
does now support them. The warning is left in case people want to avoid
using transparent unions.
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This will allow us to reuse the logic when processing a transparent
union by checking each member in turn without printing a warning unless
none of the members match.
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Since commit 2667c2d (sparse: Allow override of sizeof(bool) warning,
2014-02-26) the default has been not to warn on sizeof(bool). This
means that the sizeof-bool test case now needs an explicit command in
order to trigger the warning it is testing.
Signed-off-by: John Keeping <john@keeping.me.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Allow an override to emit or not the sizeof(bool) warning.
Add a "-Wsizeof-bool" description to the manpage.
Signed-off-by: Joe Perches <joe@perches.com>
Reviewed-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
gcc defines __CHAR_BIT__ as a pre-defined macro.
Define __CHAR_BIT__ in sparse so that code that needs it (e.g. code
using CHAR_BIT from limits.h) does not generate false warnings.
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This bug was introduced in commit bcdb5ee5. The SPARSE_VERSION
already starts with 'v'.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
this patch stops sparse from complaining about them not being
defined:
source/odp_spinlock.c:41:10: error: undefined identifier '__sync_lock_release'
source/odp_spinlock.c:54:10: error: undefined identifier '__sync_lock_release'
./odp_atomic.h:112:16: error: undefined identifier '__sync_fetch_and_add'
Reported-by: Mike Holmes <mike.holmes@linaro.org>
Signed-off-by: Kim Phillips <kim.phillips@linaro.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Emilio G. Cota <cota@braap.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Changes in the library have left the README giving out of date information
on how to intialise the library and get the symbols out of it. Update the
documentation to match the latest functions.
Signed-off-by: James Westby <james@jameswestby.net>
Signed-off-by: Franz Schrober <franzschrober@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The comparison in same_cast_type only checked the bit_size of the new and the
old symbol. The bit_offset was only compared with itself and thus would always
be true. Instead Linus most likely wanted to compare the bit_offset of the new
and the old symbol. This regression was introduced in
47f53396a1d62719c44941f84370ead80181728e ("If two implied casts end up undoing
each other, just remove them.").
Reported-by: James Westby <jw+debian@jameswestby.net>
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Reported-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The old code was relicensed by Novafora Corporation, successor in interest to
Transmeta Corporation, in 2009. Other authors were also asked about the change
of their contributions to the MIT license and all with copyrightable changes
agreed to it.
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Acked-by: Adam DiCarlo <adam@bikko.org>
Acked-by: Al Viro <viro@ZenIV.linux.org.uk>
Acked-by: Alberto Bertogli <albertito@blitiri.com.ar>
Acked-by: Alecs King <alecs@perlchina.org>
Acked-by: Alexander Shishkin <alexander.shishckin@gmail.com>
Acked-by: Alexey Dobriyan <adobriyan@gmail.com>
Acked-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>
Acked-by: Andries E. Brouwer <Andries.Brouwer@cwi.nl>
Acked-by: Arnaldo Carvalho de Melo <acme@ghostprotocols.net>
Acked-by: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Acked-by: Ben Pfaff <blp@nicira.com>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Bernd Petrovitsch <bernd@petrovitsch.priv.at>
Acked-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Acked-by: Blue Swirl <blauwirbel@gmail.com>
Acked-by: Chris Forbes <chrisf@ijw.co.nz>
Acked-by: Chris Wedgwood <cw@f00f.org>
Acked-by: Christopher Li <sparse@chrisli.org>
Acked-by: Damien Lespiau <damien.lespiau@gmail.com>
Acked-by: Dan Carpenter <error27@gmail.com>
Acked-by: Dan McGee <dan@archlinux.org>
Acked-by: Daniel De Graaf <danieldegraaf@gmail.com>
Acked-by: Daniel Sheridan <dan.sheridan@postman.org.uk>
Acked-by: Dave Jones <davej@redhat.com>
Acked-by: David Given <dg@cowlark.com>
Acked-by: David Miller <davem@redhat.com>
Acked-by: David Mosberger-Tang <dmosberger@gmail.com>
Acked-by: David Olien <David.Olien@lsi.com>
Acked-by: Diego Elio Pettenò <flameeyes@flameeyes.eu>
Acked-by: Emil Medve <Emilian.Medve@Freescale.com>
Acked-by: Ethan Jackson <jacksone@nicira.com>
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Acked-by: Frank Zago <fzago@systemfabricworks.com>
Acked-by: Frederic Crozat <fcrozat@suse.com>
Acked-by: Geoff Johnstone <geoff.johnstone@gmail.com>
Acked-by: Hannes Eder <hannes@hanneseder.net>
Acked-by: Jan Pokorný <pokorny_jan@seznam.cz>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Acked-by: Jiri Slaby <jslaby@suse.cz>
Acked-by: Joe Perches <joe@perches.com>
Acked-by: Joel Soete <rubisher@scarlet.be>
Acked-by: Johannes Berg <johannes@sipsolutions.net>
Acked-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Acked-by: Josh Triplett <josh@kernel.org>
Acked-by: Kamil Dudka <kdudka@redhat.com>
Acked-by: Kim Phillips <kim.phillips@linaro.org>
Acked-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Acked-by: Kovarththanan Rajaratnam <kovarththanan.rajaratnam@gmail.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
Acked-by: Martin Nagy <nagy.martin@gmail.com>
Acked-by: Masatake YAMATO <yamato@redhat.com>
Acked-by: Mauro Dreissig <mukadr@gmail.com>
Acked-by: Michael Büsch <m@bues.ch>
Acked-by: Michael Stefaniuc <mstefani@redhat.com>
Acked-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Mika Kukkonen <mikukkon@iki.fi>
Acked-by: Mike Frysinger <vapier@gentoo.org>
Acked-by: Mitesh Shah <Mitesh.Shah@synopsys.com>
Acked-by: Morten Welinder <mortenw@gnome.org>
Acked-by: Namhyung Kim <namhyung@gmail.com>
Acked-by: Nicolas Kaiser <nikai@nikai.net>
Acked-by: Oleg Nesterov <oleg@redhat.com>
Acked-by: Pavel Roskin <proski@gnu.org>
Acked-by: Pekka Enberg <penberg@cs.helsinki.fi>
Acked-by: Peter Jones <pjones@redhat.com>
Acked-by: Peter A Jonsson <pj@sics.se>
Acked-by: Ralf Wildenhues <Ralf.Wildenhues@gmx.de>
Acked-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Acked-by: Randy Dunlap <rdunlap@xenotime.net>
Acked-by: Reinhard Tartler <siretart@tauware.de>
Ached-by: Richard Knutsson <richard.knutsson@gmail.com>
Acked-by: Rob Taylor <rob.taylor@codethink.co.uk>
Acked-by: Rui Saraiva <rmpsaraiva@gmail.com>
Acked-by: Ryan Anderson <ryan@michonline.com>
Acked-by: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Samuel Bronson <naesten@gmail.com>
Acked-by: Santtu Hyrkkö <santtu.hyrkko@gmail.com>
Acked-by: Shakthi Kannan <shakthimaan@gmail.com>
Acked-by: Stephen Hemminger <shemminger@linux-foundation.org>
Acked-by: Thomas Schmid <Thomas.Schmid@br-automation.com>
Acked-by: Tilman Sauerbeck <tilman@code-monkey.de>
Acked-by: Vegard Nossum <vegardno@ifi.uio.no>
Acked-by: Xi Wang <xi.wang@gmail.com>
Acked-by: Yura Pakhuchiy <pakhuchiy@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
James Westby is the only person not reacting when asking him about the MIT
license change over email or social media. So he has to count as not accepting
and reverting his contributions is the only way to to avoid possible legal
problems. The contributions can be re-added later when they are rewritten from
scratch.
This reverts commit 006eff06c7adcfb0d06c6fadf6e9b64f0488b2bf.
Cc: James Westby <jw+debian@jameswestby.net>
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
James Westby is the only person not reacting when asking him about the MIT
license change over email or social media. So he has to count as not accepting
and reverting his contributions is the only way to to avoid possible legal
problems. The contributions can be re-added later when they are rewritten from
scratch.
This reverts commit 34ac7df96dd9609d684b0c949a52bc07ab1fd8b5.
Cc: James Westby <jw+debian@jameswestby.net>
Signed-off-by: Franz Schrober <franzschrober@yahoo.de>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
license
This merge grant checkin up to 1bcc92138dcdf718dc3e0c694565f56e669d6ee3
under the MIT license.
|
|
Please consider pulling the latest Sparse/LLVM tree:
git@github.com:penberg/sparse-llvm.git llvm/core
It has various LLVM backend fixes from Jonathan and Xi.
|
|
this patch stops sparse from complaining about them not being defined:
/usr/include/bits/stdio2.h:98:25: error: undefined identifier '__builtin_va_arg_pack'
/usr/include/bits/stdio2.h:98:25: error: not a function <noident>
Signed-off-by: Jeff Layton <jlayton@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Run test-linearize against this program.
static int foo(float x) { return !x; }
The output is:
set.32 %r2 <- 0.000000
bad_op.32
ret.32 %r3
The expression type of zero testing should be EXPR_COMPARE, rather than
EXPR_BINOP, which causes bad_op.
Acked-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
The result type of relational operators (e.g., x < y) and logical
operators (e.g., x && y) in C should be int, rather than bool.
For example, sparse incorrectly evaluates sizeof(x < y) to 1 (i.e.,
sizeof(int)), which should have been sizeof(int).
This patch fixes the result type of these operators in evaluation,
linearization, and the LLVM backend.
Acked-by: Christopher Li <sparse@chrisli.org>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Stop code generation if anything is wrong in front-end.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Set const, thread_local, and alignment for global variables.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Avoid null pointer dereference when ->ident is null (e.g., anonymous
struct). Also, use ->aux to avoid recursion.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Cache symbol_type() result in ->aux to avoid recomputation.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
The array size should be ->bit_size over that of its element type,
rather than ->bit_size / 8.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Stick to LLVM_DEFAULT_TARGET_TRIPLE since LLVM_HOSTTRIPLE doesn't exist
on trunk anymore. Define LLVM_DEFAULT_TARGET_TRIPLE to LLVM_HOSTTRIPLE
for building with older LLVM.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Switch to LLVM_HOSTTRIPLE to make sparse-llvm compile with LLVM 3.0.
Acked-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Set target triple and data layout, which are required by LLVM's backend.
Also export arch_m64 for choosing the target architecture.
Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Converting pointers to integers for pointer arithmetic effectively
disables pointer analysis and future optimizations. A better way is to
use LLVM's GEP, by converting pointers to `char *' rather than integers.
Acked-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
LLVM needs to be correctly told about the type of the object
being accessed.
This patch also fixes code generation for struct accesses.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Use the fix from d5bd3662 ("sparse, llvm: Fix type of loaded values").
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Remove repeated code, such as get_func_type() vs sym_func_type(),
pseudo_type() vs symbol_type().
Fix generating variadic functions.
Add a test case using printf().
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
PHI in LLVM is different from that in sparse. LLVM requires PHI "for
each predecessor basic block of the current block" even if the current
block doesn't use it. It's tricky to correctly place PHI.
This patch implements a simpler and safer strategy:
1) allocate an alloca for each phi, and
2) translate phi/phisrc to load/store alloca.
LLVM optimizations will promote load/store to registers.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
When parsing a string or character constant, the parse_escape()
function returns a pointer to the character at which to resume
parsing. However, in the case of an hex or octal escape, it was
returning a one-past-the-end pointer. Thus, a string like:
char str[3] = "\x61\x62\x63";
was being parsed as:
'\x61', 'x', '6', '2', '\x63'
which, in turn, provokes an 'too long initializer' warning.
Also, fix an off-by-one error in get_char_constant() when setting
the 'end' pointer for a TOKEN_CHAR or TOKEN_WIDE_CHAR. Despite the
name, the string->length of the token is actually the size of the
allocated memory (ie len+1), so we need to compensate by using
'token->string->length - 1'.
Signed-off-by: Ramsay Jones <ramsay@ramsay1.demon.co.uk>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch fixes the following link errors.
libLLVMSupport.a(Signals.o): In function `llvm::sys::PrintStackTrace(_IO_FILE*)':
Signals.inc:269: undefined reference to `dladdr'
Signals.inc:281: undefined reference to `dladdr'
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Avoid evaluating INT_MIN / -1 and INT_MIN % -1, which will trap on x86
and crash sparse.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
It will indicate this argument will skip the type compatible check.
It allow PTR_ERR() to accept __iomem pointer without complaining.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
"#pragma once" acts like a multiple-inclusion guard affecting the entire file,
without an associated preprocessor symbol.
This allows use of sparse on projects that rely on #pragma once without
also using an ifndef-based multiple-inclusion guard, such as systemd;
without this change, sparse will get into an include loop.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
GCC defines a macro __SIZEOF_POINTER__ to the size of a pointer in
bytes. Define it in sparse as well.
Signed-off-by: Josh Triplett <josh@joshtriplett.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch added description for -Winit-cstring option
to sparse.1.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch added a test case for -Winit-cstring option
to validation directory.
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch adds new option -Winit-cstring to sparse.
With the option sparse can Warn about initialization of a char array
with a too long constant C string. If the size of the char array and
the length of the string is the same, there is no space for the last
nul char of the string in the array.
char s[3] = "abc";
If the array is used as just a byte array, not as C string, this
warning is just noise. However, if the array is passed to functions
dealing with C string like printf(%s) and strcmp, it may cause a
trouble.
Here is a example of such trouble:
http://www.spinics.net/lists/netdev/msg229765.html
http://www.spinics.net/lists/netdev/msg229870.html
Signed-off-by: Masatake YAMATO <yamato@redhat.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The previous warning about bad constant is actually
mean for variable length array.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
of sparse. Add --version to see it.
Reviewed-by: Joe Perches <joe@perches.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Currently there are a few source file in the kernel can't
parse property due to over run of the concatenation buffer.
They either have a large string concatnation or huge macro
expand. The TRACE macro is a common one.
Now show_token_sequence and quote_token_sequence is combined
into one function with a bigger buffer. It works for most
of the kernel source except the config_data.h. The kernel
config is about 70K, larger than the string allocator chunk size.
It needs some plumbing work in the allocator before we can
allow bigger string token.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Casting to _Bool requires a zero test rather than truncation. Also add
a new cast warning for _Bool since this is not about truncation.
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This allow compile "drivers/usb/core/hub.c" without
sefault.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
The forward declare test is known to give warnings.
Just make it matching the error output.
Same for check_byte_count-ice.c
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Add attribute "noclone" or "__noclone" or "__noclone__" as an
ignored attribute. Fixes this sparse warning:
arch/x86/kvm/vmx.c:6268:13: error: attribute '__noclone__': unknown attribute
Also add test case for 'noclone': validation/attr-noclone.c.
'make check' says for this test case:
TEST attribute noclone (attr-noclone.c)
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
this patch stops sparse from complaining about them not being
defined:
include/uapi/linux/swab.h:60:16: error: undefined identifier '__builtin_bswap32'
include/uapi/linux/swab.h:60:33: error: not a function <noident>
Signed-off-by: Kim Phillips <kim.phillips@freescale.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Pull preprocessor fix from Al Viro.
1) we really, really shouldn't convert escape sequences too early;
#define A(x) #x
A('\12')
should yield "'\\12'", *not* "'\\n'".
2) literal merging handles all sequences of string/wide string
literals; result is wide if any of them is wide. string_expression() is
handling that wrong - "ab"L"c" is L"abc"
3) with support (no matter how cursory) of wide char constants
and wide string literals, we really ought to handle
#define A(x,y)
A(L,'a')
properly; it's not that tricky - combine() needs to recognize <IDENT["L"],CHAR>
and <IDENT["L"],STRING> pairs.
4) '\777' is an error, while L'\777' is valid - the value should fit
into unsigned char or unsigned counterpart of wchar_t. Note that for string
literals this happens *after* phase 6 - what matters is the type of literal
after joining the adjacent ones (see (2) above).
5) stringifying should only quote \ and " in character constants and
string literals,
#define A(x) #x
A(\n)
should produce "\n", not "\\n"
6) we are losing L when stringifying wide string literals; that's
wrong.
I've patches hopefully fixing the above. Basically, I delay interpreting
escape sequences (past the bare minimum needed to find where the token ends)
until we are handling an expression with character constant or string literal
in it.
For character constants I'm keeping the token body in token->embedded -
4-character array replacing token->character. That covers practically
all realistic instances; character constant *may* be longer than that,
but it has to be something like '\x000000000000000000000000041' - sure,
that's 100% legitimate C and it's going to be the same as '\x41' on
everything, but when was the last time you've seen something like that?
So I've split TOKEN_CHAR into 5 values - TOKEN_CHAR+1--TOKEN_CHAR+4 meaning
1--4 characters kept in ->embedded[], TOKEN_CHAR itself used for extremely
rare cases longer than that (token->string holds the body in that case).
TOKEN_WIDE_CHAR got the same treatment.
AFAICS, with those fixes we get the same behaviour as in gcc for
silently ignored by cpp if the string/char constant doesn't make it
out of preprocessor. sparse still warns about those. The situation
with this one is frustrating; on one hand C99 is saying that e.g.
'\x' is not a token. Moreover, in a footnote in 6.4.4.4 it flat-out
requires diagnostics for such. On the other hand... footnotes are
informative-only and having "other character" token match ' would
puts us in nasal daemon country, so gcc is free to do whatever it feels
like doing. I think we shouldn't play that kind of standard-lawyering
*and* sparse has always warned on that, so I've left that warning
in place.
Note that real wchar_t handling is still not there; at the very least,
we need to decide what type will be used for that sucker (for gcc it's
int on all targets we care about), fix the handling of wide string literals
in initializers and evaluate_string() and stop dropping upper bits in
get_string_constant(). That would probably mean not using struct string
for wide ones, as well... Hell knows; I don't want to touch that right
now. If anything, I'd rather wait until we get to C11 support - they've
got much saner variants of wide strings there (char16_t/char32_t with
u and U as token prefix as L is used for wchar_t; there's also u8"..." for
UTF8 strings).
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
#define A(x) #x
A('\12')
should *not* yield "'\\n'"; the problem is that we are doing the conversion
too early.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
-include foo.h will search not only in the current directory...
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
This fix the regression report by Dan Carpenter. "x96_64" can be
a valid variable name.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Mauro Dreissig <mukadr@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Please pull the latest Sparse/LLVM tree from:
git@github.com:penberg/sparse-llvm.git llvm/core
It contains few LLVM backend fixes from myself and Jonathan Neuschäfer.
|
|
Instead of making the computed address a pointer to an int type
large enough to hold a pointer, make it a pointer to the memory
object being loaded. This fixes another LLVM warning.
Cc: Pekka Enberg <penberg@kernel.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
LLVM expects the first argument of "br" and "select" to be of type i1,
so add an "icmp ne <srcty> %src, 0" for other types.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Jonathan Neuschäfer reports:
A simple function like this will compile to the following llvm
bitcode:
/* C */
void func(void) {
return;
}
/* LLVM */
define i8 @func() {
L0:
ret void
}
The return type of the function and the type in the return instruction
don't match.
I found this inconsistency by running LLVM's bitcode validation on the
bitcode produced by sparse-llvm.
Move 'void *' special-casing from sym_basetype_type() to sym_ptr_type()
to fix the issue.
Reported by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
In later versions sparse-llvm should stop on wrong llvm code, instead
of outputting it, but for now there are too many warnings being produced
for this to be feasible (I think).
Cc: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Jonathan Neuschäfer writes:
compiling a little real-world program with sparse-llvm, it segfaulted.
Using a tool called "delta"[1] and some bash scripting, I managed to
reduce the code to this test case:
extern struct foo *foop;
extern void func(struct foo *f);
int main(int argc, char **argv) {
func(foop);
}
The problem is that pseudo_to_value() does not know abou the extern
symbol because Sparse never calls output_data() on it which registers
globals with LLVMAddGlobal().
As explained by Linus, 'extern' symbols are just names with types. They
don't have any value associated with them, they just have the type and
the name. Therefore we need to explicitly call LLVMAddGlobal() for
symbols we have not encountered in pseudo_to_value().
Reported by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Add some more ignored attributes which are used in glibc header files. It
silences the warnings such as the following:
/usr/include/bits/fcntl2.h:36:1: error: attribute '__error__': unknown attribute
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
We already had "vector_size" but we also need __vector_size__ to silence
some warnings in glibc:
/usr/include/bits/link.h:67:45: error: attribute '__vector_size__': unknown attribute
Signed-off-by: KOSAKI Motohiro <kosaki.motohiro@gmail.com>
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Pull 'for-chris' tree from Pekka Enberg:
"Please pull the latest sparse-llvm tree from:
git@github.com:penberg/sparse-llvm.git for-chris
It has one new validation test case and fixes to handle strings properly
in the LLVM backend."
Pekka Enberg (4):
sparse, llvm: Add _Bool to cast validation test
sparse, llvm: Simplify output_data() type logic
sparse, llvm: Fix string initializer code generation
sparse, llvm: Fix global string access code generation
|
|
This patch attempts to fix code generation for global string access:
static char *foo = "Foo !\n";
extern int puts(const char *s);
int main(int argc, char *argv[])
{
puts(foo);
return 0;
}
The generated executable causes a SIGSEGV:
[penberg@tux sparse]$ ./sparsec foo.c && ./a.out
Segmentation fault
But as pointed out by Xi Wang, the problem is in "output_load()":
I guess the problem is that sparse-llvm generates an incorrect type `load i64*'
in llvm from the sparse instruction load.64.
load.64 %r2 <- 0[foo]
call.32 %r1 <- puts, %r2
ret.32 $0
With the new ->ctype in pseudo sparse-llvm should be able to generate the
correct type. I am playing with an LLVM backend with typed pseudos; it
generates the following code, which seems okay.
@0 = internal global [7 x i8] c"Foo !\0A\00", align 1
@foo = internal global i8* getelementptr inbounds ([7 x i8]* @0, i64 0, i64 0), align 8
define i32 @main(i32 %argc, i8** %argv) {
entry:
%0 = load i8** @foo
%1 = call i32 @puts(i8* %0)
ret i32 0
}
So I'll leave the output_load() fix to a separate patch for now.
Cc: Xi Wang <xi.wang@gmail.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This fixes code generation for string initializer such as:
static char *foo = "Foo !\n";
It's the same fix Ben proposed earlier with the small difference that we now
use LLVMTypeOf() instead of symbol_type() to resolve the type.
The generated LLVM IR looks as follows:
[penberg@tux sparse]$ ./sparse-llvm foo.c |llvm-dis
; ModuleID = '<stdin>'
@"<noident>" = private global [7 x i8] c"Foo !\0A\00"
@foo = private global [7 x i8]* @"<noident>"
Reported-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Use LLVMTypeOf() in output_data() to simplify type handling logic.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Acked-by: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch adds casting backend validation test cases for the _Bool data type.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch sets ->stmt of a SYM_LABEL to the corresponding label
statement. If ->stmt was already set, it is a duplicate label.
On the other hand, if ->stmt of a goto label is not set during
evaluation, the label was never declared.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
compile-i386 sometimes crashes due a use-after-free error. Since
f->pseudo_list is freed first, which invalidates some atom->op* in
f->atom_list. Further checks like `atom->op1->flags & STOR_WANTS_FREE'
will read garbage, which may lead to a double free.
This patch switches the cleanup order and frees f->atom_list first.
Those marked as STOR_WANTS_FREE won't appear in f->pseudo_list.
Signed-off-by: Xi Wang <xi.wang@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
Reviewed-by: Pekka Enberg <penberg@kernel.org>
|
|
relevant content, and created Documentation/sparse.txt with the
complete comparison between __nocast vs __bitwise.
Signed-off-by: Shakthi Kannan <shakthimaan@gmail.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
On 05/08/2012 04:13 PM, Jan Pokorný wrote:
> When the cast is optimized out/target pointer type information lost,
> it may be impossible for backend to recover it (think of
> "struct foo *my_new_foo = malloc(sizeof(*my_new_foo))").
>
> Losing such pointer type information can be wider issue (structs and
> unions maybe), but this is the most exposed one and the patch tries
> to be minimal in this regard and the impact seems to be minimal
> too as usually type-correctness is followed.
I expected that if both operands of the cast appear to be pointers, it is
always OP_PTRCAST case, which is not true.
So this version exchanges inequality test for "or". Beside being
shorter, it covers such previously missed cases.
Based on asserts I experimented with, OP_PTRCASTs are always captured
by the condition implicitly (beside OP_CASTs with pointer-like operands).
Signed-off-by: Jan Pokorný <pokorny_jan@seznam.cz>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Currently, it is a completely "isolated island" from backend
point of view as it also lacks pseudo->def information.
Signed-off-by: Jan Pokorný <pokorny_jan@seznam.cz>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
a) it actually allows any number of ##<arg>##... in between, as long as all
those args are empty.
b) it does *not* allow ## after __VA_ARGS__ - if it's there magic disappears
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
... and streamline it a bit more, now that we get all \t hitting
the damn thing.
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
It's not a string literal, it's a static array
Signed-off-by: Al Viro <viro@zeniv.linux.org.uk>
|
|
This is improved version of Pekka Enberg's patch
"Fix including glibc headers on x86-64".
To avoid setting 64 bit define in the -m32 case,
the 64 bit initialization needs to delay until all
arguments are handled.
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
declare_builtin_functions
Signed-off-by: Frederic Crozat <fcrozat@suse.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
We need to tell llvm about it or it won't generate the proper
stack frame & argument list on some architectures.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
[ penberg@kernel.org: Fix function pointer calls ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
On Tue, Aug 30, 2011 at 10:43 AM, Jeff Garzik <jeff@garzik.org> wrote:
> * if someone knows how to access a function declaration, I can solve the
> varargs problem
Hmm. Right now we do not have access to the function declaration at
linearize time. We've checked that the arguments match, and we've cast
the arguments to the right types (evaluate.c), so the thinking was
that you just use the arguments as-is.
But if llvm needs the declaration of a function, we'd need to squirrel it away.
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
[ penberg@kernel.org: Fix validation/context.c breakage. ]
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch adds the 'leaf' GCC attribute to the list of ignored
attributes. Glibc uses this attribute causing the following
warnings in userspace projects:
/usr/include/stdlib.h:514:26: error: attribute '__leaf__': unknown attribute
Signed-off-by: Ethan Jackson <ethan@nicira.com>
Acked-by: Pekka Enberg <penberg@kernel.org>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
'master' branch of git://github.com/penberg/sparse-llvm.git
Revert "sparse: Bump up sizeof(_Bool) to 8 bits"
sparse, llvm: Add test case for <stdbool.h> type
sparse, llvm: Use LLVMInt1Type() in sym_basetype_type()
sparse, llvm: Don't fail the build if LLVM is too old
Merge pull request #6 from jgarzik/hacks
sparse, llvm: add loop testcase
sparse, llvm: Fix loops, by properly handling OP_PHI forward references
sparse, llvm: FP comparison op code generation
sparse, llvm: Simplify comparison op code generation
sparse, llvm: More comparison ops code generation
sparse, llvm: OP_SET_B and OP_SET_A code generation
sparse, llvm: Pointer cast code generation
sparse, llvm: Make llc output to stdout in sparsec
sparse, llvm: Fix 'extern' symbol code generation
sparse, llvm: Fix symbol initializer code generation
sparse, llvm: Function pointer code generation
sparse, llvm: Make 'sparsec' error handling more robust
sparse, llvm: Add support for union types
sparse, llvm: Add support for array types
sparse, llvm: Fix symbol_type() for bitfields and enums
sparse, llvm: Fix struct code generation
sparse, llvm: Use new LLVM type system API for structs
sparse, llvm: Fix 'void *' pointer code generation
sparse, llvm: Add support for logical ops
sparse: Bump up sizeof(_Bool) to 8 bits
sparse, llvm: Add support for symbol initializers
sparse, llvm: Add support for struct types
sparse, llvm: Fix code generation for 'long double' data type
Merge pull request #4 from jgarzik/hacks
sparse, llvm: support OP_STORE
sparse, llvm: move OP_COPY support to separate function. Add FP support.
sparse, llvm: store module-local functions on function reference list
llvm, sparse: Fix symbol_is_fp_type() goof
Merge branch 'master' of github.com:penberg/sparse-llvm
Merge pull request #3 from jgarzik/hacks
sparse, llvm: Fix pseudo_type() for PSEUDO_ARG
sparse, llvm: create helper for obtaining instruction's type
sparse, llvm: Fix code generation for casts
Revert "sparse, llvm: Don't redefine module local functions"
sparse, llvm: Don't redefine module local functions
sparse, llvm: Fix PSEUDO_OP code generation
sparse, llvm: Improve sparsec front-end
sparse, llvm: Fix OP_CAST to use zero-extend
sparse, llvm: Cleanup output_data()
sparse, llvm: Code generation for string constants
sparse, llvm: Warn the user when we fall back to GCC
Limit usage of g++ to llvm related programs.
Merge pull request #2 from jgarzik/hacks
sparse, llvm: move OP_CAST code to separate func. support FP casts.
cse: update PHI users when throwing away an instruction
cse: treat PHI-nodes as other instructions
Merge pull request #1 from jgarzik/hacks
sparse, llvm: move OP_PHI code from switch statement to separate function
sparse, llvm: implement OP_CALL
sparse, llvm: replace FIXME comment with assert(), following existing style
sparse-llvm OP_PHISOURCE: replace copy with target=src pointer operation
sparse, llvm: Kill debugging code
sparse, llvm: Kill ifdef'd unssa() call
sparse, llvm: Bitwise not operator codegen
sparse, llvm: Reorganize code generation tests
sparse, llvm: Floating point support for binops
sparse-llvm: OP_LOAD
sparse-llvm: OP_SWITCH
sparse-llvm: OP_SEL
sparse, llvm: if-else code generation
sparse, llvm: Implement OP_CAST
sparse, llvm: Move binop tests to validation/backend
sparse, llvm: Implement some binary comparison ops
sparse, llvm: Add support for more binary ops
sparse, llvm: Implement OP_ADD
sparse, llvm: Add output_op_binary() stub
sparse, llvm: Introduce 'struct function' to clean up code
sparse, llvm: Add support for OP_RET/PSEUDO_ARG
sparse, llvm: OP_RET/PSEUDO_VAL code generation
sparse, llvm: Add switch statement to output_insn()
llvm, sparse: Separate entry and exit basic blocks
sparse, llvm: Fix 'sparsec' when it's not in PATH
sparse, llvm: Fix global variable initialization
sparse, llvm: Fix assert() in sparse code
sparse, llvm: Initial commit
|
|
This reverts commit 2ded1e7406914eda77abde035416140849d76f68. It's no longer
needed as LLVM backend supports 1-bit integers.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
As it turns out, our validation test harness doesn't catch <stdbool.h> related
breakage so add a minimal test case that does.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
In preparation for reverting commit 2ded1e7 ("sparse: Bump up sizeof(_Bool) to
8 bits"), teach sym_basetype_type() about LLVMInt1Type().
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Disable sparse-llvm compilation if LLVM version is too old.
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
sparse, llvm: add loop testcase
|
|
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
|
|
Previous code simply omitted PHI sources that had not been assigned a
LLVMValueRef at the time of OP_PHI.
Fix by creating a list of such instances, and attempt to resolve forward
references at each OP_PHISOURCE appearance.
Testcase:
extern int bar (int);
int foo (int x)
{
int y = 0;
while (y < 1000) {
y += bar(x);
}
return y;
}
Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
|
|
This patch implements code generation for floating point versions of OP_BINCMP.
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Linus writes:
On Tue, Nov 22, 2011 at 9:40 AM, Pekka Enberg <penberg@kernel.org> wrote:
> This patch implements LLVM code generation for OP_SET_LE, OP_SET_GE, OP_SET_BE,
> and OP_SET_AE.
Ugh.
Can't you just do it with a single statement like
target = LLVMBuildICmp(fn->builder, translate_op(op), lhs, rhs,
target_name);
instead of having that case-statement where every case does the same thing?
The translate_op() thing should be trivial too, just something like
static int translate_op(int sparse_op)
{
static const int trans_tbl[] = {
.[OP_SET_LE] = LLVMIntSLE,
...
};
return trans_tbl[sparse_op];
}
or whatever. No?
Suggested-by: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Acked-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch implements LLVM code generation for OP_SET_LE, OP_SET_GE, OP_SET_BE,
and OP_SET_AE.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch implement unsigned less than and greater than comparison operator
LLVM code generation.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch implement code generation for OP_PTRCAST using LLVMBuildBitCast().
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch fixes a bug in 'sparsec' that made it generate empty object files.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
LLVMExternalLinkage is used for both extern and non-extern C symbols. The
linkage is differentiated by LLVMSetInitializer() which is should not be called
for extern symbols.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
The output_data() function does not see right hand side symbols for expressions
such as this in target.c:
struct symbol *size_t_ctype = &uint_ctype;
Therefore, call output_data() recursively if LLVMGetNamedGlobal() returns NULL
for a symbol.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Sparse doesn't parse binary constants properly so the following code
generates an error:
x = 0b11;
test.c:5:17: error: constant 0b11 is not a valid number
Kamal: add call to tolower(), since "0B11" is also a valid syntax.
Reported-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Dan Carpenter <error27@gmail.com>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
Signed-off-by: Christopher Li <sparse@chrisli.org>
|
|
This patch implements support for function pointer types and function pointer
calls to the LLVM backend.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Make 'sparsec' more robust against SIGSEGV in Sparse/LLVM code so that 'make
check' detects test breakage.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch adds support for SYM_UNION in symbol_type(). The LLVM API does not
provide support for unions so we treat them as opaque structs.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch adds support for SYM_ARRAY in symbol_type().
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch adds SYM_BITFIELD and SYM_ENUM support to symbol_type().
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Use LLVMGetTypeByName() to look up struct data types to fix code generation for
structs that refer to themselves.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
To fix an issue with structs that refer to themselves:
struct symbol {
struct symbol *next;
};
convert the code to use new type system API introduced in LLVM 3.0 so that
there's a LLVMTypeRef of the struct we can look up while walking through the
struct members.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Sparse front-end generates SYM_PTR with SYM_BASETYPE with bit_size set to -1
for "void *" pointers. We currently map that to LLVMVoidType() but that no
longer works with LLVM Subversion trunk:
$ ./sparse-llvm validation/backend/struct.c
sparse-llvm: Type.cpp:676: static llvm::PointerType* llvm::PointerType::get(llvm::Type*, unsigned int): Assertion `isValidElementType(EltTy) && "Invalid type for pointer element!"' failed.
Aborted
Fix the issue by treating 'void *' as 'char *' as suggested by Linus:
On Mon, 24 Oct 2011, Linus Torvalds wrote:
> Why bits_per_pointer? Isn't this the "base type" of void *? A more
> logical choice would seem to be to make it equivalent to "char *", and
> just make it fall through to the "case 8" case?
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
The generated asm for logical-ops.c test case looks as follows on x86-64:
GCC 4.6:
0000000000000000 <and_bool>:
0: 31 c0 xor %eax,%eax
2: 85 f6 test %esi,%esi
4: 0f 95 c0 setne %al
7: 31 d2 xor %edx,%edx
9: 85 ff test %edi,%edi
b: 0f 95 c2 setne %dl
e: 21 d0 and %edx,%eax
10: c3 retq
0000000000000020 <uand_bool>:
20: 31 c0 xor %eax,%eax
22: 85 f6 test %esi,%esi
24: 0f 95 c0 setne %al
27: 31 d2 xor %edx,%edx
29: 85 ff test %edi,%edi
2b: 0f 95 c2 setne %dl
2e: 21 d0 and %edx,%eax
30: c3 retq
0000000000000040 <or_bool>:
40: 09 fe or %edi,%esi
42: 0f 95 c0 setne %al
45: 0f b6 c0 movzbl %al,%eax
48: c3 retq
0000000000000050 <uor_bool>:
50: 09 fe or %edi,%esi
52: 0f 95 c0 setne %al
55: 0f b6 c0 movzbl %al,%eax
58: c3 retq
Sparse/LLVM:
0000000000000000 <and_bool>:
0: 85 f6 test %esi,%esi
2: 0f 95 c0 setne %al
5: 85 ff test %edi,%edi
7: 0f 95 c1 setne %cl
a: 20 c1 and %al,%cl
c: 0f b6 c1 movzbl %cl,%eax
f: c3 retq
0000000000000010 <uand_bool>:
10: 85 f6 test %esi,%esi
12: 0f 95 c0 setne %al
15: 85 ff test %edi,%edi
17: 0f 95 c1 setne %cl
1a: 20 c1 and %al,%cl
1c: 0f b6 c1 movzbl %cl,%eax
1f: c3 retq
0000000000000020 <or_bool>:
20: 09 f7 or %esi,%edi
22: 0f 95 c0 setne %al
25: 0f b6 c0 movzbl %al,%eax
28: c3 retq
0000000000000030 <uor_bool>:
30: 09 f7 or %esi,%edi
32: 0f 95 c0 setne %al
35: 0f b6 c0 movzbl %al,%eax
38: c3 retq
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
We need sizeof(_Bool) to be one byte to generate code for boolean expressions
in the LLVM backend.
Cc: Christopher Li <sparse@chrisli.org>
Cc: Jeff Garzik <jgarzik@redhat.com>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
sparse, llvm: store module-local functions on function reference list
|
|
testcase:
int foo(int *addr_i, int x)
{
*addr_i = x;
return x;
}
|
|
|
|
Fixes testcase:
int sum(int x, int y)
{
return x + y;
}
int main(int argc, char *argv[])
{
return sum(1, 2);
}
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Conflicts:
sparse-llvm.c
|
|
sparse, llvm: create helper for obtaining instruction's type
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Use with PSEUDO_VAL.
Also, remove needless braces around PSEUDO_ARG.
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This reverts commit be40b1a0e49a97f084c67d2ffc866b1445445d44.
Jeff Garzik explains:
That last commit isn't quite right. The code before wasn't quite right either,
but the new commit doesn't do a whole lot:
commit be40b1a0e49a97f084c67d2ffc866b1445445d44
Author: Pekka Enberg <penberg@kernel.org>
Date: Tue Aug 30 18:10:25 2011 +0300
sparse, llvm: Don't redefine module local functions
Signed-off-by: Pekka Enberg <penberg@kernel.org>
First problem: we already have a list of function calling conventions cached
for use. That is what llfunc_list is.
However... this is _very wrong_ for varargs functions. Your commit changes to
using an LLVM list from a local list, but that does not fix the problem.
This test case should demonstrate the broken code:
int foo(int x, int y)
{
printf("%d\n", x);
printf("%d, %d\n", x, y);
return 0;
}
The first printf() cached [incorrectly] the list of arguments. c.f. this code
comment:
/* to avoid strangeness with varargs [for now], we build
* the function and type anew, for each call. This
* is probably wrong. We should look up the
* symbol declaration info.
*/
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
This patch improves 'sparsec' so that things like
./sparsec hello.c
./sparsec hello.c -o hello
work like with GCC.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Linus Torvalds explains:
On Mon, Aug 29, 2011 at 12:45 PM, Pekka Enberg <penberg@kernel.org> wrote:
> However, i'm not 100% sure that's sufficient. Is OP_CAST always zero-extend
> or do we need to check for something specific here?
OP_CAST is always a zero-extend, OP_SCAST is a sign-extending one.
(Of course, they may be *truncating* casts too, which don't need to
generate any code on most architectures).
OP_PTRCAST should act as OP_CAST.
NOTE! The casting is dubious. We only have a single OP_FPCAST, for
example, and that's just broken. Right now "OP_FPCAST" means that the
*source* was a FP value. But if we cast *to* a FP value, it ends up
showing up as OP_[S]CAST, which is just bogus. The FPCAST should be
for any FP operation (to or from or both), and then the FPCAST logic
would have to decide how it handles it.
The FP support in general is pretty weak. The kernel doesn't do FP, I
never really cared about it.
This patch fixes comparison operator code generation. For example, this C code
int sete(int x, int y)
{
return x == y;
}
is translated as follows:
Before:
0000000000000000 <sete>:
0: 31 c9 xor %ecx,%ecx
2: 39 f7 cmp %esi,%edi
4: b8 ff ff ff ff mov $0xffffffff,%eax
9: 0f 45 c1 cmovne %ecx,%eax
c: c3 retq
After:
0000000000000000 <sete>:
0: 39 f7 cmp %esi,%edi
2: 0f 94 c0 sete %al
5: 0f b6 c0 movzbl %al,%eax
8: c3 retq
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|
|
Make sure the user knows when we're using GCC instead of sparse-llvm.
Signed-off-by: Pekka Enberg <penberg@kernel.org>
|