[PATCH] D155894: [BPF] Do not miscompile, allow external calls
Eduard Zingerman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 16:40:07 PDT 2023
eddyz87 added a comment.
In D155894#4529918 <https://reviews.llvm.org/D155894#4529918>, @tamird wrote:
> Yeah, I also can't reproduce using llc. But in the actual code this module is fed into `LLVMTargetMachineEmitToFile` and those errors do show up.
Basing on the previous comments I assume that one of the functions for which such errors are printed is `llvm.memset.p0.i64`.
When `llc` processes the `module.ll` example that you have shared I see that calls to `llvm.memset.p0.i64` are replaced by store instructions, e.g. the following IR:
%8 = call noundef ptr inttoptr (i64 1 to ptr)(ptr noundef nonnull @AYA_LOG_BUF, ptr noundef nonnull %2) #8
...
%68 = getelementptr inbounds i8, ptr %8, i64 62
...
call void @llvm.memset.p0.i64(ptr noundef nonnull align 1 dereferenceable(7) %68, i8 0, i64 7, i1 false)
Is converted to the following byte code:
r1 = AYA_LOG_BUF ll
call 1 # bpf_map_lookup_elem
...
r1 = 0
*(u8 *)(r0 + 69) = w1
...
*(u8 *)(r0 + 62) = w1
This replacement happens when selection DAG is constructed (I assume this is default lowering logic for memset).
So, whatever is calling `LLVMTargetMachineEmitToFile` on your side must do some adjustments to the `BPFISelLowering` logic.
What tool does the `LLVMTargetMachineEmitToFile` call? Is it open source? Or am I confused?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155894/new/
https://reviews.llvm.org/D155894
More information about the llvm-commits
mailing list