diff --git a/llvm/lib/Transforms/Utils/AutoInitRemark.cpp b/llvm/lib/Transforms/Utils/AutoInitRemark.cpp --- a/llvm/lib/Transforms/Utils/AutoInitRemark.cpp +++ b/llvm/lib/Transforms/Utils/AutoInitRemark.cpp @@ -146,6 +146,8 @@ void AutoInitRemark::inspectVariable(const Value *V, SmallVectorImpl &Result) { + if (isa(V)) + return; // If we find some information in the debug info, take that. bool FoundDI = false; // Try to get an llvm.dbg.declare, which has a DILocalVariable giving us the diff --git a/llvm/test/Transforms/Util/trivial-auto-var-init-crash-20210521.ll b/llvm/test/Transforms/Util/trivial-auto-var-init-crash-20210521.ll new file mode 100644 --- /dev/null +++ b/llvm/test/Transforms/Util/trivial-auto-var-init-crash-20210521.ll @@ -0,0 +1,70 @@ +; RUN: opt < %s -annotation-remarks -pass-remarks-missed=annotation-remarks -S -o /dev/null 2>&1 | FileCheck %s + +; ModuleID = 'bugpoint-reduced-simplified.bc' +source_filename = "test.ll" +target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128" +target triple = "arm64-apple-ios14.4.0" + +%struct.frop = type { i8* } + +; Function Attrs: argmemonly nofree nosync nounwind willreturn +declare void @llvm.memset.p0i8.i64(i8* noalias nocapture writeonly, i8, i64, i1 immarg) #0 + +define void @spam() local_unnamed_addr #1 !dbg !3 { +bb: + call void @llvm.dbg.value(metadata %struct.frop* null, metadata !21, metadata !DIExpression()) #3, !dbg !28 + %tmp = getelementptr inbounds %struct.frop, %struct.frop* null, i64 0, i32 0 + %tmp1 = bitcast i8** %tmp to i8* + +; CHECK: remark: :1:0: Call to memset inserted by -ftrivial-auto-var-init. Memory operation size: 0 bytes. + tail call void @llvm.memset.p0i8.i64(i8* %tmp1, i8 0, i64 0, i1 false), !annotation !33, !dbg !28 + ret void +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) #2 + +attributes #0 = { argmemonly nofree nosync nounwind willreturn } +attributes #1 = { "target-features"="+aes,+crypto,+fp-armv8,+neon,+sha2,+zcm,+zcz" } +attributes #2 = { nofree nosync nounwind readnone speculatable willreturn } +attributes #3 = { nounwind } + +!llvm.module.flags = !{!0} +!llvm.dbg.cu = !{!1} + +!0 = !{i32 2, !"Debug Info Version", i32 3} +!1 = distinct !DICompileUnit(language: DW_LANG_C99, file: !2, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: NoDebug) +!2 = !DIFile(filename: "frop.c", directory: "frop") +!3 = distinct !DISubprogram(scope: !4, file: !4, line: 1, type: !5, scopeLine: 2167, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !19) +!4 = !DIFile(filename: "", directory: "frop") +!5 = !DISubroutineType(types: !6) +!6 = !{!7} +!7 = !DIDerivedType(tag: DW_TAG_typedef, file: !4, line: 1, baseType: !8) +!8 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !9, size: 64) +!9 = distinct !DICompositeType(tag: DW_TAG_union_type, file: !4, line: 1, size: 1664, elements: !10) +!10 = !{!11} +!11 = !DIDerivedType(tag: DW_TAG_member, scope: !12, file: !4, line: 1, baseType: !16, size: 192) +!12 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !4, line: 1, size: 832, elements: !13) +!13 = !{!14} +!14 = !DIDerivedType(tag: DW_TAG_member, scope: !12, file: !4, line: 1, baseType: !15, size: 448) +!15 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !4, line: 1, size: 448, elements: !10) +!16 = distinct !DICompositeType(tag: DW_TAG_structure_type, file: !4, line: 1, size: 192, elements: !17) +!17 = !{!18} +!18 = !DIDerivedType(tag: DW_TAG_member, scope: !12, file: !4, line: 1, baseType: !7, size: 64) +!19 = !{!20} +!20 = !DILocalVariable(arg: 1, scope: !3, file: !4, line: 1, type: !7) +!21 = !DILocalVariable(arg: 2, scope: !22, file: !4, line: 1, type: !7) +!22 = distinct !DISubprogram(scope: !4, file: !4, line: 1, type: !23, scopeLine: 1381, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagLocalToUnit | DISPFlagDefinition | DISPFlagOptimized, unit: !1, retainedNodes: !26) +!23 = !DISubroutineType(types: !24) +!24 = !{!25} +!25 = !DIBasicType(size: 32, encoding: DW_ATE_signed) +!26 = !{!27} +!27 = !DILocalVariable(arg: 1, scope: !22, file: !4, line: 1, type: !7) +!28 = !DILocation(line: 1, scope: !22, inlinedAt: !29) +!29 = distinct !DILocation(line: 1, scope: !30) +!30 = distinct !DILexicalBlock(scope: !31, file: !4, line: 1) +!31 = distinct !DILexicalBlock(scope: !32, file: !4, line: 1) +!32 = distinct !DILexicalBlock(scope: !3, file: !4, line: 1) + + +!33 = !{ !"auto-init" }