================
@@ -0,0 +1,156 @@
+; RUN: llc -mtriple=bpfel -filetype=obj -o %t1 %s
+; RUN: llvm-objcopy --dump-section='.BTF'=%t2 %t1
+; RUN: %python %p/print_btf.py %t2 | FileCheck %s
+; RUN: llc -mtriple=bpfeb -filetype=obj -o %t1 %s
+; RUN: llvm-objcopy --dump-section='.BTF'=%t2 %t1
+; RUN: %python %p/print_btf.py %t2 | FileCheck %s
+
+; BTF has no references, so a C++ reference becomes a pointer, which has the
+; same layout. The name of a template specialization, such as 'TC<int>' or an
+; alias template, is emitted without its template arguments, as with
+; -gsimple-template-names: released kernels only accept identifiers as names.
+;
+; template <class T> struct TC { T v; };
+; template <class T> using Alias = TC<T>;
+; template <class T> struct TF;
+; struct R { int &r; int &&rr; int x; };
+; int f(TC<int> *a, TC<long> *b, Alias<char> *c, TF<int> *d, R *r) {
+;   return a->v + b->v + c->v + (d != 0) + r->x;
+; }
+; Compilation flags:
+;   clang --target=bpf -O2 -g -S -emit-llvm test.cpp
+
+; CHECK:      [1] PTR '(anon)' type_id=2
+; CHECK-NEXT: [2] STRUCT 'TC' size=4 vlen=1
+; CHECK-NEXT:         'v' type_id=3 bits_offset=0
+; CHECK-NEXT: [3] INT 'int' size=4 bits_offset=0 nr_bits=32 encoding=SIGNED
+; CHECK-NEXT: [4] PTR '(anon)' type_id=5
+; CHECK-NEXT: [5] STRUCT 'TC' size=8 vlen=1
----------------
tamird wrote:

The name rewrite itself is introduced by this PR. The [kernel change you 
cited](https://github.com/torvalds/linux/commit/bed1986a1932942e9db17fbdb2a19d0c4160a1f5)
 documents LLVM-emitted Rust `STRUCT 'NonNull<str>'` and extends kernel support 
for such names; unconditional truncation changes that existing name to 
`NonNull` and can break name-based consumers outside C++ too. Please leave name 
rewriting to #233947, or preserve existing names and distinct specialization 
identity here.

https://github.com/llvm/llvm-project/pull/233715
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to