Commit Graph

302 Commits

Author SHA1 Message Date
Pierre Muller
5e6e24ec08 Rename fields of tspillregsinfo record to avoid having same field names as treginfo record 2023-09-26 18:18:04 +00:00
Pierre Muller
b49c3fe4f8 Aslo check that live_end is assigned before refering to it 2023-02-13 15:50:04 +01:00
Jinyang He
96f4300158 Fix the edge of first_imaginary in move op 2023-02-05 19:18:48 +00:00
Jonas Maebe
a835d8b533 rgobj: reduce compilation time of programs with long movelists
Reduces compilation time of webtbs/tw2242 for AArch64 with -O2 from
15 minutes to 10 seconds on my system.

from 15 minutes to 10 seconds
2022-10-12 22:58:18 +02:00
florian
4f9c19d943 * simplifications by Rika (*2 loops => shl/Bsr), resolves 2022-05-12 22:56:36 +02:00
Yuriy Sydorov
e9acd759a4 * Fixed random AVs when targeting the AVX FPU. 2021-12-12 18:19:35 +02:00
Yuriy Sydorov
4f711a8b2c * Use longint for Tmoveins.id instead of word to prevent overflow in extreme cases. 2021-11-28 01:02:20 +02:00
Yuriy Sydorov
5c55f1a16e * Added Tmoveins.id to be used for sorting and searching in Tmovelist, to
produce the consistent order of elements.
  This fixes occasional differences in the register allocation caused by
  the address space randomization. When ASLR is in effect, the previous
  approach to sort elements by their memory addresses can't guarantee the
  consistent elements order for each compilation of the same source code.
2021-11-27 19:44:50 +02:00
Yuriy Sydorov
8e5c2467e2 * Fixed node coalescing with real registers. 2021-11-06 21:47:28 +02:00
Yuriy Sydorov
7e4753bebd * Typo fixed. 2021-11-02 20:36:30 +02:00
Yuriy Sydorov
d0cc649428 * Write interference graphs to the unit output directory. 2021-11-02 16:46:09 +02:00
Yuriy Sydorov
c4a1cdceae * Corrected calculation of spilling efficiency. 2021-11-02 16:46:08 +02:00
Yuriy Sydorov
c9d9d42f0e * Better coalescing with real registers. This improves setting of parameters
in registers.
* Removed superfluous condition in trgobj.enable_moves().
* Fixed flags checking in trgobj.adjacent_ok().
* Added assembler comments about coalescing when DEBUG_SPILLCOALESCE is defined.
2021-11-02 16:46:08 +02:00
Yuriy Sydorov
b4df9dbe1d * Prevent spilling of spill-helper registers which contain the value of a
previously spilled register. These helper registers must never be spilled.
  This fixes failures of the register allocator in rare corner cases.
2021-09-10 18:06:12 +03:00
Yuriy Sydorov
61cf121533 * Use a register alias while handling reg deallocs in trgobj.instr_spill_register()
to be in sync with commit b96057ad.
2021-09-09 16:58:16 +03:00
Yuriy Sydorov
b43ee41090 * If in a move instruction "MOV reg1,reg2" one of the registers must be
spilled, but reg1 and reg2 are coalesced, then this is a no-op
  instruction and no spilling is needed.
2021-09-06 18:57:41 +03:00
Yuriy Sydorov
213a0a704a * Added trgobj.remove_ai(), call it instead of code duplication.
No functional changes.
2021-09-06 18:49:33 +03:00
Yuriy Sydorov
b96057adeb * Remove register allocations of coalesced registers if the alias
register is spilled.
2021-09-06 18:37:45 +03:00
florian
837b433abc * avoid overflow during register allocation
git-svn-id: trunk@49285 -
2021-04-28 18:32:48 +00:00
yury
6975437da8 * rgobj: ungetiftemp can't be used here since it frees only temps of the tt_normal type.
git-svn-id: trunk@48407 -
2021-01-24 17:53:42 +00:00
yury
4fa99cff62 * Removed more assigned but unused vars.
git-svn-id: trunk@48392 -
2021-01-24 14:05:21 +00:00
yury
31cd3df783 * Fixed r44145. To test if a constant is declared it is needed to use {$if declared()} instead of {$if defined()}.
git-svn-id: trunk@48389 -
2021-01-24 13:32:11 +00:00
florian
637976e83f * patch by Marģers to unify internal error numbers, resolves
git-svn-id: trunk@47103 -
2020-10-13 19:59:01 +00:00
yury
2f21f5ae93 * Reverted r46836, since it does not work as expected for yet unknown reason.
git-svn-id: trunk@46856 -
2020-09-12 10:13:00 +00:00
yury
b5abefe03e * Moved spilling of registers which have the initial memory location and are used only once to a stage after coalescing is done. This produces a better code.
git-svn-id: trunk@46836 -
2020-09-11 13:32:18 +00:00
yury
c06744b62b * Include stack location of spilled variables in the assembler output.
git-svn-id: trunk@46835 -
2020-09-11 12:36:31 +00:00
yury
60c23daa91 * Fixed the stack parameters optimization (r46776) for big endian CPUs.
git-svn-id: trunk@46794 -
2020-09-07 12:54:20 +00:00
yury
71fcb74e95 * Fixed r46776: With -O3 do not "coalesce" spilled nodes if the initial location is set.
git-svn-id: trunk@46777 -
2020-09-05 18:39:09 +00:00
yury
c2dc342c55 * Use the initial location of stack parameters as a spilling location if spilling is needed. This leads to the following optimizations:
- no spill temp is allocated;
  - no load of a stack parameter to a spill temp;
  - if a stack parameter is used only once do not preload it to a register. The parameter can be accessed directly in the stack if the target CPU supports this.

git-svn-id: trunk@46776 -
2020-09-05 18:20:18 +00:00
yury
acef1e22d3 * Improved output of spilling statistics:
- Do not use count_uses, since weight already represents a usage count of a register.
  - Do not count spills of registers with weight less than 100.

git-svn-id: trunk@46775 -
2020-09-05 16:06:41 +00:00
yury
d9db680937 * In assembly comments include all used registers by a variable for 8/16 bit CPUs.
* Do not add comments about unused varlocs.

git-svn-id: trunk@46296 -
2020-08-06 17:57:30 +00:00
Jonas Maebe
3047ce71bc * fixed LLVM register allocator after r46199
git-svn-id: trunk@46212 -
2020-08-03 20:36:02 +00:00
yury
ff820247c3 * Early during register allocation, spill registers which interfere with all usable real registers.
It is pointless to keep them for further processing. Also it may
  cause endless spilling.
  This can happen when compiling for very constrained CPUs such as
  i8086 where indexed memory access instructions allow only
  few registers as arguments and additionally the calling convention
  provides no general purpose volatile registers.

git-svn-id: trunk@46199 -
2020-08-03 16:46:25 +00:00
yury
601e05f17f * Count only usable real registers.
git-svn-id: trunk@46197 -
2020-08-03 16:24:14 +00:00
yury
0daba07246 * Enhanced the debug output of spilling statistics. Now it includes efficiency of the spilling which is based on
weight and usage count of registers. Range 0-100%. Such statistics are very handy when you modify the register allocator.
  

git-svn-id: trunk@46196 -
2020-08-03 16:18:32 +00:00
yury
4964f5cf76 * Count the number of interferences with real registers.
* Do not coalesce registers 'u' and 'v' if 'u' is the last usable real register available for imaginary register 'n' which also interferences with 'v'.
    This prevents endless spilling in some cases for constrained CPUs such as AVR. Resolves issue .
    Also this reduces the number of spilled registers in some cases and even eliminates spilling completely for some simple routines for i386 and AVR.
* Added a debug output of the number of spilled registers for each routine. This allows to easily compare results after changes in spilling algorithms.

git-svn-id: trunk@45987 -
2020-08-02 11:50:43 +00:00
yury
e6b89c98f5 * Changed tsuperregisterworklist.get() to always return the last item from the list.
* Reversed sort order of simplifyworklist so nodes with most interferences will get their colors first.
    Since degree of nodes in simplifyworklist before sorting is always
    less than the number of usable registers this should not trigger spilling
    and should lead to a better register allocation in some cases.

  After these changes sysutils.o for i386-win32 is 80 bytes less. :)

git-svn-id: trunk@45857 -
2020-07-25 18:29:59 +00:00
yury
c455e942e5 * Try to avoid spilling of an imm register if it contains a value loaded from an already spilled imm register. It likely leads to an endless loop and the register allocation fails.
This fixes the register allocation for i8086 when handling registers for very constrained instructions such as "mov ireg1,[ireg2+ireg3]". 
    Here ireg2 can be only BX or BP. So in most cases only BX is available. When ireg2 is spilled, its value must be loaded to BX only.
    Coloring of the ireg which holds the spilled value must be as early as possible to be able to assign BX to this ireg.
    This fix should also help register allocation for other constrained/old CPUs.

git-svn-id: trunk@45843 -
2020-07-24 14:08:18 +00:00
yury
15f411a332 * Improved r45832.
git-svn-id: trunk@45833 -
2020-07-23 12:52:17 +00:00
yury
80facfa0bf * Fixed indentations of the interference graph.
* Added register names to the interference graph.

git-svn-id: trunk@45832 -
2020-07-23 12:45:40 +00:00
pierre
40a6059143 Modify code to avoid error when compiling with -CriotR option
git-svn-id: trunk@44145 -
2020-02-10 09:37:53 +00:00
florian
96a4cda03b * AVR: fixes pushing and handling of stack passed parameters
git-svn-id: trunk@43983 -
2020-01-19 15:55:21 +00:00
florian
c6659d62f8 * do not join register deallocations/allocations as it makes no use and causes later on trouble in
the assembler optimizer as register allocations are not correct, resolves 

git-svn-id: trunk@43384 -
2019-11-03 17:13:59 +00:00
Jonas Maebe
281b3ad276 * fix case completeness and unreachable code warnings in compiler that would
be introduced by the next commit

git-svn-id: trunk@42046 -
2019-05-12 14:29:03 +00:00
yury
a277a5f8db * Removed unused local vars.
git-svn-id: trunk@41457 -
2019-02-25 11:22:49 +00:00
florian
ccb8e86560 * fixes arm
git-svn-id: trunk@40350 -
2018-11-18 14:16:20 +00:00
florian
9d56387e7f + new spilling heuristics which takes care of the usage weigth of a register,
not yet activated, can be selected by passing SPILLING_NEW when compiling the compiler

git-svn-id: trunk@40346 -
2018-11-18 10:11:13 +00:00
yury
4357caaad8 * Removed unused local vars.
git-svn-id: trunk@40183 -
2018-11-02 18:44:29 +00:00
florian
ea32ddd5b2 * avoid overflows of execution weight
git-svn-id: trunk@39623 -
2018-08-16 20:45:36 +00:00
florian
37a5716819 * reuse more sparc code for sparc64
git-svn-id: trunk@36961 -
2017-08-20 17:20:43 +00:00