[Lldb-commits] [lldb] [Clang] Add __builtin_vectorelements to get number of elements in vector (PR #69010)

Erich Keane via lldb-commits lldb-commits at lists.llvm.org
Fri Oct 13 09:58:08 PDT 2023


================
@@ -13595,6 +13595,15 @@ bool IntExprEvaluator::VisitUnaryExprOrTypeTraitExpr(
                     Info.Ctx.getOpenMPDefaultSimdAlign(E->getArgumentType()))
             .getQuantity(),
         E);
+  case UETT_VectorElements: {
+    QualType Ty = E->getTypeOfArgument();
+    // If the vector has a fixed size, we can determine the number of elements
+    // at compile time.
+    if (Ty->isVectorType())
+      return Success(Ty->castAs<VectorType>()->getNumElements(), E);
+
+    return false;
----------------
erichkeane wrote:

Shouldn't this 'return false' just be an  assert?  (That is, instead of the 'if')?  Or is there a way for a non-vector type to make it through?

Additionally, what about sizeless vectors here?  Should we be testing for those instead to make this a 'fail'?  And does that case need a diagnostic?

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


More information about the lldb-commits mailing list