1; RUN: opt -S < %s -passes=globalopt | FileCheck %s 2 3target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 4target triple = "x86_64-unknown-linux-gnu" 5 6@_ZL1x = internal global [200 x i8]* null, align 8, !dbg !0 7 8define i32 @main(i32 %argc, i8** %argv) norecurse !dbg !18 { 9; CHECK: define i32 @main 10; Make sure we localized the global. 11; CHECK: alloca [200 x i8]* 12; Make sure the metadata is sane. Currently, we just drop the metadata, 13; so it points to nothing. 14; CHECK: call void @llvm.dbg.value(metadata !2, 15; CHECK: !2 = !{} 16entry: 17 call void @llvm.dbg.value(metadata i32 %argc, metadata !22, metadata !23), !dbg !24 18 call void @llvm.dbg.value(metadata i8** %argv, metadata !25, metadata !23), !dbg !26 19 %arrayidx = getelementptr inbounds i8*, i8** %argv, i64 0, !dbg !27 20 %0 = load i8*, i8** %arrayidx, align 8, !dbg !27 21 %1 = bitcast i8* %0 to [200 x i8]*, !dbg !28 22 store [200 x i8]* %1, [200 x i8]** @_ZL1x, align 8, !dbg !29 23 call void @llvm.dbg.value(metadata i8** bitcast ([200 x i8]** @_ZL1x to i8**), metadata !30, metadata !23), !dbg !31 24 %2 = load i8*, i8** bitcast ([200 x i8]** @_ZL1x to i8**), align 8, !dbg !32 25 %3 = load i8, i8* %2, align 1, !dbg !33 26 %conv = sext i8 %3 to i32, !dbg !33 27 ret i32 %conv, !dbg !34 28} 29 30declare void @llvm.dbg.value(metadata, metadata, metadata) 31 32!llvm.dbg.cu = !{!2} 33!llvm.module.flags = !{!15, !16} 34!llvm.ident = !{!17} 35 36!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) 37!1 = distinct !DIGlobalVariable(name: "x", linkageName: "_ZL1x", scope: !2, file: !14, line: 1, type: !6, isLocal: true, isDefinition: true) 38!2 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, retainedTypes: !5, globals: !13) 39!3 = !DIFile(filename: "-", directory: "/") 40!4 = !{} 41!5 = !{!6, !11} 42!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) 43!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 1600, elements: !9) 44!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) 45!9 = !{!10} 46!10 = !DISubrange(count: 200) 47!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) 48!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64) 49!13 = !{!0} 50!14 = !DIFile(filename: "<stdin>", directory: "/") 51!15 = !{i32 2, !"Dwarf Version", i32 4} 52!16 = !{i32 2, !"Debug Info Version", i32 3} 53!17 = !{!"clang"} 54!18 = distinct !DISubprogram(name: "main", scope: !14, file: !14, line: 2, type: !19, isLocal: false, isDefinition: true, scopeLine: 2, flags: DIFlagPrototyped, isOptimized: false, unit: !2, retainedNodes: !4) 55!19 = !DISubroutineType(types: !20) 56!20 = !{!21, !21, !11} 57!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) 58!22 = !DILocalVariable(name: "argc", arg: 1, scope: !18, file: !14, line: 2, type: !21) 59!23 = !DIExpression() 60!24 = !DILocation(line: 2, column: 14, scope: !18) 61!25 = !DILocalVariable(name: "argv", arg: 2, scope: !18, file: !14, line: 2, type: !11) 62!26 = !DILocation(line: 2, column: 26, scope: !18) 63!27 = !DILocation(line: 2, column: 52, scope: !18) 64!28 = !DILocation(line: 2, column: 38, scope: !18) 65!29 = !DILocation(line: 2, column: 36, scope: !18) 66!30 = !DILocalVariable(name: "y", scope: !18, file: !14, line: 2, type: !11) 67!31 = !DILocation(line: 2, column: 68, scope: !18) 68!32 = !DILocation(line: 2, column: 92, scope: !18) 69!33 = !DILocation(line: 2, column: 91, scope: !18) 70!34 = !DILocation(line: 2, column: 84, scope: !18) 71