[PATCH] D83242: [clang][BPF] support expr with typedef/record type for FIELD_EXISTENCE reloc

Yonghong Song via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Jul 15 13:23:36 PDT 2020


yonghong-song added a comment.

In D83242#2154145 <https://reviews.llvm.org/D83242#2154145>, @ast wrote:

> lgtm.
>  curious what happens when type is defined within args, like:
>  __builtin_preserve_field_info(*(struct { int a; } *)0, 2);


-bash-4.4$ clang -target bpf -O2 -g -S t1.c
t1.c:3:40: error: __builtin_preserve_field_info argument 1 invalid

  return __builtin_preserve_field_info(*(struct { int a; } *)0, 2);

it will flag out an error since an non-empty name is required
as we will need it to generate relocation.

  if (!RT || RT->getDecl()->getDeclName().isEmpty())

With an name, it works properly.

  -bash-4.4$ cat t1.c
  
  unsigned unit1() {
    return __builtin_preserve_field_info(*(struct t { int a; } *)0, 2);
  }
  -bash-4.4$ clang -target bpf -O2 -g -S t1.c                                                        
  -bash-4.4$




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D83242





More information about the cfe-commits mailing list