-
Notifications
You must be signed in to change notification settings - Fork 14.3k
[BPF] fix sub-register handling for bpf_fastcall #110618
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
✅ With the latest revision this PR passed the C/C++ code formatter. |
This issue was causing Linux kernel BPF selftest failure: arena_htab/arena_htab_asm execution log
Here register |
bpf_fastcall induced spill/fill pairs should be generated for sub-register as well as for sub-registers. At the moment this is not the case, e.g.: $ cat t.c extern int foo(void) __attribute__((bpf_fastcall)); int bar(int a) { foo(); return a; } $ clang --target=bpf -mcpu=v3 -O2 -S t.c -o - ... call foo w0 = w1 exit Modify BPFMIPeephole.cpp:collectBPFFastCalls() to check sub-registers liveness and thus produce correct code for example above: *(u64 *)(r10 - 8) = r1 call foo r1 = *(u64 *)(r10 - 8) w0 = w1 exit
8a11bee
to
407143c
Compare
As pointed by @4ast, there is no need to do two calls to `IsLiveBeforeInsn`, LivePhysRegs::contains() is documented as follows: /// ... This also /// works if only the super register of \p Reg has been defined, because /// addReg() always adds all sub-registers to the set as well ...
No changes in behaviour, just makes the code more terse.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Thank you, I'll wait for comments from Yonghong and land after that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Thanks!
bpf_fastcall induced spill/fill pairs should be generated for sub-register as well as for sub-registers. At the moment this is not the case, e.g.: $ cat t.c extern int foo(void) __attribute__((bpf_fastcall)); int bar(int a) { foo(); return a; } $ clang --target=bpf -mcpu=v3 -O2 -S t.c -o - ... call foo w0 = w1 exit Modify BPFMIPeephole.cpp:collectBPFFastCalls() to check sub-registers liveness and thus produce correct code for example above: *(u64 *)(r10 - 8) = r1 call foo r1 = *(u64 *)(r10 - 8) w0 = w1 exit
bpf_fastcall induced spill/fill pairs should be generated for sub-register as well as for sub-registers. At the moment this is not the case, e.g.:
Modify BPFMIPeephole.cpp:collectBPFFastCalls() to check sub-registers liveness and thus produce correct code for example above: