[llvm] Fixes for compile rust code (PR #192134)

via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 14 15:46:20 PDT 2026


================
@@ -794,6 +794,12 @@ void BTFDebug::visitArrayType(const DICompositeType *CTy, uint32_t &TypeId) {
 
   // Visit array dimensions.
   DINodeArray Elements = CTy->getElements();
+  if (Elements.size() == 0) {
+    // Rust and other languages may emit array types with no dimensions.
+    // Treat as a zero-length array so the type is still registered.
+    auto TypeEntry = std::make_unique<BTFTypeArray>(ElemTypeId, 0);
----------------
eddyz87 wrote:

I'd make a utility function `getElementsCount()` which returns 0 if nothing can be found. And use it to keep a single `std::make_unique<BTFTypeArray>(ElemTypeId, ?)` call.

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


More information about the llvm-commits mailing list