1 ; RUN: llc -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s
3 ;; This checks if the call site information is correctly written in debug info.
4 ;; This is a regression test for the bug that DwarfDebug unconditionally assumed
5 ;; the callee operand was getOperand(0), which was not true for WebAssembly.
7 target datalayout = "e-m:e-p:32:32-i64:64-n32:64-S128"
8 target triple = "wasm32-unknown-unknown"
10 ; CHECK: 0x00000026: DW_TAG_subprogram
11 ; CHECK: DW_AT_name ("call_direct")
12 ; CHECK: 0x0000003d: DW_TAG_GNU_call_site
13 ; CHECK-NEXT: DW_AT_abstract_origin (0x00000047 "foo")
15 define i32 @call_direct() !dbg !6 {
17 %0 = call i32 @foo(), !dbg !8
21 ;; WebAssembly does not currently support DW_TAG_GNU_call_site for stackified
22 ;; registers. This just checks if the test runs without crashing.
23 define i32 @call_indirect(i32 (i32, i32)* %callee) !dbg !11 {
24 %1 = call i32 %callee(i32 3, i32 5), !dbg !12
28 declare !dbg !10 i32 @foo()
29 declare void @llvm.dbg.value(metadata, metadata, metadata)
32 !llvm.module.flags = !{!3, !4, !5}
34 !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug)
35 !1 = !DIFile(filename: "test.c", directory: "/home/llvm-project")
36 !2 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
37 !3 = !{i32 7, !"Dwarf Version", i32 4}
38 !4 = !{i32 2, !"Debug Info Version", i32 3}
39 !5 = !{i32 1, !"wchar_size", i32 4}
40 !6 = distinct !DISubprogram(name: "call_direct", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
41 !7 = !DISubroutineType(types: !{null})
42 !8 = !DILocation(line: 4, column: 11, scope: !6)
43 !9 = !DILocation(line: 7, column: 1, scope: !6)
44 !10 = !DISubprogram(name: "foo", scope: !1, file: !1, line: 30, type: !7, scopeLine: 3, spFlags: DISPFlagOptimized)
45 !11 = distinct !DISubprogram(name: "call_indirect", scope: !1, file: !1, line: 3, type: !7, scopeLine: 3, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0)
46 !12 = !DILocation(line: 40, column: 11, scope: !11)
47 !13 = !DILocation(line: 70, column: 1, scope: !11)