1 ; This test checks that 'llvm-objdump --source' works with archive files.
2 ; The reason this test is written in .ll is that showing source code
3 ; requires the debug data to have the source file path. Since we create
4 ; the source file ad-hoc in this test, we don't know the path beforehand to
5 ; create the object and archive.
7 ; RUN: rm -rf %t && mkdir -p %t/subdir && cd %t
8 ; RUN: echo -e "int foo(int a)\n\n{ return a+1; }" > subdir/a.c
9 ; RUN: sed -e "s,DIRNAME,%/t/subdir," %s | llc --filetype=obj -mtriple=x86_64-pc-linux -o a.o
10 ; RUN: llvm-ar rc a.a a.o
12 ; RUN: llvm-objdump --source a.a | FileCheck %s
14 ; CHECK: { return a+1; }
16 define i32 @foo(i32 %a) #0 !dbg !8 {
18 %a.addr = alloca i32, align 4
19 store i32 %a, i32* %a.addr, align 4
20 call void @llvm.dbg.declare(metadata i32* %a.addr, metadata !12, metadata !DIExpression()), !dbg !13
21 %0 = load i32, i32* %a.addr, align 4, !dbg !14
22 %add = add nsw i32 %0, 1, !dbg !14
23 ret i32 %add, !dbg !14
26 declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
28 attributes #0 = { noinline nounwind optnone sspstrong uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="false" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
29 attributes #1 = { nounwind readnone speculatable }
32 !llvm.module.flags = !{!3, !4, !5, !6}
35 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 9.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, nameTableKind: None)
36 !1 = !DIFile(filename: "a.c", directory: "DIRNAME")
38 !3 = !{i32 2, !"Dwarf Version", i32 4}
39 !4 = !{i32 2, !"Debug Info Version", i32 3}
40 !5 = !{i32 1, !"wchar_size", i32 2}
41 !6 = !{i32 7, !"PIC Level", i32 2}
42 !7 = !{!"clang version 9.0.0"}
43 !8 = distinct !DISubprogram(name: "foo", scope: !1, file: !1, line: 1, type: !9, scopeLine: 3, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
44 !9 = !DISubroutineType(types: !10)
46 !11 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
47 !12 = !DILocalVariable(name: "a", arg: 1, scope: !8, file: !1, line: 1, type: !11)
48 !13 = !DILocation(line: 1, scope: !8)
49 !14 = !DILocation(line: 3, scope: !8)