diff options
author | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 21:13:54 +0100 |
---|---|---|
committer | Luc Van Oostenryck <luc.vanoostenryck@gmail.com> | 2017-11-16 21:13:54 +0100 |
commit | 4d15929201e0bf91df213e624d833541b61c4cb8 (patch) | |
tree | 6de666ef6f265170ee4318d3e5d47f17487672b1 /linearize.h | |
parent | 8376a70ce36ef3e22bfbab06455f5b6397f9c2de (diff) | |
download | sparse-4d15929201e0bf91df213e624d833541b61c4cb8.tar.gz |
give a type to all function arguments
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>
Diffstat (limited to 'linearize.h')
-rw-r--r-- | linearize.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/linearize.h b/linearize.h index 0a9d2547..1a637e41 100644 --- a/linearize.h +++ b/linearize.h @@ -114,7 +114,7 @@ struct instruction { struct /* call */ { pseudo_t func; struct pseudo_list *arguments; - struct symbol *fntype; + struct symbol_list *fntypes; }; struct /* context */ { int increment; |