[llvm] [SROA]: Only defer trying partial sized ptr or ptr vector types (PR #82279)

Jeffrey Byrnes via llvm-commits llvm-commits at lists.llvm.org
Mon Mar 4 10:34:24 PST 2024


================
@@ -2257,6 +2257,38 @@ checkVectorTypesForPromotion(Partition &P, const DataLayout &DL,
   return nullptr;
 }
 
+static VectorType *createAndCheckVectorTypesForPromotion(
+    SetVector<Type *> &OtherTys,
+    SmallVectorImpl<VectorType *> &CandidateTysCopy,
+    function_ref<void(Type *)> CheckCandidateType, Partition &P,
+    const DataLayout &DL, SmallVector<VectorType *, 4> &CandidateTys,
+    bool &HaveCommonEltTy, Type *&CommonEltTy, bool &HaveVecPtrTy,
+    bool &HaveCommonVecPtrTy, VectorType *&CommonVecPtrTy) {
+  // Consider additional vector types where the element type size is a
+  // multiple of load/store element size.
+  for (Type *Ty : OtherTys) {
+    if (!VectorType::isValidElementType(Ty))
+      continue;
+    unsigned TypeSize = DL.getTypeSizeInBits(Ty).getFixedValue();
+    // Make a copy of CandidateTys and iterate through it, because we
+    // might append to CandidateTys in the loop.
+    for (VectorType *&VTy : CandidateTysCopy) {
----------------
jrbyrnes wrote:

There is no good way to capture the actual failure. This is because the failure depends on overwriting the reclaimed memory -- this is dependent upon malloc as well as hardware. 

Instead, I've added an assert which enforces memory invariance to support the test. This is one of the conditions for the failure.

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


More information about the llvm-commits mailing list