Compiler projects using llvm
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py UTC_ARGS: --check-globals
; RUN: opt -S -globalopt < %s | FileCheck %s

; The store here writes into the padding after [5 x i8].
; Make sure we don't crash.

%T = type { [5 x i8], i16 }

@g = global %T zeroinitializer

@llvm.global_ctors = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @ctor, i8* null }]

;.
; CHECK: @[[G:[a-zA-Z0-9_$"\\.-]+]] = local_unnamed_addr global [[T:%.*]] zeroinitializer
; CHECK: @[[LLVM_GLOBAL_CTORS:[a-zA-Z0-9_$"\\.-]+]] = appending global [1 x { i32, void ()*, i8* }] [{ i32, void ()*, i8* } { i32 65535, void ()* @ctor, i8* null }]
;.
define internal void @ctor() {
; CHECK-LABEL: @ctor(
; CHECK-NEXT:    store i8 0, i8* getelementptr inbounds ([[T:%.*]], %T* @g, i64 0, i32 0, i64 5), align 1
; CHECK-NEXT:    ret void
;
  store i8 0, i8* getelementptr inbounds (%T, %T* @g, i64 0, i32 0, i64 5)
  ret void
}