aboutsummaryrefslogtreecommitdiffstatshomepage
AgeCommit message (Collapse)AuthorFilesLines
2017-12-21fix: evaluate_dereference() unexamined base typeLuc Van Oostenryck3-2/+1
Examination of a pointer type doesn't examine the corresponding base type (this base type may not yet be complete). So, this examination must be done later, when the base type is needed. However, in some cases it's possible to call evaluate_dereference() while the base type is still unexamined. Fix this by adding the missing examine_symbol_type() on the base type. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-21add testcases for unexamined base typeLuc Van Oostenryck2-0/+64
evaluate_dereference() lacks an explicit examination of the base type. Most of the time, the base type has already been examined via another path, but in some case, it's not. The symptom here is the dereferenced value having a null size. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-16Merge branch 'testsuite-arg-env' into cli-macroLuc Van Oostenryck1-8/+6
2017-12-16fix: spaces in macro definition on the command lineLuc Van Oostenryck2-2/+1
GCC's manual or POSIX say about the '-D' option something like: '−D name[=value]' should be treated as if in directive '#define name value' (with '1' as default for the value), including its tokenization. So an option like '-DM(X, Y)=...' should be processed like a directive '#define M(X, Y) ...'. However, the current code treat a space as a separator between the macro and its definition, just like the '='. As consequence, the above option is processed like the directive would be '#define M(X, Y)=...', with 'M(X,' as the macro (name) and 'Y)=...' as its definition. Fix this by stopping to treat the space character specially, thus only using '=' as the separator. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-16add test case for space within command lineLuc Van Oostenryck1-0/+11
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-16Merge branch 'testsuite-fix-quotes-cmdline' into cli-macroLuc Van Oostenryck2-5/+14
2017-12-16testsuite: allow default args from environment for test commandsLuc Van Oostenryck1-1/+2
During testing it's sometimes useful to force some default arguments for all commands. An example of this is using '-m32' which essentially allow to run the tessuite on an 64bit machine as-if run a 32-bit one. Allow this by using the environment variable 'SPARSE_TEST_ARGS' to hole default arguments for the test commands. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-16testsuite: respect command line's quotes & whitespacesLuc Van Oostenryck2-6/+7
Currently the testsuite use 'eval echo $cmd' to expand the name of the test file to be given on the command line. This has the annoying consequence to go a bit too far in the expansion of variables and to destroy any quotes and whitespaces escaping that would have done. Fix this by doing the eval later, when effectively executing the command. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-16testsuite: process extra options without execLuc Van Oostenryck1-7/+4
Commit 399c43889 (testsuite: get options from env too) allowed the testsuite to takes extra options from the environment but did it in a crude way involving exec. Change this by using 'set --' instead of doing an 'exec'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-13testsuite: add test case for quoting of command's argumentsLuc Van Oostenryck1-0/+8
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-13fix: accept 'sparse -D M...'Luc Van Oostenryck2-5/+8
Till now, sparse was unneedlessly strict in what it accepted in '-D' options. More specifically, it doesn't accept: 1) separated '-D' and the macro definition, like: sparse -D MACRO[=definition] ... 2) a space between the '-D' and the macro name, like: sparse '-D MACRO[=definition] ... Case 1) is clearly accepted by GCC, clang and should be accepted for a POSIX's c99. Case 2's status is less clear but is also accepted by GCC and clang (leaving any validation to the corresponding internal #define). Fix this by accepting separated command line argument for '-D' and the macro (and removing the check that rejected the macro part if it started with a space). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-13add testcase for 'sparse -D M...'Luc Van Oostenryck1-0/+13
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-10Merge remote-tracking branch 'worktree/testsuite-next'Luc Van Oostenryck14-91/+92
Some fixes & improvements to the testsuite; mainly: - allow to run the testsuite on all the tests of a subdir - teach 'format' to directly append to the testcase - validate the 'check-...' tags Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: add support for 'format -a'Luc Van Oostenryck1-0/+5
The 'format' command create the information needed for the testcase from the input file and output this on stdout. The developper must then add this to the input file. Let's do this automatically by adding an option '-a' to the 'format' command to directly append the infos to the input file. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: default to shift in the getopt loopLuc Van Oostenryck1-9/+1
The getopt loop used to bear by default and only some options had to explicitly call 'shift' and 'continue' to process further elements. Change this to a 'normal' loop, shifting the next arg by default and breaking of the loop when needed. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: allow to test only a subdirLuc Van Oostenryck1-5/+17
During development, it is very useful to be able to run only some of the tests, maybe a whole class. Help this by allowing to run the testsuite on only a subdir of the 'validation/' directory. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: change do_usage textLuc Van Oostenryck1-7/+7
The text for the testsuite usage used 'none' as if it was an option/keyword while it only meant the absence of arguments. Make the text clearer by removing the 'none' and being explicit about the absence of arguments. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: move no-arg out of the getopt loopLuc Van Oostenryck1-6/+5
This is a preparatory step to allow to run only a part of the testsuite (a subdir). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: move do_test_suite out of the getopt loopLuc Van Oostenryck1-2/+1
This is a preparatory step to allow to run only a part of the testsuite (a subdir). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: early return in getopt loopLuc Van Oostenryck1-0/+4
This is a preparatory step to allow to run only a part of the testsuite (a subdir). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: validate the 'check-...' tagsLuc Van Oostenryck1-0/+12
Making a typo in one of the 'check-...' tags can make a testcase useless and thus incapable of detecting a regression. Add some validation to these tags in order to detect wrong tags. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: fix invalid 'check-...' tagsLuc Van Oostenryck8-12/+12
A few testcases had typos in their 'check-...' tags or the tag was plainly invalid. Fix them in accordance to the doc. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: reset 'quiet' at the start of each testcaseLuc Van Oostenryck1-1/+1
The flag 'quiet' is used to quiets unwanted error messages, for example for testcases known to fail, but this flag is reset too late so that the beginning of the next testcases will run with the value for the previous case. Fix this by reseting the flag at the begining of each testcase. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: add & use warning()Luc Van Oostenryck1-1/+9
Allow this new helper to indicate wich file trigger the warning and replace the existing call to 'echo "warning: ...'. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: move verbose/error() before get_tag_value()Luc Van Oostenryck1-17/+19
So, we can use them inside get_tag_value(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: remove old ugly pattern syntaxLuc Van Oostenryck1-32/+0
It was too ugly (and a bit longish). Remove it. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: convert to the new pattern syntaxLuc Van Oostenryck1-1/+1
The old one is too ugly and has to die. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: fix a few more incorrect check-commandsLuc Van Oostenryck3-3/+3
The exact syntax for commands is: 'check-command: ' <command> <args>... and the command itself must *not* be prefixed with './'. Fix the last three that had it wrong. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08testsuite: make the '%.t' rule depends on PROGRAMS tooLuc Van Oostenryck1-1/+1
The testsuite can be run on a specific testcase directly via the Makefile via a 'validation/%.t' pattern rule but this rule had no dependency on the programs being tested and thus could be run on a previous version. Fix this by adding the needed dependencies. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-08fix: add missing degenerate() for logical notLuc Van Oostenryck2-1/+1
Expressions involving the logical-not '!' does not call degenerate(). Since the result type is always 'int' and thus independent of the expression being negated, this has no effect on the type-checking but the linearization is wrong. For example, code like: int foo(void) { if (!arr) return 1; return 0; } generates: foo: load %r6 <- 0[arr] seteq.32 %r7 <- VOID, $0 ret.32 %r7 The 'load' being obviously wrong. Fix this by adding the missing degenerate(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-07add testcases linearization of degenerated arrays/functionsLuc Van Oostenryck3-0/+110
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-07add more testcases for using addresses in conditionalsLuc Van Oostenryck6-44/+177
and unify the existing ones. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-12-06fix: build sparse-llvm on i686s too.Luc Van Oostenryck1-1/+1
In commit "f1e4ba13d (build: disable sparse-llvm on non-x86)", we wanted to disable the build of sparse-llvm on non-x86 archs but the pattern used also excluded machines like 'i686'. Fix this by using the pattern 'i[3456]86' instead. Fixes: f1e4ba13d1499407a72349b50052ae818c8d8553 Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-20testsuite: fix: remove unneeded './' before commandsLuc Van Oostenryck13-13/+13
Some testcases have their command specified as './<command name>' but the './' part is unneeded as all commands are first prefixed with '../' before being run. Furthermore, the presence of these './' inhibit simple filtering of the disabled commands. Fix this by stripping the './' where it was used. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-18add support of floating-point specific arithmetic opsLuc Van Oostenryck8-32/+176
Floating-point arithmetic is quite different from the arithmetic on integers or the one of real numbers. In particular, most transformations, simplifications that can be done on integers are invalid when done on floats. For example: - associativity doesn't hold - distributivity doesn't hold - comparison is tricky & complex This is because (among others things): - limited precision, rounding everywhere - presence of signed zeroes - presence of infinities - presence of NaNs (signaling or quiet) - presence of numbers without inverse - several kind of exceptions. Since they don't follow the same rules as their integer counterpart, better to give them a specific opcode instead of having to test the type of the operands at each manipulation. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-18fix support of floating-point compareLuc Van Oostenryck9-26/+270
Comparision of floating-point values can't be done like for integral values because of the possibility to have NaNs which can't be ordered with normal values or even between themselves. The real difference appears once there is any "reasoning" done with the result of the comparison. For example, once NaNs are taken in account: "!(a < b)" and "(a >= b)" are not the same. In fact the usual comparison operators must be reinterpreted as implicitely first testing if any of the operand is a Nan and return 'false' if it is the case. Thus "a < b" becomes "!isnan(a) && !isnan(b) && (a < b)". If we need to negate the comparison we get "!(a < b)" which naturally becomes "isnan(a) || isnan(b) || (a >= b)". We thus need two sets of operators for comparison of floats: one for the "ordered" values (only true if neither operand is a Nan) and one for the "values" (also true if either operand is a NaN). A negation of the comparison switch from one of the set to the other. So, introduce another set of instructions for the comparison of floats. Note: the C standard requires that: *) "x == x" is false if x is a NaN, *) "x != x" is true if x is a NaN, and this is coherent with "x != x" <-> "!(x == x)". Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-18add test case for boolean negation on floatLuc Van Oostenryck1-0/+9
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-18fix linearize_inc_dec() with floatsLuc Van Oostenryck2-2/+29
Using the pre or post increment or decrement operator on floating-point values mix the addition of a floating-point value with an *integral* constant 1 or -1. Fix this by checking if we're dealing with fp or not and using the proper fp constants (1.0 or -1.0) if it is the case. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: only compare void pointersLuc Van Oostenryck1-0/+4
LLVM use a stricter type system for its IR than sparse does. In the present case, sparse allow to compare pointers regardless of their types. This create LLVM errors if we try to simply translate, instruction by instruction, sparse's compare instructions to LLVM ones. Fix this by casting all pointers to void *, before comparing them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for float initializerLuc Van Oostenryck1-0/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: warn instead of assert on global initsLuc Van Oostenryck1-1/+6
Currently, sparse-llvm can't emit the needed code for all initializers and when it's the case it stop abruptly with an assert(0). This is kinda useless. Somehow fix this by issuing a warning instead and try to continue gracefully. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: gracefully catch impossible type/valueLuc Van Oostenryck1-2/+9
Until now, in sparse-llvm, an assert(0) was used each time something which was not yet handled was encountered. This is doubly annoying because: - the assert gave no info about the cause - it also hide possible further issuses. Fix this by: - removing the asserts - use a warnng explaining what's at hand - try to continue with the following instructions. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: give names easier to debugLuc Van Oostenryck2-6/+6
LLVM automatically add an numeric suffix for names automatically created. So, if intermediate names must be created for a pseudo whose name was, for example, "%R4", these new names will be "%R41", "%R42". This is quite annoying because we can't make the distinction between these names and the original names, (maybe of some other pseudos whose names were "%R41" & "%R42). Change this by adding a "." at the end of each name, as this will then allow to see what the original name was. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix creation of sparsec's tmp filesLuc Van Oostenryck1-2/+2
It seems the intention was to create the tmp files with the suffixes but the files are create without the suffixes (while the filename that is used later is with the suffixes). In all case the non-suffixed file that is created by the mktemp command is never removed and after a while these files begin to pile-up. Better to remove them. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: cleanup of output_[ptr]cast()Luc Van Oostenryck1-27/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for cast from floatsLuc Van Oostenryck2-3/+9
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for OP_FPCASTLuc Van Oostenryck2-3/+24
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix type of bitfieldsLuc Van Oostenryck1-0/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix get value from non-anonymous symbolLuc Van Oostenryck3-9/+44
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix get value from initialized symbolLuc Van Oostenryck1-14/+13
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for restricted typesLuc Van Oostenryck1-0/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutated OP_[PTR]CASTLuc Van Oostenryck1-6/+4
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutated OP_PHISOURCELuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutated OP_SWITCHLuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutated OP_SELLuc Van Oostenryck1-3/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutated OP_RETLuc Van Oostenryck1-3/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix mutating function pointerLuc Van Oostenryck2-6/+64
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: take care of degenerated rvaluesLuc Van Oostenryck5-6/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix variadic calls with constantsLuc Van Oostenryck2-2/+5
The linearized code, sparse's IR, have no use of C's complex type system. Those types are checked in previous phases and the pseudos doesn't have a type directly attached to them as all the needed typing info info are conveyed by the instructions. In particular, PSEUDO_VAL (used for integer and address constants) are completely typeless. There is a problem with this when calling a variadic function with a constant argument as in this case there is no type in the function prototype (for the variadic part, of course) and there is no defining instructions holding the type of the argument. Fiw this by using the type of the arguments explicitly given in the OP_CALL instructions. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add testcase for calling variadic functionsLuc Van Oostenryck1-0/+28
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add small script to test LLVM generated bytecodeLuc Van Oostenryck2-1/+16
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: let pseudo_to_value() directly use the typeLuc Van Oostenryck1-21/+21
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add test case pointer compare with castLuc Van Oostenryck1-0/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: make value_to_ivalue() more flexibleLuc Van Oostenryck2-5/+23
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: make value_to_pvalue() more flexibleLuc Van Oostenryck1-3/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix OP_SWITCH has no targetLuc Van Oostenryck2-3/+249
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for OP_SWITCH with a rangeLuc Van Oostenryck1-10/+7
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: give a name to all valuesLuc Van Oostenryck1-13/+20
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: make pseudo_name() more flexibleLuc Van Oostenryck1-11/+6
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix type of switch constantsLuc Van Oostenryck1-1/+1
In sparse-llvm, the type of switch constants are hardcoded to 'i32'. Fix this by using the right type as given by the instruction. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: variadic functions are not being marked as suchLuc Van Oostenryck1-1/+1
It appears that when a function is compiled, its variadic flag is not being set in LLVM so LLVM complains when at call sites variable arguments are passed. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Originally-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: adjust OP_RET's typeLuc Van Oostenryck2-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: give correct type to binopsLuc Van Oostenryck4-0/+110
Pointer arithmetic and/or simplification can mixup pointer and integer types. Fix this by adding casts before all non-floating point binops and adjust the result type if needed to match the instructio. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix type in comparison with an address constantLuc Van Oostenryck2-2/+13
Since sparse's constant are typeless comparing a pointer with an address constant lack correct type information. Fix this by casting the constant to the same type as the LHS. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix pointer/float mixup in comparisonsLuc Van Oostenryck2-2/+24
In output_op_compare() everything that is not of interger type is treated as floats. Pointers disagree. Fix this by rearranging the code and treat pointers like integers as required for LLVM's icmp. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: ignore OP_INLINED_CALLLuc Van Oostenryck1-1/+0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for OP_SETVAL with labelsLuc Van Oostenryck2-0/+16
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for OP_SETVAL with floatsLuc Van Oostenryck2-1/+25
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add support for OP_NEGLuc Van Oostenryck1-2/+15
sparse-llvm has not yet support for OP_NEG and stop on an assert if one is encountered. Fix this by invoking the appropriate LLVMBuild[F]Neg(). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add test cases for degenerated pointersLuc Van Oostenryck1-0/+73
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add test cases for arrays passed as argumentLuc Van Oostenryck1-3/+146
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add test cases for pointers passed as argumentLuc Van Oostenryck1-0/+43
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: add test cases for symbol's addressLuc Van Oostenryck1-0/+63
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix output_op_[ptr]cast()Luc Van Oostenryck1-5/+35
OP_PTRCASTs can't always be directly translated into LLVM bitcasts and OP_[S]CASTs can't always be translated into LLVM's trunc/sext/zext because integer to pointer and pointer to integer must be handled too. Fix this in output_op_ptrcast() & output_op_cast() by issuing LLVMBuildIntToPtr/PtrToInt when appropriate. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix output_op_store() which modify its operandLuc Van Oostenryck2-4/+18
In sparse-llvm the field 'priv' of a pseudo is used to store the corresponding LLVMValueRef. This field is normaly assigned when processing the instruction that produces the speudo. In output_op_store(), the field insn->target->priv is overwritten by the LLVMValueRef returned by LLVMBuildStore(). It's unclear what this return value is: - this corrupts the pseudo, making it unusable in subsequent instructions. - there is no reason to change this field anyway. Fix this by removing the assignment to insn->target->priv in output_op_store(). Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix translation of PSEUDO_VALs into a ValueRefsLuc Van Oostenryck3-1/+77
In sparse-llvm there is the assumption that a PSEUDO_VAL is always of integer type. But this is not always the case: constant pointers, like NULL, are also of the PSEUDO_VAL kind. Fix this by adding a helper 'val_to_value()' and using the instruction's type where this pseudo is used as the type of the value. Note: while this patch improve the situation, like for example for the test cases added here, it's still not correct because now we're making the assumption that 'insn->type' is the type we need for the pseudo. This is often true, but certainly not always. For example this is not true for: - OP_STORE/OP_LOAD's insn->src - OP_SET{EQ,...}'s insn->src[12] - probably some others ones - in general, obviously, for any instructions where the target has a different type than the operands. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: fix test of floating-point typeLuc Van Oostenryck1-25/+17
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: extract get_sym_value() from pseudo_to_value()Luc Van Oostenryck1-47/+53
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: avoid useless temp variableLuc Van Oostenryck1-5/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: give a name to call's return valuesLuc Van Oostenryck1-1/+6
Currently, a name is given to the result of instruction like binops, compares, ... but not to function calls. Functionally, it doesn't change anything but those names are useful by easing reading while debugging, reading the generated code, ... Fix this by giving a name to OP_CALL's result too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: give arguments a nameLuc Van Oostenryck1-0/+12
Arguments, like all LLVMValues, are given a default name but these name are simply '%0', '%1', ... and are thus not very readable. Fix this by giving them an explicit name 'ARG1', ... to match the names used in sparse's linearized code. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: use pseudo_list_size() instead of open coding itLuc Van Oostenryck1-4/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: reduce scope of 'bb_nr'Luc Van Oostenryck1-2/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: remove unneeded function::typeLuc Van Oostenryck1-3/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: remove unneeded 'generation'Luc Van Oostenryck1-11/+2
It's not needed here since there is no recursive access to BBs. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17llvm: remove unneeded arg 'module'Luc Van Oostenryck1-37/+37
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17add support for wider type in switch-caseLuc Van Oostenryck3-5/+52
Currently the different cases of a switch-statement, or more exactly the 'struct multijmp' that hold the value of these cases excepted only value of 'int' type. Trying to use a wider value results in the value being truncated but any integer value should be valid. Fix this by unsigned 'long long' to hold these values. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-17add doc about sparse's instructions/IRLuc Van Oostenryck1-0/+293
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16give a type to OP_SWITCHsLuc Van Oostenryck1-2/+3
For consistency and for sparse-LLVM which needs it, give them a type too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16give a type to OP_SELs, alwaysLuc Van Oostenryck1-1/+1
Currently, when a phi-node is converted into a OP_SEL this instruction is given a size but not a type but when created directly it is given a type. For consistency and for sparse-LLVM which needs it, give them always a type. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16give a type to OP_PHISOURCEsLuc Van Oostenryck4-12/+10
Currently, OP_PHISOURCEs are given a size but not a type. For consistency and for sparse-LLVM which need it, give them a type too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16give a type to all function argumentsLuc Van Oostenryck3-7/+31
The linearized code, sparse's IR, have no use of C's complex type system. Those types are checked in previous phases and the pseudos doesn't have a type directly attached to them as all the needed typing info info are conveyed by the instructions. In particular, PSEUDO_VAL (used for integer and address constants) are completely typeless. There is a problem with this when calling a variadic function with a constant argument as in this case there is no type in the function prototype (for the variadic part, of course) and there is no defining instructions holding the type of the argument. Possible but rejected solutions are: * give a full type to all pseudos This is silly as, for example 'int 0' and 'unsigned int 0' are, really, the same constants. * give simply a size to all pseudos This seems to be simple enough but *currently* it negatively impacts CSE (maybe because of some others deficiencies in the type system, especially for casts). * give a type to all function arguments via a new instruction that would mimic argument passing (OP_ARG or OP_PUSH). This solution is interesting, especially as it gives a placeholder for real argument passing at code generation time, but: 0) they can be added, if needed, when some code generation will be done. 1) it creates a superfluous instruction for every argument of every function call 2) these instructions are essentially copy instructions in disguise. So, since the problem only exist for constants used in variadic arguments (and currently, it's only a problem for sparse-llvm), the solution selected is to add to OP_CALLs a list holding the type of all arguments. More exactly, it reuses the field .fntype which was used to store the type of the function, and changes it to a list holding the function type *and* the type of all effective arguments. Reported-by: Dibyendu Majumdar <mobile@majumdar.org.uk> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16inlined calls should not block BB packingLuc Van Oostenryck3-5/+32
OP_INLINED_CALL are there only as a sort of annotation for debugging purpose. Their presence should thus not block the packing of basic blocks. Fix this by ignoring OP_INLINED_CALL when trying to pack a basic block. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16fix usage of inlined callsLuc Van Oostenryck2-1/+59
OP_INLINED_CALL are there only as a sort of annotation for debugging purpose. It is thus wrong to associate pseudo's usage to them (even if the pseudo are the arguments of the function now inlined). Fix this by removing the use_pseudo() for each arguments. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16add is_signed_type()Luc Van Oostenryck3-22/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16canonicalize compare instructionsLuc Van Oostenryck4-14/+151
Currently only commutative instructions are canonicalized (the "simpler" operands, often a constant, is forced, if present to be in the second operand). This improve CSE (more cases are considered as equivalent) and help to reduce the number of "pattern" to be handled at simplification. Do this also for compare instructions since in thsi case we can swap the order of the operands if at the same time we also swap the 'direction' on the comparison. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16canonicalize binops before simplificationLuc Van Oostenryck1-11/+9
Currently, canonicalization of binops (more specifically insuring that the operands of binops are in canonical order) is only done after simplify_binop(). But the goal of canonicalization is to limit the number of cases/patterns we need to check/handle during ... simplification. So canonicalization need to be done before simplification. Fix this by moving (this part of) canonicalization before doing simplification. Note 1: the motivation of this patch is to prepare code for the canonicalization of compare instructions Note 2: this patch allow now some simplification of ... the simplification code (simplify_binop()), this will be done in a later serie. Note 3: this patch changes slightly the cost of the CSE/ simplification, positively or negatively, depending on the ration of simplification/canonicalization that can be done. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16use opcode table for compare_opcode()Luc Van Oostenryck1-25/+1
At the same time, change also the name of the function. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16add table to "negate" some opcodeLuc Van Oostenryck4-0/+49
Some optimizations transform an instruction opcode into another. For example, it may be needed to know the opcode corresponding to the negation of a comparison. This patch make this easy and flexible by adding a table for the relation between opcodes. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16don't output value of anonymous symbol's pointerLuc Van Oostenryck1-2/+2
The value of this pointer is of no use unless you're using a debugger (or just to see if two things are identical or not) and it's presence produces noise when comparing the output of two runs for testing. Change this by issuing it only if 'verbose' is set. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-16show OP_PHI without VOIDLuc Van Oostenryck1-0/+2
As the normal result of branch simplification OP_PHI can have some VOID in their phi_list, sometimes lots of them. These list can't be simplified, comacted or so because the address of the pseudos is used for the pseudo tracking. But it's annoying that these VOID are displayed by show_instruction(), it make things sometimes hard to read. Chnage this by ommiting to display them (when not verbose). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13Merge branches 'testcases-bugs', 'testcases-bugs-optim' and ↵Luc Van Oostenryck35-0/+799
'testcases-mem2reg' into tip
2017-11-13add test case for missing conversion to selectLuc Van Oostenryck1-0/+24
This may seems as an missing optimization problem but in truth, the root cause is a problem with SSA conversion. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test cases for canonicalization of boolean expressionsLuc Van Oostenryck1-0/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add testcase for mem2reg/SSA conversionLuc Van Oostenryck28-0/+629
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for superfluous cast with volatilesLuc Van Oostenryck1-0/+14
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test cases for simplification of equivalent to 'x == 0' or 'x != 0'Luc Van Oostenryck2-0/+24
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add testcase for return & inlineLuc Van Oostenryck1-0/+24
The linearization of 'return' statements must correctly take in account some implementation details of the inlining. As such, it deserves its own testcase. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for pre-processor extra tokens warningLuc Van Oostenryck1-0/+15
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test cases for canonicalization of mul chainsLuc Van Oostenryck1-0/+24
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add testcase for __builtin_unreachable()Luc Van Oostenryck1-0/+31
__builtin_unreachable()'s semantic has consequences on the CFG and this should be taken in account for: * checking for undefined variables * checking when control reaches end of non-void function * context checking * ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for compound literalsLuc Van Oostenryck2-0/+45
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test cases for canonicalization of add/sub chainsLuc Van Oostenryck1-0/+55
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for missed overflow detectionLuc Van Oostenryck1-0/+19
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for bad layout of bool in bitfieldsLuc Van Oostenryck1-0/+26
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case using sizeof on incomplete typeLuc Van Oostenryck1-0/+27
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case storage specifier in struct memberLuc Van Oostenryck1-0/+20
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case bitfields in K&R declLuc Van Oostenryck1-0/+14
Reported-by: Lance Richardson <lrichard@redhat.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for incomplete typeLuc Van Oostenryck1-0/+20
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for conditionally undefined varLuc Van Oostenryck1-0/+21
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for memory to register problemLuc Van Oostenryck1-0/+25
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for VLA sizeofLuc Van Oostenryck1-0/+37
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13add test case for using multiple input filesLuc Van Oostenryck1-0/+11
GCC can be called with several input files in a single invocation but these files are processed individually. There is so no reasons to warn about a symbol being already defined in a previous file. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13Merge branch 'dump-ir' into tipLuc Van Oostenryck11-76/+257
2017-11-13dump-ir: activate -fdump-ir=mem2regLuc Van Oostenryck1-0/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13dump-ir: make it more flexibleLuc Van Oostenryck8-19/+78
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13dump-ir: rename -fdump-linearize to -fdump-irLuc Van Oostenryck8-11/+11
as it will be used for dumping the IR not only just after linearization but after other passes too. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13dump-ir: saner use of fdump_linearizeLuc Van Oostenryck3-4/+5
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-13dump-ir: allow to skip the optimization pass(es)Luc Van Oostenryck1-0/+2
For experimenting with some optimization and the linearization process, it's useful to see the raw result, without any kind of optimization. This patch test PASS_OPTIM (-foptim-{enable,disable}) to see if the whole optimization process can be skipped. Note: ideally, this should be coupled with -O0 but this could create problems with the 'sparse' tools when used on file wit an optimization level of 0 (since the sparse tools depends on the optimization for the context checking to be accurate and in general diagnostics also need at least basic optimization). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-12dump-ir: activate/deactive pass 'mem2reg'Luc Van Oostenryck1-1/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-12dump-ir: allow to specify the passes to execute via cli's optionsLuc Van Oostenryck4-0/+54
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-12dump-ir: add testcase for option parsing corner caseLuc Van Oostenryck2-0/+10
2017-11-11Merge branches 'volatile-loads-are-side-effects', ↵Luc Van Oostenryck30-193/+552
'fix-volatile-simplification', 'struct-asm-ops', 'restricted-pointers', 'fix-f2i-casts', 'symaddr-description', 'flush-stdout' and 'diet-simple' into tip
2017-11-11fix: volatile stores must not be simplifiedLuc Van Oostenryck2-2/+5
kill_dominated_stores() simplify away redundant stores. Nice but volatile stores are never redundant and must never be simplified away. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11add test case for bogus volatile simplificationLuc Van Oostenryck1-10/+6
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11flush stdout when warningLuc Van Oostenryck1-0/+1
This is much needed for tools like test-linearize which output on stderr & stdout and without this patch error messages and normal output are out-of-sync. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11fix description setval & symaddrLuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11Merge branches 'constexpr-shorter-name', 'testsuite-clean', 'make-cleanup', ↵Luc Van Oostenryck33-347/+445
'graph-cleanup' and 'cgcc-cleanup' into tip
2017-11-11fix 'simplification' of float-to-int castsLuc Van Oostenryck3-4/+42
Currently, simplify_cast() don't really take floating-points in account and happily simplify away a float-to-int cast if both types have the same size. Fix this by not touching such casts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-11define MOD_ACCESS for (MOD_ASSIGNED | MOD_ADDRESSABLE)Luc Van Oostenryck3-4/+4
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10volatile loads are side-effects tooLuc Van Oostenryck2-0/+20
Some branch simplifications are only valid if the branch is free of side-effects. The check is done in flow.c:bb_has_side_effects() but currently deosn't take in account the fact that a volatile load is also a side-effect. Fix this by adding the appropriate check. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10Makefile: use locally built sparse in the selfcheck targetRamsay Jones1-1/+1
Signed-off-by: Ramsay Jones <ramsay@ramsayjones.plus.com> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: let -fno-strict-aliasing be a mandatory flagLuc Van Oostenryck1-1/+6
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add rule to run a single testLuc Van Oostenryck1-0/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use a single space before assignmentsLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: reorg & add commentLuc Van Oostenryck1-8/+9
No functionnal changes here, only shuffling a few lines around, adding separators and adding a few comments Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: avoid foreachLuc Van Oostenryck1-9/+11
(g)make foreach can be quite handy but it also make Makefiles much less declarative and thus harder to read. Avoid them by adding the few needed assignments & dependencies. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add *.o to clean-check patternLuc Van Oostenryck1-0/+1
.o files are also created in the validation directory (currently only tmp.o, for sparse-llvm/sparsec testing). Aso remove them during make clean-check. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: simplify clean patternLuc Van Oostenryck1-7/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: simplify quiet commandsLuc Van Oostenryck1-13/+12
The current mechanism for the quiet commands, what's hiding the true command and emitting instead things like: CC target.o is, IMO, somehow unneedlessly sophisticated and this doesn't help to understand what's happening and to adapt things when needed. Change this by using simple 'echo' commands and make's '@' to display the short command and hiding the long one. Warning: There is a small change in behaviour with this: previously, when displaying the non-quiet commands with 'make V=1' the quiet ones were not emitted. Now, with this patch, the short/quiet command is emitted in both case. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: let quiet commands use less indentationLuc Van Oostenryck1-8/+8
Now it does the same as done in the kernel: 2 + 8. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove unused QUIET_INST_SHLuc Van Oostenryck1-1/+0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use standard rules for installLuc Van Oostenryck1-21/+14
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow the name 'local.mk' to be configurable via the environmentLuc Van Oostenryck2-1/+3
So people who like this file to be a hidden one or to be an out-of-tree file or simply who don't like the name, can choose whatever suits them the best. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use one line per itemLuc Van Oostenryck1-8/+43
This help to minimize merge conflicts. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove the dist rule since unusedLuc Van Oostenryck1-7/+0
The last .tar.gz was for v0.5.0 in 2014. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: normalize rulesLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove rule for shared lib, it's unusedLuc Van Oostenryck1-15/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: make clean targets quieterLuc Van Oostenryck1-2/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: move clean & clean-check togetherLuc Van Oostenryck1-3/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: remove references to unexisting pre-process.hLuc Van Oostenryck2-2/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: add note about overwritable varsLuc Van Oostenryck1-0/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: only generate version.h when neededUwe Kleine-König1-8/+14
This way version.h isn't generated when running $(make clean) but only when lib.c is about to be compiled. This simplifies packaging for Debian because the package building programs abort when there are additional files after $(make clean). Signed-off-by: Uwe Kleine-König <uwe@kleine-koenig.org> Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: move tests near their useLuc Van Oostenryck1-38/+41
No functional changes here, just moving things around. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: CHECKER_FLAGS=-Wno-vla for all targetsLuc Van Oostenryck1-3/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: reuse rule for ALL_OBJSLuc Van Oostenryck1-3/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: no need to use wildcards for generated dependenciesLuc Van Oostenryck1-4/+3
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use $LIBS directly in the dependency listLuc Van Oostenryck1-2/+2
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: avoid rule-specific CFLAGSLuc Van Oostenryck1-1/+1
Those are not evil but it's for consistency with the remaining. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow CFLAGS & friends from command lineLuc Van Oostenryck1-3/+3
This allow distros or devs to override the default CFLAGS, CPPFLAGS, LDFLAGS, ... Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: allow target-specific CFLAGS, CPPFLAGS, LDFLAGS & LDLIBSLuc Van Oostenryck1-8/+11
This a preparatory step to allow these flags to be overriden from the command line. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use '-ldlibs' instead of '_EXTRA_OBJS'Luc Van Oostenryck1-4/+4
Some of the programs need to link with some external libraries. For some reasons, these libraries are specified via variables named: "<target>_EXTRA_OBJS". Use the '-ldlibs' prefix instead to better reflect the real use. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-10build: use '-objs' instead of '_EXTRA_DEPS'Luc Van Oostenryck1-6/+6
Some programs are composed of several source files other than the main one. These files need then to be added at linking time. These extra file are currently specified using variables named "<program-name>_EXTRA_DEPS" but the way these variables are used make that they can only hold .o files (or .a ones) and are not some kind of generic dependencie. Make this explicit by using the suffix '-objs' instead. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08add support for C11's _Atomic as type qualifierLuc Van Oostenryck7-2/+127
This only add the parsing and checks as a type qualifier; there is no operational semantic associated with it. Note: this only support _Atomic as *type qualifier*, not as a *type specifier* (partly because there an ambiguity on how to parse '_Atomic' when followed by an open parenthesis (can be valid as qualifier and as specifier)). Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08associate MOD_RESTRICT with restrict-qualified variablesLuc Van Oostenryck8-6/+238
Note: there is still no semantic associated with 'restrict' but this is a preparatory step. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08define MOD_QUALIFIER for (MOD_CONST | MOD_VOLATILE)Luc Van Oostenryck4-5/+6
This is slightly shorter (and thus may avoid long lines) and facilitate the introduction of MOD_RETRICT in a later patch. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08remove redundancy in MOD_STORAGELuc Van Oostenryck2-2/+2
MOD_TOPLEVEL & MOD_INLINE are already include in MOD_STORAGE so there is no need to repeat them in MOD_IGNORE & elsewhere where MOD_STORAGE is used. Change this by removing the redundant MOD_TOPLEVEL & MOD_INLINE. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08reorganize the definition of the modifiersLuc Van Oostenryck1-33/+32
Now they are grouped a bit more logically. Note: MOD_ASSIGNED & MOD_ADDRESSABLE are not type modifiers but properties of the symbol. As such they should be moved to struct symbol. However, as they should be correctly propagated to the symbol components if any, better to leave them as is. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08MOD_ACCESSED is not a type modifier ...Luc Van Oostenryck5-9/+5
but is used to track which inline functions are effectively used. So better remove it from the MOD_... and implement the same functionality via a flag in struct symbol. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08remove never-used MOD_TYPEDEFLuc Van Oostenryck3-6/+0
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: add support for 'format -l'Luc Van Oostenryck1-1/+13
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: add support for 'format -f'Luc Van Oostenryck1-2/+12
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: format: strip .c from default nameLuc Van Oostenryck1-1/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: format: saner defaults handlingLuc Van Oostenryck1-10/+5
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: make do_format() more self-containedLuc Van Oostenryck1-3/+27
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: move up arg_file()Luc Van Oostenryck1-15/+17
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: 'quiet' must be initialized earlierLuc Van Oostenryck1-0/+1
as it can, for example, be needed via arg_file() -> error() Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: add a blank line before formatLuc Van Oostenryck1-0/+1
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: save screen real estateLuc Van Oostenryck1-2/+2
Emit the short command witht he same sacing as done in the kernel: 2 + 8. Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>
2017-11-08testsuite: allow arch-specific testsLuc Van Oostenryck2-0/+23
Signed-off-by: Luc Van Oostenryck <luc.vanoostenryck@gmail.com>