Index: llvm/lib/Transforms/IPO/GlobalOpt.cpp =================================================================== --- llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -477,6 +477,10 @@ if (Pair.first < Offset) return nullptr; + // Scalable types not currently supported. + if (isa(Pair.second)) + return nullptr; + Offset = Pair.first + DL.getTypeAllocSize(Pair.second); } Index: llvm/test/Transforms/GlobalOpt/2022-08-23-ScalableVectorCrash.ll =================================================================== --- /dev/null +++ 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 +}