[clang] [llvm] [BPF] Handle C++ records in BTF and CO-RE (PR #233715)

Tamir Duberstein via cfe-commits cfe-commits at lists.llvm.org
Tue Oct 20 11:58:57 PDT 2026


================
@@ -252,6 +252,37 @@ static bool canUseNocallOptimizedSignature(
   return true;
 }
 
+/// Return the name to emit for a named BTF type. Released kernels only accept
+/// identifiers as type names, so a C++ template specialization is named without
+/// its template arguments, as with -gsimple-template-names. Type identity and
+/// fixups keep using the DI name.
+static StringRef getBTFTypeName(StringRef Name) {
+  return Name.take_front(Name.find('<'));
+}
+
+/// Whether a DI derived type tag becomes a BTF pointer: a pointer, or a C++
+/// reference, which BTF has no kind for.
+static bool isBTFPointerTag(unsigned Tag) {
----------------
tamird wrote:

Please apply the same pointer-like rule in `sourceArgMatchesIRType()`. Dead-argument elimination can retain a C++ reference as an IR pointer while the source debug type remains a reference and the signature is marked `DW_CC_nocall`. The raw pointer-tag check rejects that pair, so the fallback serializes eliminated source arguments into the BTF function prototype. That prototype disagrees with the actual optimized ABI. Extend the matcher and cover a surviving reference parameter.

https://github.com/llvm/llvm-project/pull/233715


More information about the cfe-commits mailing list