diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -375,6 +375,11 @@ auto It = Types.try_emplace(Offset.getZExtValue(), Ty).first; if (Ty != It->second) return false; + + // Scalable types not currently supported. + if (isa(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 --- /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] }> + +@.bss = internal unnamed_addr global %struct.xxx zeroinitializer, align 32 + +define dso_local void @foo() local_unnamed_addr align 16 #0 { +L.entry: + store zeroinitializer, ptr @.bss, align 1 + %0 = load , ptr @.bss, align 8 + unreachable +}