[clang] [llvm] [BPF] introduce __attribute__((bpf_fastcall)) (PR #105417)

via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 20 17:25:37 PDT 2024


eddyz87 wrote:

Hi @AaronBallman, @yonghong-song,

This is a second try for `bpf_fastcall`, I had to revert the previous attempt in #101228 because of the "expensive tests" build bot failure for the main branch. The fix for the failure is in the second commit of this branch (I did not squash it to allow for review), copy the reasoning below.

Two kinds of errors are detected when LLVM is compiled with expensive checks:

    *** Bad machine code: Extra explicit operand on non-variadic instruction ***
    - function:    foo1
    - basic block: %bb.0 entry (0x2c53bbd8)
    - instruction: LDD $r3, $r10, -24, 0
    - operand 3:   0

    *** Bad machine code: Explicit definition marked as use ***
    - function:    foo1
    - basic block: %bb.0 entry (0x2c53bbd8)
    - instruction: LDD $r2, $r10, -16, 0
    - operand 0:   $r2

Both kinds of errors are reported for STD/LDD instructions inserted by `BPFMIPreEmitPeephole::insertMissingCallerSavedSpills()` pass:
- first is caused by an extra operand passed to BuildMI;
- second is caused by absence of `RegState` flag for destination register.

```
    BuildMI(BB, Call.MI->getIterator(), Call.MI->getDebugLoc(),
            TII->get(BPF::STD))
        .addReg(Reg)        // <---- need RegState::Define here
        .addReg(BPF::R10)
        .addImm(CurOffset)
        .addImm(0);         // <---- not needed
```

Please take a look, sorry for not getting this right for the first time.

https://github.com/llvm/llvm-project/pull/105417


More information about the cfe-commits mailing list