Issue 57291
Summary [llvm16] LLVM ERROR: Could not match memory address. Inline asm failure!
Labels new issue
Assignees
Reporter xiaer1921
    a llvm error  when I make linux ebpf test code.

``` c
#include <linux/netdevice.h>
#include <uapi/linux/bpf.h>
#include <linux/version.h>
#include <bpf/bpf_helpers.h>
#include <bpf/bpf_tracing.h>
#include <linux/sched.h>

static struct task_struct *p;

SEC("tracepoint/syscalls/sys_enter_execve")
int bpf_prog(void *ctx) {
  char msg[] = "pid filter! pid is %d, tgid is %d\n";
  //u32 pid = bpf_get_current_pid_tgid() & 0xFFFF;
  //u32 tgid = bpf_get_current_pid_tgid() >>32;
  p = current;
  u32 pid = p->pid;
  u32 tgid = p->tgid;
  bpf_trace_printk(msg, sizeof(msg), pid, tgid);
  return 0;
}
```

The version of llvm and clang:

``` shell
✗ llc -version
LLVM (http://llvm.org/):
  LLVM version 16.0.0git
  DEBUG build with assertions.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

  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

 ✗ clang -v   
clang version 16.0.0
Target: x86_64-unknown-linux-gnu
Thread model: posix
InstalledDir: /usr/local/bin
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/12.0.1
Found candidate GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.5.0
Selected GCC installation: /usr/local/bin/../lib/gcc/x86_64-pc-linux-gnu/6.5.0
Candidate multilib: .;@m64
Selected multilib: .;@m64
```

crash backtrace:

``` shell
LLVM ERROR: Could not match memory address.  Inline asm failure!
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0.      Program arguments: llc -march=bpf -filetype=obj -o /github/linux/samples/bpf/pid_filter_kern.o
1.      Running pass 'Function Pass Manager' on module '<stdin>'.
2.      Running pass 'BPF DAG->DAG Pattern Instruction Selection' on function '@bpf_prog'
 #0 0x00000000035e2e57 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/usr/local/bin/llc+0x35e2e57)
 #1 0x00000000035e2f0e PrintStackTraceSignalHandler(void*) Signals.cpp:0:0
 #2 0x00000000035e0a57 llvm::sys::RunSignalHandlers() (/usr/local/bin/llc+0x35e0a57)
 #3 0x00000000035e27b5 SignalHandler(int) Signals.cpp:0:0
 #4 0x00007f348fe11390 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x11390)
 #5 0x00007f348e235438 raise /build/glibc-S7Ft5T/glibc-2.23/signal/../sysdeps/unix/sysv/linux/raise.c:54:0
 #6 0x00007f348e23703a abort /build/glibc-S7Ft5T/glibc-2.23/stdlib/abort.c:91:0
 #7 0x0000000003519e6a llvm::report_fatal_error(llvm::Twine const&, bool) (/usr/local/bin/llc+0x3519e6a)
 #8 0x0000000003519c58 llvm::report_fatal_error(llvm::StringRef, bool) (/usr/local/bin/llc+0x3519c58)
 #9 0x00000000033ab99a llvm::SelectionDAGISel::SelectInlineAsmMemoryOperands(std::vector<llvm::SDValue, std::allocator<llvm::SDValue>>&, llvm::SDLoc const&) (/usr/local/bin/llc+0x33ab99a)
#10 0x00000000033ac203 llvm::SelectionDAGISel::Select_INLINEASM(llvm::SDNode*) (/usr/local/bin/llc+0x33ac203)
#11 0x00000000033b006f llvm::SelectionDAGISel::SelectCodeCommon(llvm::SDNode*, unsigned char const*, unsigned int) (/usr/local/bin/llc+0x33b006f)
#12 0x000000000183550a (anonymous namespace)::BPFDAGToDAGISel::SelectCode(llvm::SDNode*) BPFISelDAGToDAG.cpp:0:0
#13 0x0000000001836cea (anonymous namespace)::BPFDAGToDAGISel::Select(llvm::SDNode*) BPFISelDAGToDAG.cpp:0:0
#14 0x00000000033a6a77 llvm::SelectionDAGISel::DoInstructionSelection() (/usr/local/bin/llc+0x33a6a77)
#15 0x00000000033a5d4c llvm::SelectionDAGISel::CodeGenAndEmitDAG() (/usr/local/bin/llc+0x33a5d4c)
#16 0x00000000033a4411 llvm::SelectionDAGISel::SelectBasicBlock(llvm::ilist_iterator<llvm::ilist_detail::node_options<llvm::Instruction, false, false, void>, false, true>, llvm::ilist_iterator<llvm::ilis$
_detail::node_options<llvm::Instruction, false, false, void>, false, true>, bool&) (/usr/local/bin/llc+0x33a4411)
#17 0x00000000033a9255 llvm::SelectionDAGISel::SelectAllBasicBlocks(llvm::Function const&) (/usr/local/bin/llc+0x33a9255)
#18 0x00000000033a2f11 llvm::SelectionDAGISel::runOnMachineFunction(llvm::MachineFunction&) (/usr/local/bin/llc+0x33a2f11)
#19 0x00000000018354db (anonymous namespace)::BPFDAGToDAGISel::runOnMachineFunction(llvm::MachineFunction&) BPFISelDAGToDAG.cpp:0:0
#20 0x0000000002465cfb llvm::MachineFunctionPass::runOnFunction(llvm::Function&) (/usr/local/bin/llc+0x2465cfb)
#21 0x0000000002b57048 llvm::FPPassManager::runOnFunction(llvm::Function&) (/usr/local/bin/llc+0x2b57048)
#22 0x0000000002b572f1 llvm::FPPassManager::runOnModule(llvm::Module&) (/usr/local/bin/llc+0x2b572f1)
#23 0x0000000002b57719 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) LegacyPassManager.cpp:0:0
#24 0x0000000002b526a9 llvm::legacy::PassManagerImpl::run(llvm::Module&) (/usr/local/bin/llc+0x2b526a9)
#25 0x0000000002b57fa3 llvm::legacy::PassManager::run(llvm::Module&) (/usr/local/bin/llc+0x2b57fa3)
#26 0x0000000001758cce compileModule(char**, llvm::LLVMContext&) llc.cpp:0:0
#27 0x0000000001755973 main (/usr/local/bin/llc+0x1755973)
#28 0x00007f348e220840 __libc_start_main /build/glibc-S7Ft5T/glibc-2.23/csu/../csu/libc-start.c:325:0
#29 0x0000000001750219 _start (/usr/local/bin/llc+0x1750219)
/bin/sh: 行 12: 14751 已完成               clang -nostdinc -I./arch/x86/include -I./arch/x86/include/generated -I./include -I./arch/x86/include/uapi -I./arch/x86/include/generated/uapi -I./include/uapi -$
./include/generated/uapi -include ./include/linux/compiler-version.h -include ./include/linux/kconfig.h -fno-stack-protector -g -I/github/linux/samples/bpf -I./tools/testing/selftests/bpf/ -I/github/linu$
/samples/bpf/libbpf/include -D__KERNEL__ -D__BPF_TRACING__ -Wno-unused-value -Wno-pointer-sign -D__TARGET_ARCH_x86 -Wno-compare-distinct-pointer-types -Wno-gnu-variable-sized-type-not-at-end -Wno-address$
of-packed-member -Wno-tautological-compare -Wno-unknown-warning-option -fno-asynchronous-unwind-tables -I./samples/bpf/ -include asm_goto_workaround.h -O2 -emit-llvm -Xclang -disable-llvm-passes -c /gith$
b/linux/samples/bpf/pid_filter_kern.c -o -
     14752                       | opt -O2 -mtriple=bpf-pc-linux
     14753                       | llvm-dis
     14754 已放弃               | llc -march=bpf -filetype=obj -o /github/linux/samples/bpf/pid_filter_kern.o
/github/linux/samples/bpf/Makefile:445: recipe for target '/github/linux/samples/bpf/pid_filter_kern.o' failed
make[2]: *** [/github/linux/samples/bpf/pid_filter_kern.o] Error 134
Makefile:1834: recipe for target '/github/linux/samples/bpf' failed
make[1]: *** [/github/linux/samples/bpf] Error 2
make[1]: Leaving directory '/github/linux'
Makefile:281: recipe for target 'all' failed
make: *** [all] Error 2

```
_______________________________________________
llvm-bugs mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs

Reply via email to