Commit Graph

9514 Commits

Author SHA1 Message Date
Bill Currie 3e38c4aa48 Merge branch 'qfcc-cse'
qfcc now does local common subexpression elimination. It seems to work, but
is optional (default off): use -O to enable. Also, uninitialized variable
detection is finally back :)

The progs engine now has very basic valgrind-like functionality for
checking pointer accesses. Enable with pr_boundscheck 2
2012-12-13 20:17:28 +09:00
Bill Currie 47c721b32e Clear the dstring in test-harness's printf builtin.
PR_Sprintf always appends to the result dstring. I'm not sure if this is by
design or a bug, so I'll leave it be for now.
2012-12-13 14:59:42 +09:00
Bill Currie decc3845c5 Kill any aliases when assigning to an aliased def.
Temps aren't supported yet :P

The alias defs themselves aren't killed (still want any assignments to
occur) but rather, their nodes are. Also, edges to the alias defs' nodes
are added to the assigning node. Fixes structlive.r :)
2012-12-13 14:43:43 +09:00
Bill Currie 2dc60d4f9a Allow tests for full overlap of defs.
Not actually used yet, but I imagine I'll want it.
2012-12-13 14:42:51 +09:00
Bill Currie 821081c9c8 Use the desination type for moves in assign_expr.
for <struct> = nil; the source type is void and thus probably the wrong
size.
2012-12-13 14:05:24 +09:00
Bill Currie 503154257c Fix an uninitialized variable.
Yay valgrind, boo taniwha.
2012-12-13 13:58:30 +09:00
Bill Currie 3665a0566a Add a test for struct writes.
This tests local kills via aliases.
2012-12-13 13:44:25 +09:00
Bill Currie 0ff6e8a471 Correct some spaces in the type dump output. 2012-12-13 13:33:13 +09:00
Bill Currie cf05f65596 Add int_val and uint_val to @param and @zero.
I got fed up with using "int" types, but the members being "integer"
(hold-over from before the int rename).
Also, correct the names of those types and @va_list (error reporting was
chopping off part of the name).
2012-12-13 13:24:03 +09:00
Bill Currie 5681e0fd42 Treat certain move instructions as assignments.
MOVE (static move) and MOVEP to a pointer constant know exactly where their
data is going, so treat them similarly to assignments: save their
distination operands (the addressed def for MOVEP) and mark them as
defined.
2012-12-13 12:50:00 +09:00
Bill Currie c61e03a0b9 Clean up operand creation.
Rather than having the creation scattered through the code, use helper
functions. Makes exposing operand creating saner.
2012-12-13 12:49:00 +09:00
Bill Currie d990a956c0 More label count paranoia.
MOVEP can generate 4 daglabels.
2012-12-13 12:48:07 +09:00
Bill Currie c295a0473e Add edges from call nodes to their param nodes.
Assinments to .param_N (0-7 for call, 2-7 for rcall) must occur before the
call, or weird things will happen.
2012-12-13 09:55:28 +09:00
Bill Currie c477191488 Be a little more paranoid about daglabel counts.
I'm still a little worried about the number of labels needed with heavy
alias usage.
2012-12-13 09:50:18 +09:00
Bill Currie 204a0b3f72 Make def_visit_all return the actual result of visit.
This way, def_visit_all is a little more useful (though I think I might
redo the one case that's using this feature).
2012-12-13 09:47:00 +09:00
Bill Currie 028b19888f Check aliases for liveness when removing dead vars.
The live var flow analysis doesn't check for aliases. Rather than changing
it to check for aliases (which might break uninitialized var analysis, as
it uses "use" from the live var analysis), make dag_remove_dead_vars do the
check. Fixes the misplaced text in the menus.
2012-12-12 23:15:55 +09:00
Bill Currie 95c249e8b9 Scale the glsl crosshairs to match gl. 2012-12-12 22:34:49 +09:00
Bill Currie 2ce65d931e Use exact texture coords for 2d pics in glsl.
Moving the texture coordinates in 1/4 pixel made a mess of the 2d pics
(very noticable on the round crosshair).
2012-12-12 22:34:43 +09:00
Bill Currie cb259823af Scale the glsl crosshairs to match gl. 2012-12-12 21:37:55 +09:00
Bill Currie f71affdfba Use exact texture coords for 2d pics in glsl.
Moving the texture coordinates in 1/4 pixel made a mess of the 2d pics
(very noticable on the round crosshair).
2012-12-12 21:34:37 +09:00
Bill Currie a372efee5c Add a new crosshair.
Now all 4 slots of the crosshair table are used :)

Also, fix the offset for pic based crosshairs in glsl, and use just one
func for them.
2012-12-12 19:36:50 +09:00
Bill Currie 814f902e88 Add a new crosshair.
Now all 4 slots of the crosshair table are used :)

Also, fix the offset for pic based crosshairs in glsl, and use just one
func for them.
2012-12-12 19:36:18 +09:00
Bill Currie 06d14f6433 Dump operand contents for verbosity > 1. 2012-12-12 16:21:33 +09:00
Bill Currie 07d348fbd8 Fix an uninitialized warning from recent gcc.
Nifty: if you pass a struct via reference to a function, and a field of
that struct may be both set and not set (eg, set only in an if statement),
gcc will report that field assuming that fields that are never set will be
set by the function (my interpretation).

* taniwha ponders the flow analysis for that
2012-12-12 14:28:35 +09:00
Bill Currie 099bbcbd8a Fix an uninitialized warning from recent gcc.
Nifty: if you pass a struct via reference to a function, and a field of
that struct may be both set and not set (eg, set only in an if statement),
gcc will report that field assuming that fields that are never set will be
set by the function (my interpretation).

* taniwha ponders the flow analysis for that
2012-12-12 14:12:21 +09:00
Bill Currie dd03678a74 Ensure \n gets printed for the null type. 2012-12-12 13:44:22 +09:00
Bill Currie 48821f379f Set edges/live for addressed variables.
This fixes (again:P) the messup with .super.
2012-12-12 12:55:17 +09:00
Bill Currie 03fdbe9b86 Ensure the def is aliasing before adding edges.
Getting two nodes doubly connected for *to = *from++; was interesting.
2012-12-12 12:52:01 +09:00
Bill Currie 75be251d65 Create and use def_visit_all.
Even though it turned out there were only two copies of the def alias
handling code, I got tired of writing it. The code is easier to read, too
:)
2012-12-12 12:01:31 +09:00
Bill Currie 85e6dd965f Treat aliases of the same basic type as no-ops.
At the statement level, all pointer types are the same, so just return the
op obtained from the sub-expression when the low-level type of the alias
expression matches the low-level type of the type of type sub-expression
operand.

With this, the alias of a value code can be removed (I always thought it
was wrong), which is what broke calling obj_msgSend_super (type &.super
param lost the &).

Now I have to deal with pointer values in the optimizer :/
2012-12-11 20:44:40 +09:00
Bill Currie 76c9aa2930 Handle alias defs when building a dag.
When an alais def (or aliased def) is used, any overlapping aliases that
have previously been assigned need to be marked as live, and edges to the
aliases added to the new node. However, when assigned to, live-forcing
needs to be turned off.

This fixes the lost assignments to .super.
2012-12-11 19:57:19 +09:00
Bill Currie 045947706e Compare the base def spaces in def_overlap.
The space field in alias defs is always null and thus aliases would never
overlap the aliased def. Oops.
2012-12-11 19:51:34 +09:00
Bill Currie 998868e53c Maybe make dags a little easier to read. 2012-12-11 19:50:31 +09:00
Bill Currie 7607c7d649 Resurrect alias operands.
It turns out they are necessary for the code output from dags. This fixes
the ice for *to = *from++;
2012-12-11 15:52:37 +09:00
Bill Currie 8452f69a21 Use only the real temp for daglabels.
This fixes the bogus temps for "*to = *from++;", but qfcc ices due to the
operand types being lost. It seems alias operands need to be resurrected,
if only for code output by dags.
2012-12-11 15:20:52 +09:00
Bill Currie 50b0bd0b95 Use define from temp aliases as well to kill uninit defines.
Finally, the uninitialized temp warnings are fixed.
2012-12-11 13:04:06 +09:00
Bill Currie 5083679fcc Don't mask out the dummy defines from temp kills. 2012-12-11 12:58:16 +09:00
Bill Currie 6b4efaa3e4 Link temp aliases to their main def.
This fixes the kill sets not building properly.
2012-12-11 12:57:37 +09:00
Bill Currie 28c37b367d Fix the dummy definitions of temp vars.
I forgot to add func->num_statements :P. Fixes the weirdness where only
some alias temps were being (bogusly) detected as uninitialized. Now they
all are.
2012-12-11 12:27:23 +09:00
Bill Currie b5a72320bb Make alias defs and temps more obvious in dumps. 2012-12-11 12:26:48 +09:00
Bill Currie f358364ef2 Fix assignment of nil to a structure.
constfold.c seems to be getting a little long in the tooth :P
2012-12-11 11:53:01 +09:00
Bill Currie 8582e9de63 Make it possible to dump statement blocks in a flow graph.
Much nicer looking with proper back edges :). Not actually enabled, though.
2012-12-11 11:31:55 +09:00
Bill Currie cd62755ce4 Fix some warnings found by qfcc's flow analysis.
Ok, maybe it works too well? Nah, not really. It's nice having proper
unisnitialized checks on structs.
2012-12-10 22:20:44 +09:00
Bill Currie aeed16109f Add vecinit.r to the test-suite.
Ugh, I really need to take time out to do compile tests properly.
2012-12-10 21:09:53 +09:00
Bill Currie 3aa3a0945a Scan the statements in a node with suspect var usage.
When the naive uninitialized variable detection finds a node with possible
uses of uninitialized variables, the statements in the node are scanned one
at a time checking each usage and removing uninitialized definitions as
appropriate. vectest.r now compiles without warnings. As an added bonus,
accurate line number information is reported for uninitialized variables.

Unfortunately, there is still a problem with uninitialized temps in
switch.r, but that might just be poor handling of temp op aliases.
2012-12-10 20:49:08 +09:00
Bill Currie 426363cd0d Don't kill aliased definitions in the entry dummy block.
Only definitions for the def used in the current statement (whether an
alias or not) are suitable for killing. Doing otherwise defeats the purpose
of this work :P

Fixes the false negatives found in a modified quattest.r (commented out the
"tq.s = 0;" line).
2012-12-10 19:42:31 +09:00
Bill Currie aa97979d98 Rewrite flow_uninitialized() to use reaching defs.
Nicely, the use sets from live_variable analysis can be used too, though
there are some problems with the naive implementation. For:

vector foo (float x, float y, float z)
{
	vector v;
	v.x = x;
	v.y = y;
	v.z = z;
	return v;
}

qfcc thinks v is uninitialized, but if "if (x) return nil;" (or any other
basic-block splitter) is put just before the return v; qfcc correctly
detects that v is initialized. The reason is that the inits are in the same
basic block as the return, and thus aren't affecting the reaching
definitions, which are stored per-block.

The naive implementation should be good for a fast-cull before doing a
per-statement check.
2012-12-10 15:58:51 +09:00
Bill Currie c47cb697de Create dummy uses for global variables
The exit dummy block is setup to provide dummy uses of global variables to
the live variable analysis doesn't miss global variables. Much cleaner than
the previous code :) There may be some issues with aliases, though.
2012-12-10 15:27:07 +09:00
Bill Currie 2e105f17f2 Enable live var flow dumps. 2012-12-10 15:27:07 +09:00
Bill Currie d2f2fdc28e Create dummy definitions for local variables.
The entry dummy block is setup to provide dummy definitions of local
variables so the reaching definitions analysis can be used to detect
uninitialized variables (not implemented yet). Fake statement numbers
(func->num_statements + X) are used to represent the definitions. Local
variables (ie, not temp ops) use their offsets (ie, the offset range they
cover) for X. Temp ops use their flowvar number + the size of the
function's defspace for X. flow_kill_aliases() should take care of temp op
aliasing, while the use of the actual offsets spanned by the variable's def
should take care of any wild aliasing so structures and unions should
become a non-issue.
2012-12-10 15:26:47 +09:00