[llvm] 38d58c1 - [GlobalOpt] Bail out of GlobalOpt SROA if a Scalable Vector is seen

Cameron McInally via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 24 13:21:56 PDT 2022


Author: Cameron McInally
Date: 2022-08-24T13:17:59-07:00
New Revision: 38d58c1b376d5781f0d293c9811dd3f2d9b3afcf

URL: https://github.com/llvm/llvm-project/commit/38d58c1b376d5781f0d293c9811dd3f2d9b3afcf
DIFF: https://github.com/llvm/llvm-project/commit/38d58c1b376d5781f0d293c9811dd3f2d9b3afcf.diff

LOG: [GlobalOpt] Bail out of GlobalOpt SROA if a Scalable Vector is seen

The SROA algorithm won't work for Scalable Vectors, since we don't
know how many bytes are loaded/stored. Bail out if a Scalable
Vector is seen.

Differential Revision: https://reviews.llvm.org/D132417

Added: 
    llvm/test/Transforms/GlobalOpt/2022-08-23-ScalableVectorCrash.ll

Modified: 
    llvm/lib/Transforms/IPO/GlobalOpt.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
index a7665f50a5eee..ff096b41ff64b 100644
--- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp
+++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp
@@ -375,6 +375,11 @@ static bool collectSRATypes(DenseMap<uint64_t, Type *> &Types, GlobalValue *GV,
       auto It = Types.try_emplace(Offset.getZExtValue(), Ty).first;
       if (Ty != It->second)
         return false;
+
+      // Scalable types not currently supported.
+      if (isa<ScalableVectorType>(Ty))
+        return false;
+
       continue;
     }
 

diff  --git a/llvm/test/Transforms/GlobalOpt/2022-08-23-ScalableVectorCrash.ll b/llvm/test/Transforms/GlobalOpt/2022-08-23-ScalableVectorCrash.ll
new file mode 100644
index 0000000000000..6014b63b1ac42
--- /dev/null
+++ b/llvm/test/Transforms/GlobalOpt/2022-08-23-ScalableVectorCrash.ll
@@ -0,0 +1,15 @@
+; RUN: opt -globalopt < %s
+
+; Ensure we don't ICE by trying to optimize a scalable vector load of a global
+; variable.
+
+%struct.xxx = type <{ [96 x i8] }>
+
+ at .bss = internal unnamed_addr global %struct.xxx zeroinitializer, align 32
+
+define dso_local void @foo() local_unnamed_addr align 16 #0 {
+L.entry:
+  store <vscale x 2 x double> zeroinitializer, ptr @.bss, align 1
+  %0 = load <vscale x 2 x double>, ptr @.bss, align 8
+  unreachable
+}


        


More information about the llvm-commits mailing list