~koskanaiken

Recent activity

Re: [PATCH] Revert "revert 5af33410" 7 months ago

From Chenguang Wang to ~mpu/qbe

I don't think so:

    qbe $ ./qbe test/tls.ssa | tail -n17
    
    .text
    xvalcnt:
            .cfi_startproc
            pushq %rbp
            movq %rsp, %rbp
            movq %fs:0, %rax
            leaq x@tpoff(%rax), %rax
            movl (%rax, %rdi, 4), %eax
            leave
            ret

[PATCH] Revert "revert 5af33410" 7 months ago

From Chenguang Wang to ~mpu/qbe

This reverts commit 4bc4c9584a13736c20855cdea2203d3bd0a259a3.

We can re-enable BTI now, since the stock `as` in OpenBSD 7.5 seems to
support it:

    qbe $ ./qbe test/tls.ssa > /tmp/tls.s
    qbe $ grep endbr64 /tmp/tls.s | uniq -c
       6    endbr64
    qbe $ as /tmp/tls.s -o /tmp/tls.o
    qbe $ ls -al /tmp/tls.o
    -rw-r--r--  1 w  wheel  2312 Apr 19 06:57 /tmp/tls.o

isel4.ssa and tls.ssa currently fail with SIGILL on my machine. This
commit fixes that.
[message trimmed]

[PATCH] Add missing testmod::s_a allocation 10 months ago

From Chenguang Wang to ~sircmpwn/hare-dev

In testmod/testmod.ha, s_x/s_a was defined as a prototype [1]:

    export let @symbol("s_x") s_a: int;

But tests/34-declarations.ha uses it [2]:

    fn imported() void = {
        testmod::s_a;
    }

This currently works on QBE because QBE recognizes the `loadsw $s_x`
return value is never used, and eliminates the expression, but in
fact $s_x is never defined anywhere in the final linked binary
tests_34_declarations.
[message trimmed]

Re: [PATCH] Fix sprintf() and strcpy() warnings on OpenBSD. 11 months ago

From Chenguang Wang to ~mpu/qbe

Fair points. Just for the record...

1. `-Wsizeof-pointer-memaccess` catches `sizeof` misuses on pointer
types, but it only works on gcc; the clang version doesn't detect this:

    $ cat t.c
    #include <stdio.h>
    int main(void) {
        char *p = 0;
        char buf[42];
        snprintf(p, sizeof p, "hi");
        snprintf(buf, sizeof buf, "hi");
    }

Re: Control-flow integrity overhead 11 months ago

From Chenguang Wang to ~mpu/qbe

Hi,

This is irrelevant to code size or runtime overhead, but I do
wish this feature could be controlled behind a flag, because
on OpenBSD the default binutils shipped with system is 2.17,
which does not seem to support `endbr64`. I had to 1) run
`pkg_add binutils` and 2) configure my copy of cproc using
`--with-as=gas` to make it work as expected. It would be great
if QBE could remove non-stock binutils as a hard dependency on
OpenBSD.

On Sat, Dec 30, 2023, at 7:19 AM, Quentin Carbonneaux wrote:
> Hi all,
>

[PATCH] Add missing documentation for union types and VAL. 11 months ago

From Chenguang Wang to ~mpu/qbe

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
---
 doc/il.txt | 30 ++++++++++++++++++++++++++++--
 1 file changed, 28 insertions(+), 2 deletions(-)

diff --git a/doc/il.txt b/doc/il.txt
index cc3e021..b036273 100644
--- a/doc/il.txt
+++ b/doc/il.txt
@@ -15,7 +15,7 @@
  2. <@ Types >
[message trimmed]

[PATCH] Fix sprintf() and strcpy() warnings on OpenBSD. 11 months ago

From Chenguang Wang to ~mpu/qbe

When compiling on OpenBSD, the compiler produces warning messages about the
usage of these two functions, and suggests replacing them with snprintf() and
strlcpy().

strlcpy() on Linux requires including bsd/string.h and linking libbsd. I found
it easier to just use equivalent snprintf() calls instead.
---
 amd64/emit.c  |  2 +-
 amd64/isel.c  |  2 +-
 arm64/emit.c  | 10 +++++-----
 arm64/isel.c  |  2 +-
 minic/minic.y | 21 +++++++++++----------
 minic/yacc.c  | 24 ++++++++++++------------
 parse.c       |  8 ++++----
[message trimmed]

Re: Spec clarifications 1 year, 1 month ago

From Chenguang Wang to ~mpu/qbe

> VAL could also be $IDENT, e.g. in function calls:

My apologies -- apparently $IDENT is CONST already.

Re: Spec clarifications 1 year, 1 month ago

From Chenguang Wang to ~mpu/qbe

Just found this thread while writing my own QBE parser.

> > 2. I haven't found the definition of VAL, is it true that
> > VAL := DYNCONST | %IDENT
> 
> 
> Yes that's a valid definition I believe. VAL is what the
> parseref() function parses.
> 
> See https://c9x.me/git/qbe.git/tree/parse.c#n402

VAL could also be $IDENT, e.g. in function calls:

// CALL := [%IDENT '=' ABITY] 'call' VAL '(' (ARG), ')'