Commit graph

1355 commits

Author SHA1 Message Date
Richard McCormack
c8fc20b8ef Eliminate fully overlapping blits after coalescing stack slots
I noticed that my compiler was generating redundant blits, and after
looking through the QBE debug output I believe that I found some low
hanging fruit to help clean them up.

I'm new to this codebase, so please treat this patch with a lot of
skepticism. Happy to make any changes.

Thanks for reviewing, and thank you for QBE!
2024-04-03 22:12:36 +02:00
Michael Forney
85827e2232 check that data alignment is in range and a power of two
Otherwise, the alignment gets truncated to fit in char, so
`align 256` is handled as no alignment requirement.
2024-03-28 10:35:11 +01:00
Michael Forney
1b7770e271 Drop quotes around floating point constant labels
This is incompatible with binutils gas older than 2.26.
2024-03-26 09:22:06 +01:00
Nguyễn Gia Phong
be5d46fe7d test/fpcnv: skip of inexactly converted integers
In C, if a floating point cannot be represented exactly as an integer,
conversion from the former to the latter is implementation-defined.
Therefore, it can be flaky to test this against QBE-defined behavior.

This was discovered from (unsigned int) 4294967295.0f being an UB,
because (uint64_t) 4294967295.0f is 4294967296 > UINT_MAX
on amd64 when compiled by either gcc or clang.
2024-03-07 16:52:43 +01:00
Nguyễn Gia Phong
b582e84e10 remove duplicated function declarations
References: 12f9d16c7b ("create cfg.c for cfg-related functions")
2024-03-07 16:46:10 +01:00
Quentin Carbonneaux
9ee57a637a update copyright years 2024-03-07 16:45:22 +01:00
Nguyễn Gia Phong
190fd3fb09 declare check-rv64 as a phony make target
References: 4e93eeaa3b ("add rv64 backend")
2024-03-07 16:44:48 +01:00
Quentin Carbonneaux
bd7a73d0ea fix bug in alias analysis
The handling of phi was incorrect
and we would sometimes miss escapes.
We now handle phis at the very end
of the pass to make sure the defs
for their arguments have all been
processed.
2024-03-07 16:40:51 +01:00
Tobias Heider
2d683e0c53 Print total number of tests run to get a better view of how much is broken. 2024-01-29 10:24:41 +01:00
Quentin Carbonneaux
1f69842fb8 fix link in doc 2024-01-03 12:12:41 +01:00
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