[520] % clangtk -v clang version 13.0.0 (https://github.com/llvm/llvm-project.git f860187ea6e9b30e1ecf74784f0af0e0c9ecc01c) Target: x86_64-unknown-linux-gnu Thread model: posix InstalledDir: /local/suz-local/opfuzz/bin Found candidate GCC installation: /usr/lib/gcc/i686-linux-gnu/8 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/6.5.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0 Found candidate GCC installation: /usr/lib/gcc/x86_64-linux-gnu/8 Selected GCC installation: /usr/lib/gcc/x86_64-linux-gnu/7.5.0 Candidate multilib: .;@m64 Candidate multilib: 32;@m32 Candidate multilib: x32;@mx32 Selected multilib: .;@m64 [521] % [521] % clangtk -Os small.c; ./a.out [522] % [522] % clangtk -O2 small.c [523] % ./a.out Segmentation fault [524] % [524] % cat small.c static int *a[2][3][3], b, c; int main() { for (c = 0; c < 2; c++) for (b = 0; b < 2; b++) a[1][c][b] = a[0][0][0]; return 0; }
https://gcc.godbolt.org/z/xTv9PG Seems to be an alignment issue @_ZL1a.1 = internal unnamed_addr global [3 x [3 x i32*]] zeroinitializer, align 16 define dso_local i32 @main() local_unnamed_addr #0 { store <2 x i32*> zeroinitializer, <2 x i32*>* bitcast ([3 x [3 x i32*]]* @_ZL1a.1 to <2 x i32*>*), align 16 store <2 x i32*> zeroinitializer, <2 x i32*>* bitcast (i32** getelementptr inbounds ([3 x [3 x i32*]], [3 x [3 x i32*]]* @_ZL1a.1, i64 0, i64 1, i64 0) to <2 x i32*>*), align 16 ; THIS ISN'T 16-BYTE ALIGNED ret i32 0 }
This looks the same as bug 50253, but not making it a duplicate yet since I don't know anything about -globalopt. Before that pass, we have: @c = internal unnamed_addr global i32 0, align 4 @b = internal unnamed_addr global i32 0, align 4 @a = internal unnamed_addr global [2 x [3 x [3 x i32*]]] zeroinitializer, align 16 ; Function Attrs: nofree norecurse nosync nounwind ssp uwtable define i32 @main() local_unnamed_addr #0 { entry: %0 = load i32*, i32** getelementptr inbounds ([2 x [3 x [3 x i32*]]], [2 x [3 x [3 x i32*]]]* @a, i64 0, i64 0, i64 0, i64 0), align 16, !tbaa !5 store i32* %0, i32** getelementptr inbounds ([2 x [3 x [3 x i32*]]], [2 x [3 x [3 x i32*]]]* @a, i64 0, i64 1, i64 0, i64 0), align 8, !tbaa !5 store i32* %0, i32** getelementptr inbounds ([2 x [3 x [3 x i32*]]], [2 x [3 x [3 x i32*]]]* @a, i64 0, i64 1, i64 0, i64 1), align 16, !tbaa !5 store i32* %0, i32** getelementptr inbounds ([2 x [3 x [3 x i32*]]], [2 x [3 x [3 x i32*]]]* @a, i64 0, i64 1, i64 1, i64 0), align 16, !tbaa !5 store i32* %0, i32** getelementptr inbounds ([2 x [3 x [3 x i32*]]], [2 x [3 x [3 x i32*]]]* @a, i64 0, i64 1, i64 1, i64 1), align 8, !tbaa !5 store i32 2, i32* @c, align 4, !tbaa !9 store i32 2, i32* @b, align 4, !tbaa !9 ret i32 0 } And after: @a.1 = internal unnamed_addr global [3 x [3 x i32*]] zeroinitializer, align 16 ; Function Attrs: nofree norecurse nosync nounwind ssp uwtable define i32 @main() local_unnamed_addr #0 { entry: %b = alloca i32, align 4 store i32 0, i32* %b, align 4 %c = alloca i32, align 4 store i32 0, i32* %c, align 4 store i32* null, i32** getelementptr inbounds ([3 x [3 x i32*]], [3 x [3 x i32*]]* @a.1, i32 0, i64 0, i64 0), align 8, !tbaa !5 store i32* null, i32** getelementptr inbounds ([3 x [3 x i32*]], [3 x [3 x i32*]]* @a.1, i32 0, i64 0, i64 1), align 16, !tbaa !5 store i32* null, i32** getelementptr inbounds ([3 x [3 x i32*]], [3 x [3 x i32*]]* @a.1, i32 0, i64 1, i64 0), align 16, !tbaa !5 store i32* null, i32** getelementptr inbounds ([3 x [3 x i32*]], [3 x [3 x i32*]]* @a.1, i32 0, i64 1, i64 1), align 8, !tbaa !5 store i32 2, i32* %c, align 4, !tbaa !9 store i32 2, i32* %b, align 4, !tbaa !9 ret i32 0 }
https://reviews.llvm.org/D102552
Should be fixed with: https://reviews.llvm.org/rGf34311c4024d
*** Bug 50253 has been marked as a duplicate of this bug. ***