diff --git a/llvm/lib/IR/Type.cpp b/llvm/lib/IR/Type.cpp --- a/llvm/lib/IR/Type.cpp +++ b/llvm/lib/IR/Type.cpp @@ -548,6 +548,8 @@ // vector case all of the indices must be equal. if (!V->getType()->isIntOrIntVectorTy(32)) return false; + if (isa(V->getType())) + return false; const Constant *C = dyn_cast(V); if (C && V->getType()->isVectorTy()) C = C->getSplatValue(); diff --git a/llvm/test/Assembler/getelementptr_vscale_struct.ll b/llvm/test/Assembler/getelementptr_vscale_struct.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Assembler/getelementptr_vscale_struct.ll @@ -0,0 +1,10 @@ +; RUN: not llvm-as < %s >/dev/null 2> %t +; RUN: FileCheck %s < %t +; Test that a scalable vector struct index is rejected. + +; CHECK: invalid getelementptr indices + +define @test7( %a) { + %w = getelementptr {i32, i32}, %a, zeroinitializer, zeroinitializer + ret %w +}