81 lines · plain
1; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s2; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s3;4; Source code:5; extern void bla1;6; ptr test1() {7; ptr x = &bla1;8; return x;9; }10;11; extern const void bla2;12; const ptr test2() {13; const ptr x = &bla2;14; return x;15; }16; Compilation flag:17; clang -target bpf -O2 -g -S -emit-llvm t.c18 19@bla1 = external dso_local global i8, align 1, !dbg !020@bla2 = external dso_local constant i8, align 1, !dbg !621 22; Function Attrs: norecurse nounwind readnone23define dso_local nonnull ptr @test1() local_unnamed_addr #0 !dbg !13 {24entry:25 call void @llvm.dbg.value(metadata ptr @bla1, metadata !18, metadata !DIExpression()), !dbg !1926 ret ptr @bla1, !dbg !2027}28 29; Function Attrs: norecurse nounwind readnone30define dso_local nonnull ptr @test2() local_unnamed_addr #0 !dbg !21 {31entry:32 call void @llvm.dbg.value(metadata ptr @bla2, metadata !26, metadata !DIExpression()), !dbg !2733 ret ptr @bla2, !dbg !2834}35 36; CHECK: .quad bla137; CHECK-NEXT: DW_TAG_variable38;39; CHECK: .quad bla240; CHECK-NEXT: DW_TAG_const_type41 42; Function Attrs: nounwind readnone speculatable willreturn43declare void @llvm.dbg.value(metadata, metadata, metadata) #144 45attributes #0 = { norecurse nounwind readnone "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "use-soft-float"="false" }46attributes #1 = { nounwind readnone speculatable willreturn }47 48!llvm.dbg.cu = !{!2}49!llvm.module.flags = !{!9, !10, !11}50!llvm.ident = !{!12}51 52!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())53!1 = distinct !DIGlobalVariable(name: "bla1", scope: !2, file: !3, line: 1, isLocal: false, isDefinition: false)54!2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 11.0.0 (https://github.com/llvm/llvm-project.git 8a8c6913a931e8bbd119012f4badd81155a0f48a)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !4, globals: !5, splitDebugInlining: false, nameTableKind: None)55!3 = !DIFile(filename: "t.c", directory: "/home/yhs/tmp3")56!4 = !{}57!5 = !{!0, !6}58!6 = !DIGlobalVariableExpression(var: !7, expr: !DIExpression())59!7 = distinct !DIGlobalVariable(name: "bla2", scope: !2, file: !3, line: 7, type: !8, isLocal: false, isDefinition: false)60!8 = !DIDerivedType(tag: DW_TAG_const_type, baseType: null)61!9 = !{i32 7, !"Dwarf Version", i32 4}62!10 = !{i32 2, !"Debug Info Version", i32 3}63!11 = !{i32 1, !"wchar_size", i32 4}64!12 = !{!"clang version 11.0.0 (https://github.com/llvm/llvm-project.git 8a8c6913a931e8bbd119012f4badd81155a0f48a)"}65!13 = distinct !DISubprogram(name: "test1", scope: !3, file: !3, line: 2, type: !14, scopeLine: 2, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !17)66!14 = !DISubroutineType(types: !15)67!15 = !{!16}68!16 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: null, size: 64)69!17 = !{!18}70!18 = !DILocalVariable(name: "x", scope: !13, file: !3, line: 3, type: !16)71!19 = !DILocation(line: 0, scope: !13)72!20 = !DILocation(line: 4, column: 3, scope: !13)73!21 = distinct !DISubprogram(name: "test2", scope: !3, file: !3, line: 8, type: !22, scopeLine: 8, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !25)74!22 = !DISubroutineType(types: !23)75!23 = !{!24}76!24 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !8, size: 64)77!25 = !{!26}78!26 = !DILocalVariable(name: "x", scope: !21, file: !3, line: 9, type: !24)79!27 = !DILocation(line: 0, scope: !21)80!28 = !DILocation(line: 10, column: 3, scope: !21)81