terralang / terra

Terra is a low-level system programming language that is embedded in and meta-programmed by the Lua programming language.
terralang.org
Other
2.71k stars 197 forks source link

Only include formal parameters in function for varargs call #602

Closed elliottslaughter closed 2 years ago

elliottslaughter commented 2 years ago

Potential fix for macOS on M1: https://github.com/terralang/terra/issues/597#issuecomment-1221319348.

shoe42 commented 2 years ago

Looks like this substantially improves the test pass rate on macOS M1 (macOS 12.5, system clang, Homebrew LLVM 13):

99% tests passed, 3 tests failed out of 550

Total Test time (real) =  16.54 sec

The following tests FAILED:
     27 - atomicrmw.t (Subprocess aborted)
     61 - cconv_array.t (Failed)
    534 - vararg.t (Subprocess aborted)

vararg.t still fails with Assertion failed: (Ty && "Invalid GetElementPtrInst indices for type!"), function checkGEPType, file Instructions.h, line 921., however bug372*.t seem to now pass.

shoe42 commented 2 years ago

Looks like arguments are now being passed properly with the bug372 minimal address printing example:

0000000100003ec4 <_main>:
100003ec4: f4 4f be a9  stp x20, x19, [sp, #-32]!
100003ec8: fd 7b 01 a9  stp x29, x30, [sp, #16]
100003ecc: ff 43 0d d1  sub sp, sp, #848
100003ed0: c0 02 00 10  adr x0, #88
100003ed4: f3 23 00 91  add x19, sp, #8
100003ed8: 1f 20 03 d5  nop
100003edc: f3 03 00 f9  str x19, [sp]
100003ee0: 0f 00 00 94  bl  0x100003f1c <_printf+0x100003f1c>
100003ee4: e0 02 00 50  adr x0, #94
100003ee8: 68 e2 08 91  add x8, x19, #568
100003eec: 1f 20 03 d5  nop
100003ef0: e8 03 00 f9  str x8, [sp]
100003ef4: 0a 00 00 94  bl  0x100003f1c <_printf+0x100003f1c>
100003ef8: 20 03 00 10  adr x0, #100
100003efc: 68 02 7e b2  orr x8, x19, #0x4
100003f00: 1f 20 03 d5  nop
100003f04: e8 03 00 f9  str x8, [sp]
100003f08: 05 00 00 94  bl  0x100003f1c <_printf+0x100003f1c>
100003f0c: ff 43 0d 91  add sp, sp, #848
100003f10: fd 7b 41 a9  ldp x29, x30, [sp, #16]
100003f14: f4 4f c2 a8  ldp x20, x19, [sp], #32
100003f18: c0 03 5f d6  ret
elliottslaughter commented 2 years ago

Nice! Maybe we could split out the remaining three test failures into separate issues? For the vararg.t, it might help to get a backtrace (remember to build Terra in debug mode).

shoe42 commented 2 years ago

Done - issues #603, #604 and #605.