Created attachment 20745 [details] C test case The attached test cases trigger assertion failures in BPFAsmBackend::applyFixup() with llvm/clang 6.0.1. I've provided the original C test case as well as a reduced LLVM IR To reproduce: clang -target bpf kprobes_kern.c or ./llc -march=bpf bpf-fixup-crash.ll -filetype=obj
Created attachment 20746 [details] LLVM IR test case
llvm 7.0.0 seems working fine. -bash-4.2$ llc -version LLVM (http://llvm.org/): LLVM version 7.0.0 Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: broadwell Registered Targets: bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 -bash-4.2$ cat fixup.ll ; ModuleID = 'bugpoint-reduced-simplified.bc' source_filename = "bugpoint-output-9102428.bc" target datalayout = "e-m:e-p:64:64-i64:64-n32:64-S128" target triple = "bpf" %struct.bpf_map_def.0.4.8.10.12.16.20.22.24.26 = type { i32, i32, i32, i32, i32, i32, i32 } %struct.pt_regs.1.5.9.11.13.17.21.23.25.27 = type { i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64 } @my_map = external global %struct.bpf_map_def.0.4.8.10.12.16.20.22.24.26, section "maps", align 4 @bpf_map_lookup_elem = internal global i8* (i8*, i8*)* inttoptr (i64 1 to i8* (i8*, i8*)*), align 8 @bpf_map_update_elem = internal global i32 (i8*, i8*, i8*, i64)* inttoptr (i64 2 to i32 (i8*, i8*, i8*, i64)*), align 8 ; Function Attrs: noinline nounwind optnone define i32 @bpf_prog1(%struct.pt_regs.1.5.9.11.13.17.21.23.25.27* %ctx) { entry: %0 = load i32 (i8*, i8*, i8*, i64)*, i32 (i8*, i8*, i8*, i64)** @bpf_map_update_elem, align 8 %call2 = call i32 %0(i8* bitcast (%struct.bpf_map_def.0.4.8.10.12.16.20.22.24.26* @my_map to i8*), i8* undef, i8* undef, i64 0) ret i32 %call2 } -bash-4.2$ llc -march=bpf -filetype=obj fixup.ll -bash-4.2$ and latest trunk 8.0.0 works as well. -bash-4.2$ llc -version LLVM (http://llvm.org/): LLVM version 8.0.0svn Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: broadwell Registered Targets: bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 -bash-4.2$ llc -march=bpf -filetype=obj fixup.ll -bash-4.2$
Some how I cannot reproduce the issue with manually built 6.0.1. The following is how I built llvm: # release_60 branch of llvm and clang cd llvm/build cmake -G "Unix Makefiles" -DLLVM_TARGETS_TO_BUILD="BPF;X86" \ -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=$PWD/install .. make -j120 make install -bash-4.2$ llc -version LLVM (http://llvm.org/): LLVM version 6.0.1 Optimized build. Default target: x86_64-unknown-linux-gnu Host CPU: broadwell Registered Targets: bpf - BPF (host endian) bpfeb - BPF (big endian) bpfel - BPF (little endian) x86 - 32-bit X86: Pentium-Pro and above x86-64 - 64-bit X86: EM64T and AMD64 -bash-4.2$ llc -march=bpf -filetype=obj fixup.ll -bash-4.2$ Did I miss anything in order to reproduce the failure?
You need to build with -DLLVM_ENABLE_ASSERTIONS=ON
Okay, I can reproduce the problem now with latest trunk. will take a look soon.
Fixed with better error messages. https://reviews.llvm.org/rL340455