69 lines · plain
1; RUN: opt -S < %s -passes=globalopt | FileCheck %s2 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 ptr null, align 8, !dbg !07 8define i32 @main(i32 %argc, ptr %argv) norecurse !dbg !18 {9; CHECK: define i32 @main10; Make sure we localized the global.11; CHECK: alloca ptr12; Make sure the metadata is sane. Currently, we just drop the metadata,13; so it points to nothing.14; CHECK: #dbg_value(ptr poison,15; CHECK: !2 = !{}16entry:17 call void @llvm.dbg.value(metadata i32 %argc, metadata !22, metadata !23), !dbg !2418 call void @llvm.dbg.value(metadata ptr %argv, metadata !25, metadata !23), !dbg !2619 %0 = load ptr, ptr %argv, align 8, !dbg !2720 store ptr %0, ptr @_ZL1x, align 8, !dbg !2921 call void @llvm.dbg.value(metadata ptr @_ZL1x, metadata !30, metadata !23), !dbg !3122 %1 = load ptr, ptr @_ZL1x, align 8, !dbg !3223 %2 = load i8, ptr %1, align 1, !dbg !3324 %conv = sext i8 %2 to i32, !dbg !3325 ret i32 %conv, !dbg !3426}27 28declare void @llvm.dbg.value(metadata, metadata, metadata)29 30!llvm.dbg.cu = !{!2}31!llvm.module.flags = !{!15, !16}32!llvm.ident = !{!17}33 34!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())35!1 = distinct !DIGlobalVariable(name: "x", linkageName: "_ZL1x", scope: !2, file: !14, line: 1, type: !6, isLocal: true, isDefinition: true)36!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)37!3 = !DIFile(filename: "-", directory: "/")38!4 = !{}39!5 = !{!6, !11}40!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64)41!7 = !DICompositeType(tag: DW_TAG_array_type, baseType: !8, size: 1600, elements: !9)42!8 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)43!9 = !{!10}44!10 = !DISubrange(count: 200)45!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64)46!12 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)47!13 = !{!0}48!14 = !DIFile(filename: "<stdin>", directory: "/")49!15 = !{i32 2, !"Dwarf Version", i32 4}50!16 = !{i32 2, !"Debug Info Version", i32 3}51!17 = !{!"clang"}52!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)53!19 = !DISubroutineType(types: !20)54!20 = !{!21, !21, !11}55!21 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)56!22 = !DILocalVariable(name: "argc", arg: 1, scope: !18, file: !14, line: 2, type: !21)57!23 = !DIExpression()58!24 = !DILocation(line: 2, column: 14, scope: !18)59!25 = !DILocalVariable(name: "argv", arg: 2, scope: !18, file: !14, line: 2, type: !11)60!26 = !DILocation(line: 2, column: 26, scope: !18)61!27 = !DILocation(line: 2, column: 52, scope: !18)62!28 = !DILocation(line: 2, column: 38, scope: !18)63!29 = !DILocation(line: 2, column: 36, scope: !18)64!30 = !DILocalVariable(name: "y", scope: !18, file: !14, line: 2, type: !11)65!31 = !DILocation(line: 2, column: 68, scope: !18)66!32 = !DILocation(line: 2, column: 92, scope: !18)67!33 = !DILocation(line: 2, column: 91, scope: !18)68!34 = !DILocation(line: 2, column: 84, scope: !18)69