Commit graph

1395 commits

Author SHA1 Message Date
Drew DeVault
85287081c4 dbgloc: add column argument
dbgloc line [col]

This is implemented in a backwards-compatible manner.
2024-01-02 12:12:05 +01:00
Chenguang Wang
24d68e841f Add missing documentation for union types and VAL.
See previous discussion here[1]. It's unclear to me how to preview HTML page
generated from the .txt file, though.

[1]: https://lists.sr.ht/~mpu/qbe/%3C87cz1jq26k.fsf%40greenfork.me%3E
2024-01-02 11:51:34 +01:00
Quentin Carbonneaux
4bc4c9584a revert 5af33410
Causes errors with stock toolchain
on OpenBSD.
2024-01-02 11:16:08 +01:00
Tobias Heider
5af33410f6 Fix IBT/BTI by instrumenting function calls 2023-12-30 15:59:25 +01:00
Lorenz (xha)
00501eeb6e hard-code $(CC) to equal "cc"
this fixes the build on FreeBSD, where the value of $(CC) recently
changed from "cc" (13.2) to "c99" (14).

Signed-off-by: Lorenz (xha) <me@xha.li>
2023-12-30 15:50:35 +01:00
Josiah Frentsos
d023bdaa6b Fix architecture detection on OpenBSD/arm64 2023-09-25 09:49:35 +02:00
Quentin Carbonneaux
c5aca682a2 comments in amd64 isel 2023-08-28 22:45:41 +02:00
Michael Forney
d6c9669c3c Fix conversion from float/double to unsigned int
signed int can't represent all the values of unsigned int, so we
need to do the conversion to signed long, and use the lower 32 bits
as the result.
2023-08-26 15:16:45 +02:00
Quentin Carbonneaux
d41d91ddd8 test.sh fixes for devuan linux 2023-08-18 17:21:48 +02:00
Quentin Carbonneaux
36946a5142 file,loc become dbgfile,dbgloc 2023-08-18 15:12:56 +02:00
Quentin Carbonneaux
baf11b7175 parseline() tweaks 2023-06-07 10:11:58 +02:00
Thomas Bracht Laumann Jespersen
0d929287d7 implement line number info tracking
Support "file" and "loc" directives. "file" takes a string (a file name)
assigns it a number, sets the current file to that number and records
the string for later. "loc" takes a single number and outputs location
information with a reference to the current file.
2023-06-06 18:44:51 +02:00
Alexey Yerin
e493a7f233 Bump NString 2023-05-31 09:25:58 +02:00
Quentin Carbonneaux
50452b88e9 fix sub-word returns on arm64_apple 2023-05-09 12:39:51 +02:00
Locria Cyber
96f16f958a Fix 1 C UB 2023-04-03 16:08:46 +02:00
Quentin Carbonneaux
a3dfbb9c04 amd64_apple: one more thread-local symbols fix
We now treat thread-local
symbols in Mems properly.
2023-04-02 19:21:16 +02:00
Quentin Carbonneaux
eda2db5737 tests for thread-local addresses 2023-04-02 18:54:26 +02:00
Quentin Carbonneaux
1ec70daee6 amd64_apple: support thread-local addresses
Non-store/load instructions were
not lowered correctly for thread-
local symbols. This is an attempt
at a fix (cannot test for now).
2023-04-02 16:51:49 +02:00
Quentin Carbonneaux
56f4b5be4c amd64_sysv: fix offsets in thread-local Oaddr 2023-04-02 15:48:48 +02:00
Quentin Carbonneaux
28d9ca8eae print prefix for thread-local symbols 2023-04-02 15:20:16 +02:00
Quentin Carbonneaux
a9d3e06a57 amd64_sysv: thread-local support in Oaddr
Thanks to Lassi Pulkkinen for
flagging the issue and pointing
me to Ulrich Drepper's extensive
doc [1].

[1] https://people.redhat.com/drepper/tls.pdf
2023-04-02 14:48:52 +02:00
Quentin Carbonneaux
5fee3da6ac rename blknew() to newblk()
This is consistent with newtmp()
and newcon().
2023-03-22 11:43:46 +01:00
Quentin Carbonneaux
eb9fcece9e naming nit 2023-03-19 07:38:24 +01:00
Quentin Carbonneaux
011dfc839d silence format warning more reliably 2023-03-16 16:22:11 +01:00
Quentin Carbonneaux
6f45894c7f silence some warnings 2023-03-15 22:07:18 +01:00
Quentin Carbonneaux
498af259eb fix memory leak 2023-03-13 11:00:07 +01:00
Quentin Carbonneaux
f51aba22e0 refresh stale Tmp.link before use
During coalescing, the resizing/
reordering of the sl[] array
invalidates the indices stored
in the 'visit' field of temps;
we need to reset it before we
can use it again.
2023-03-13 10:51:41 +01:00
Alexey Yerin
7410f90629 Emit .type and .size directives on RISC-V and ARM
To match x86
2023-03-11 21:56:45 +01:00
Quentin Carbonneaux
9632f2f148 kill dead stores when coalescing slots
This is necessary because, post
fusion, dead stores may clobber
data.  A new test case exposes
one such situation.
2023-03-11 21:51:10 +01:00
Quentin Carbonneaux
f1b21d145b reorder some sections in doc 2023-01-09 14:05:06 +01:00
Quentin Carbonneaux
0956b11331 ready for this jelly 2022-12-27 18:14:01 +01:00
Quentin Carbonneaux
a6cd65d498 link pthread in tests 2022-12-25 16:38:46 +01:00
Quentin Carbonneaux
5e9726946d new UNDEF Ref
Crashing loads of uninitialized memory
proved to be a problem when implementing
unions using qbe.  This patch introduces
a new UNDEF Ref to represent data that is
known to be uninitialized.  Optimization
passes can make use of it to eliminate
some code.  In the last compilation stages,
UNDEF is treated as the constant 0xdeaddead.
2022-12-25 16:37:33 +01:00
Quentin Carbonneaux
c5cd65261e update documentation 2022-12-16 16:56:40 +01:00
Quentin Carbonneaux
99fea1e211 bugfix in load elimination
When checking if two slices represent
the same range of memory we must check
that offsets match.

The bug was revealed by a harec test.
2022-12-15 09:30:47 +01:00
Quentin Carbonneaux
26c1c30b7d new blit instruction 2022-12-14 23:18:26 +01:00
Quentin Carbonneaux
15e25a61b3 fix coalesce() to produce valid ssa
When multiple stack slots are coalesced
one 'alloc' instruction is kept in the il
and the other ones are removed and have
their uses replaced by the result of the
selected one. To produce valid ssa, it
must be ensured that the uses that get
replaced are dominated by the selected
'alloc' instruction. This patch ensures
dominance by moving the selected alloc up
in the start block as necessary.
2022-12-14 23:05:35 +01:00
Quentin Carbonneaux
c5ea06c136 treat retc as non-escaping
We may well treat all rets as
non-escaping since stack slots
are destroyed upon funcion
return.
2022-12-12 22:36:34 +01:00
Quentin Carbonneaux
c0f25aeae3 new rsval() helper for signed Refs
The .val field is signed in RSlot.
Add a new dedicated function to
fetch it as a signed int.
2022-12-12 22:16:33 +01:00
Quentin Carbonneaux
2ec355df6a crash loads from uninitialized slots 2022-12-12 17:42:08 +01:00
Quentin Carbonneaux
7ee9970b32 renamings in coalesce() 2022-12-12 16:51:37 +01:00
Quentin Carbonneaux
d79b2aecbf zero msbs of 32-bit constants
Some noisy assemblers complain
when asked to do it themselves.
2022-12-12 13:57:28 +01:00
Quentin Carbonneaux
9126afa2da new hlt block terminator
It is handy to express when
the end of a block cannot be
reached. If a hlt terminator
is executed, it traps the
program.

We don't go the llvm way and
specify execution semantics as
undefined behavior.
2022-11-27 21:48:21 +01:00
Quentin Carbonneaux
b5da3f3d64 cosmetics in mem.c 2022-11-24 10:32:13 +01:00
Quentin Carbonneaux
cbee74bdb4 use a new struct for symbols
Symbols are a useful abstraction
that occurs in both Con and Alias.
In this patch they get their own
struct. This new struct packages
a symbol name and a type; the type
tells us where the symbol name
must be interpreted (currently, in
gobal memory or in thread-local
storage).

The refactor fixed a bug in
addcon(), proving the value of
packaging symbol names with their
type.
2022-11-22 21:56:21 +01:00
Quentin Carbonneaux
04e2640901 rename Tmp.ins to be more descriptive 2022-11-22 21:55:06 +01:00
Quentin Carbonneaux
87dc3ea290 fix allocation ordering bug in rega
When we process one block, we
start by allocating registers
for all the temporaries live
at the exit of the block.

Before this patch we processed
temps first, then in doblk() we
would mark globally live registers
allocated. This meant that temps
could get wrongly assigned a live
register.

The fix is simple: we now process
registers first at block exits,
then allocate temps.
2022-11-21 14:16:19 +01:00
Quentin Carbonneaux
0db06dad63 recognize some phis as copies
The copy elimination pass is not
complete. This patch improves
things a bit, but I think we still
have quite a bit of incompleteness.

We now consistently mark phis with
all arguments identical as copies.
Previously, they were inconsistently
eliminated by phisimpl(). An example
where they were not eliminated is
the following:

    @blk2
        %a = phi @blk0 %x, @blk1 %x
	jnz ?, @blk3, @blk4
    @blk3
        %b = copy %x
    @blk4
        %c = phi @blk2 %a, @blk3 %b

In this example, neither %c nor %a
were marked as copies of %x because,
when phisimpl() is called, the copy
information for %b is not available.

The incompleteness is still present
and can be observed by modifying
the example above so that %a takes
a copy of %x through a back-edge.
Then, phisimpl()'s lack of copy
information about %b will prevent
optimization.
2022-11-21 11:53:00 +01:00
Quentin Carbonneaux
674901b718 new slot coalescing pass
This pass limits stack usage when
many small aggregates are allocated
on the stack. A fast liveness
analysis figures out which slots
interfere and the pass then fuses
slots that do not interfere. The
pass also kills stack slots that
are only ever assigned.

On the hare stdlib test suite, this
fusion pass managed to reduce the
total eligible slot bytes count
by 84%.

The slots considered for fusion
must not escape and not exceed
64 bytes in size.
2022-11-20 22:14:41 +01:00
Quentin Carbonneaux
f5007126f3 export getalias()
We will be using it in the new
coalesce() pass.
2022-11-20 22:13:44 +01:00