summary refs log tree commit diff
AgeCommit message (Collapse)Author
2021-08-02copy: consider identity element for more instructionsMichael Forney
udiv %x, 1 == %x, and for each of sub, or, xor, sar, shr, and shl, <op> %x, 0 == %x.
2021-08-02gas: always emit GNU-stack noteÉrico Nogueira
In cases where stash was 0, gasemitfin exits immediately and the GNU-stack note isn't added to the asm output. This would result in an executable where GNU_STACK uses flags RWE instead of the desired RW.
2021-07-30err when an address contains a sum $a+$b (afl)Quentin Carbonneaux
Reported by Alessandro Mantovani. These addresses are likely bogus, but they triggered an unwarranted assertion failure. We now raise a civilized error.
2021-07-29load: handle all cases in cast()Michael Forney
Previously, all casts but d->w, d->s, l->s, s->d, w->d were supported. At least the first three can occur by storing to then loading from a slot, currently triggering an assertion failure. Though the other two might not be possible, they are easy enough to support as well. Fixes hare#360.
2021-07-28handle fast locals in amd64 shifts (afl)Quentin Carbonneaux
Reported by Alessandro Mantovani. Although unlikely in real programs it was found that using the address of a fast local in amd64 shifts triggers assertion failures. We now err when the shift count is given by an address; but we allow shifting an address.
2021-07-28fix buffer overflow in parser (afl)Quentin Carbonneaux
Reported by Alessandro Mantovani. Overly long function names would trigger out-of-bounds accesses.
2021-07-28fix amd64 addressing selection bug (afl)Quentin Carbonneaux
Reported by Alessandro Mantovani. Unlikely to be hit in practice because we don't add addresses to addresses. type :biggie = { l, l, l } function $repro(:biggie %p) { @start %x =l add %p, $a storew 42, %x ret }
2021-06-17amd64: fix conditional jump when compare is swapped and used elsewhereMichael Forney
selcmp may potentially swap the arguments and return 1 indicating that the opposite operation should be used. However, if the compare result is used for a conditional jump as well as elsewhere, the original compare op is used instead of the opposite. To fix this, add a check to see whether the opposite compare should be used, regardless of whether selcmp() is done now, or later on during sel(). Bug report and test case from Charlie Stanton.
2021-03-18spill: use stronger assertion for registers in use at start of functionMichael Forney
2021-03-18use toolchain to determine aarch64 sysroot pathMichael Forney
2021-03-18Revert "arm64: try qemu-system-aarch64"Michael Forney
This reverts commit be3a67a7f5079f30b0ccc696d549fd03a2dbbad1. qemu-system-aarch64 is a full system emulator and is not suitable for running the qbe test suite (at least without a kernel and root filesystem).
2021-03-12arm64: fix selcall call data for return of aggregate in memoryMichael Forney
The no-op `copy R0` is necessary in order to trigger dopm in spill.c and rega.c, which assume that a call is always followed by one or more copies from registers. However, the arm64 ABI does not actually return the caller-passed pointer as in x86_64. This causes an assertion failure qbe: aarch64: Assertion failed: r == T.rglob || b == fn->start (spill.c: spill: 470) for the following test program type :t = { l 3 } function $f() { @start.1 @start.2 %ret =:t call $g() ret } The assertion failure only triggers when the block containing the call is not the first block, because the check is skipped for the first block (since some registers may have been used for arguments). To fix this, set R0 in the call data so that spill/rega can see that this dummy "return" register was generated by the call. This matches qbe's existing behavior when the function returns void, another case where no register is used for the function result.
2021-03-12Arrange debug flag table to match pass orderMichael Forney
This makes it easier to determine which flag to pass to show the desired debug info.
2021-03-02disable pie for arm64 testsQuentin Carbonneaux
2021-03-02arm64: try qemu-system-aarch64Reini Urban
2021-03-02fix a couple asan complaintsQuentin Carbonneaux
2021-03-02renaming in gas.cQuentin Carbonneaux
2021-03-02add data $name = section "section" ...Drew DeVault
This allows you to explicitly specify the section to emit the data directive for, allowing for sections other than .data: for example, .bss or .init_array.
2021-03-02silence a gcc10 warningQuentin Carbonneaux
2021-03-02gas: emit GNU-stack note so that stack is not executableMichael Forney
GNU ld uses the presence of these notes to determine the flags of the final GNU_STACK program header. If they are present in every object, then the resulting executable's GNU_STACK uses flags RW instead of RWE. Reported by Érico Nogueira Rolim.
2021-03-02arm64: handle stack offsets >=4096 in OaddrMichael Forney
The immediate in the add instruction is only 12 bits. If the offset does not fit, we must move it into a register first.
2021-02-16docs/llvm: Fix typo jeoparadized -> jeopardizedThomas Bracht Laumann Jespersen
2020-10-05fold: zero-initialize padding bits of constantsMichael Forney
Otherwise, if a constant is stored as a float and retrieved as an int, the padding bits are uninitialized. This can result in the generation of invalid assembly: Error: suffix or operands invalid for `cvtsi2ss' Reported by Hiltjo Posthuma.
2020-08-06fix a typo in call's BNFQuentin Carbonneaux
Thanks to Jakob for pointing this out.
2020-08-06amd64: Use member class for aggregate parameter temporaryMichael Forney
Otherwise, we may end up using an integer and floating class for the same register, triggering an assertion failure: qbe: rega.c:215: pmrec: Assertion `KBASE(pm[i].cls) == KBASE(*k)' failed. Test case: type :T = { s } export function $d(:T %.1, s %.2) { @start call $c(s %.2) ret }
2020-08-06rega: Fix allocation of multiple temporaries to the same registerMichael Forney
2020-08-06arm64: Make sure SP stays aligned by 16Michael Forney
According to the ARMv8 overview document However if SP is used as the base register then the value of the stack pointer prior to adding any offset must be quadword (16 byte) aligned, or else a stack alignment exception will be generated. This manifests as a bus error on my system. To resolve this, just save registers two at a time with stp.
2020-08-06Move NPred in parse.c and decrease itMichael Forney
This now only limits the number of arguments when parsing the input SSA, which is usually a small fixed size (depending on the frontend).
2020-08-06Use a dynamic array for phi argumentsMichael Forney
2019-11-25copy: Fix use of compound literal outside its scopeMichael Forney
C99 6.5.2.5p6: > If the compound literal occurs outside the body of a function, > the object has static storage duration; otherwise, it has automatic > storage duration associated with the enclosing block. So, we can't use the address of a compound literal here. Instead, just set p to NULL, and make the loop conditional on p being non-NULL. Remarks from Quentin: I made a cosmetic change to Michael's original patch and merely pushed the literal at toplevel.
2019-07-11minic: fix undefined symbol linkage issueSergei V. Rogachev
The mandel example uses SDL2 for graphics output. When GCC is used to assemble the resulting *.s file it shows linker's errors about undefined symbols from the library. This behavior can be fixed by moving the flags passed to the compiler after the source file name.
2019-05-16Fix a few uses of gassym missed in 9e7e5bffMichael Forney
2019-05-15arm64: Handle stack allocations larger than 4095 bytesMichael Forney
In this case, the immediate is too large to use directly in the add/sub instructions, so move it into a temporary register first. Also, for clarity, rearrange the if-conditions so that they match the constraints of the instructions that immediately follow.
2019-05-15arm64: Handle truncd instructionMichael Forney
2019-05-15arm64: Use 32-bit register name when loading 'b' or 'h' into 'l'Michael Forney
The ldrb and ldrh instructions require a 32-bit register name for the destination and will clear the upper 32-bits of that register.
2019-05-15Allow specifying literal global namesMichael Forney
2019-05-14drop dead declarationQuentin Carbonneaux
2019-05-14fix a bad bug in copy detectionQuentin Carbonneaux
The code used to see add 0, 10 as a copy of 0.
2019-05-05add asm diffing in test scriptQuentin Carbonneaux
2019-05-05fuse epilog deduplication with jump threadingQuentin Carbonneaux
2019-05-05revert last commitQuentin Carbonneaux
The same functionality can be implemented naturally in the cfg simplification pass.
2019-05-04emit only one epilog per functionQuentin Carbonneaux
Previously, each ret would lead to an epilog. This caused bloat for large functions with multiple return points.
2019-05-03gas: use .balign instead of .alignQuentin Carbonneaux
.align N can either mean align to the next multiple of N or align to the next multiple of 1<<N. Credit goes to Jorge Acereda Maciá for reporting this issue.
2019-05-02move fillloop() after fold()Quentin Carbonneaux
SCCP is currently the one and only pass which seriously affects control flow; so we must compute loop costs afterwards.
2019-05-02detect ubiquitous simple copiesQuentin Carbonneaux
When lowering pointer arithmetic, it is natural for a C frontend to generate those instructions.
2019-05-02revert heuristic to reuse stack slotsQuentin Carbonneaux
The heuristic was bogus for at least two reasons (see below), and, looking at some generated code, it looks like some other issues are more pressing. 1. A stack slot of 4 bytes could be used for a temporary of 8 bytes. 2. Should 2 arguments of an operation end up spilled, the same slot could be allocated to both!
2019-04-30isel fix for amd64 memory storesQuentin Carbonneaux
The value argument of store instructions was handled incorrectly.
2019-04-29fix folding of unsigned operationsQuentin Carbonneaux
This fixes similar bugs than the ones fixed in the previous commit. In the folding code the invariant is that when a result is 32 bits wide, the low 32 bits of 'x' are correct. The high bits can be anything.
2019-04-29fold: Make sure 32-bit constants get sign extended when necessaryMichael Forney
2019-04-29amd64: Use unordered compare for floating pointsMichael Forney
This prevents an FE_INVALID exception when comparing with NaN.