[PATCH] D156136: [BPF] Clean up SelLowering

Yonghong Song via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 30 17:09:13 PDT 2023


yonghong-song added a comment.

The error message is not what I envisioned.

  $ cat t.c
  struct t {
     int a;
  };
  struct t foo(int a, int b) {
    struct t tmp;
    tmp.a = a + b;
    return tmp;
  }
  $ clang --target=bpf -O2 -g -c t.c
  t.c:4:10: error: functions returning through a pointer parameter are not supported
      4 | struct t foo(int a, int b) {
        |          ^
  1 error generated.
  $

>From source code perspective, there is no 'returning through a pointer parameter'.
The source code shows 'returning a struct'.
The error message can be 'functions returning a struct are not supported'.

'union' has the same issue,

  $ cat t.c
  union t {
     int a;
     int b;
  };
  union t foo(int a, int b) {
    union t tmp;
    tmp.a = a + b;
    return tmp;
  }
  $ clang --target=bpf -O2 -g -c t.c
  t.c:5:9: error: functions returning through a pointer parameter are not supported
      5 | union t foo(int a, int b) {
        |         ^
  1 error generated.
  $

In llvm IR, 'union' is represented as 'struct' as well.

If you really want, the error message can be
`functions returning a struct/union are not supported`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156136/new/

https://reviews.llvm.org/D156136



More information about the llvm-commits mailing list