diff --git a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp --- a/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp +++ b/llvm/lib/CodeGen/AsmPrinter/DwarfDebug.cpp @@ -992,6 +992,16 @@ assert((IsTail || PCAddr) && "Non-tail call without return PC"); + ParamSet Params; + // Try to interpret values of call site parameters. + if (!emitDebugEntryValues()) + continue; + + collectCallSiteParameters(&MI, Params); + + if (Params.size() == 0) + continue; + LLVM_DEBUG(dbgs() << "CallSiteEntry: " << MF.getName() << " -> " << (CalleeDecl ? CalleeDecl->getName() : StringRef(MF.getSubtarget() @@ -1002,13 +1012,7 @@ DIE &CallSiteDIE = CU.constructCallSiteEntryDIE( ScopeDIE, CalleeDIE, IsTail, PCAddr, CallAddr, CallReg); - // Optionally emit call-site-param debug info. - if (emitDebugEntryValues()) { - ParamSet Params; - // Try to interpret values of call site parameters. - collectCallSiteParameters(&MI, Params); - CU.constructCallSiteParmEntryDIEs(CallSiteDIE, Params); - } + CU.constructCallSiteParmEntryDIEs(CallSiteDIE, Params); } } } diff --git a/llvm/test/DebugInfo/X86/dwarf-empty_callsite.ll b/llvm/test/DebugInfo/X86/dwarf-empty_callsite.ll new file mode 100644 --- /dev/null +++ b/llvm/test/DebugInfo/X86/dwarf-empty_callsite.ll @@ -0,0 +1,145 @@ +;; Check DW_TAG_GNU_call_site without DW_TAG_GNU_call_site_parameter is not created. +; REQUIRES: x86_64-linux + +; RUN: llc -emit-call-site-info -filetype=obj %s -o - | llvm-dwarfdump - | FileCheck %s + +; CHECK-NOT: DW_TAG_GNU_call_site + +;; The IR is generated from below source program +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; +;;subroutine fun (array) +;; integer :: array (*) +;; +;; array(5:10) = 1311 +;; array(7) = 1 +;; array(100) = 100 +;; return +;;end subroutine +;; +;;program vla +;; interface +;; subroutine fun (array) +;; integer :: array (*) +;; end subroutine +;; end interface +;; integer :: sub_arr(42) +;; +;; sub_arr(:) = 3 +;; call fun(sub_arr) +;;end program vla +;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; + +; ModuleID = '/tmp/empty_callsite.ll' +source_filename = "/tmp/empty_callsite.ll" +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +%struct.BSS2 = type <{ [168 x i8] }> + +@.BSS2 = internal global %struct.BSS2 zeroinitializer, align 32, !dbg !0 +@.C330_MAIN_ = internal constant i32 0 + +; Function Attrs: nofree norecurse nounwind writeonly +define void @fun_(i64* noalias nocapture %array) local_unnamed_addr !dbg !15 { +L.entry: + call void @llvm.dbg.declare(metadata i64* %array, metadata !21, metadata !DIExpression()), !dbg !22 + call void @llvm.dbg.value(metadata i64 5, metadata !23, metadata !DIExpression()), !dbg !22 + %0 = bitcast i64* %array to i8* + %1 = getelementptr i8, i8* %0, i64 -4 + %2 = bitcast i8* %1 to i32* + br label %L.LB1_362 + +L.LB1_362: ; preds = %L.LB1_362, %L.entry + %"i$a_360.0" = phi i64 [ 5, %L.entry ], [ %4, %L.LB1_362 ], !dbg !25 + call void @llvm.dbg.value(metadata i64 %"i$a_360.0", metadata !23, metadata !DIExpression()), !dbg !22 + call void @llvm.dbg.value(metadata i64 %"i$a_360.0", metadata !26, metadata !DIExpression()), !dbg !22 + %3 = getelementptr i32, i32* %2, i64 %"i$a_360.0", !dbg !25 + store i32 1311, i32* %3, align 4, !dbg !25 + call void @llvm.dbg.value(metadata i64 %"i$a_360.0", metadata !27, metadata !DIExpression()), !dbg !22 + %4 = add nuw nsw i64 %"i$a_360.0", 1, !dbg !25 + call void @llvm.dbg.value(metadata i64 %4, metadata !23, metadata !DIExpression()), !dbg !22 + %exitcond.not = icmp eq i64 %4, 11, !dbg !25 + br i1 %exitcond.not, label %L.LB1_387, label %L.LB1_362, !dbg !25 + +L.LB1_387: ; preds = %L.LB1_362 + %5 = getelementptr i64, i64* %array, i64 3, !dbg !28 + %6 = bitcast i64* %5 to i32*, !dbg !28 + store i32 1, i32* %6, align 4, !dbg !28 + %7 = getelementptr i8, i8* %0, i64 396, !dbg !29 + %8 = bitcast i8* %7 to i32*, !dbg !29 + store i32 100, i32* %8, align 4, !dbg !29 + ret void, !dbg !30 +} + +define void @MAIN_() local_unnamed_addr !dbg !2 { +L.entry: + call void (i8*, ...) bitcast (void (...)* @fort_init to void (i8*, ...)*)(i8* bitcast (i32* @.C330_MAIN_ to i8*)) + call void @llvm.dbg.value(metadata i64 1, metadata !31, metadata !DIExpression()), !dbg !32 + br label %L.LB2_359 + +L.LB2_359: ; preds = %L.LB2_359, %L.entry + %"i$a_356.0" = phi i64 [ 1, %L.entry ], [ %1, %L.LB2_359 ], !dbg !33 + call void @llvm.dbg.value(metadata i64 %"i$a_356.0", metadata !31, metadata !DIExpression()), !dbg !32 + call void @llvm.dbg.value(metadata i64 %"i$a_356.0", metadata !34, metadata !DIExpression()), !dbg !32 + %0 = getelementptr i32, i32* bitcast (i8* getelementptr (i8, i8* getelementptr inbounds (%struct.BSS2, %struct.BSS2* @.BSS2, i64 0, i32 0, i64 0), i64 -4) to i32*), i64 %"i$a_356.0", !dbg !33 + store i32 3, i32* %0, align 4, !dbg !33 + call void @llvm.dbg.value(metadata i64 %"i$a_356.0", metadata !35, metadata !DIExpression()), !dbg !32 + %1 = add nuw nsw i64 %"i$a_356.0", 1, !dbg !33 + call void @llvm.dbg.value(metadata i64 %1, metadata !31, metadata !DIExpression()), !dbg !32 + %exitcond.not = icmp eq i64 %1, 43, !dbg !33 + br i1 %exitcond.not, label %L.LB2_376, label %L.LB2_359, !dbg !33 + +L.LB2_376: ; preds = %L.LB2_359 + call void @fun_(i64* bitcast (%struct.BSS2* @.BSS2 to i64*)), !dbg !36 + ret void, !dbg !37 +} + +declare void @fort_init(...) local_unnamed_addr + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.declare(metadata, metadata, metadata) + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) + +!llvm.module.flags = !{!13, !14} +!llvm.dbg.cu = !{!4} + +!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) +!1 = distinct !DIGlobalVariable(name: "sub_arr", linkageName: ".BSS2", scope: !2, file: !3, line: 16, type: !9, isLocal: true, isDefinition: true) +!2 = distinct !DISubprogram(name: "vla", scope: !4, file: !3, line: 10, type: !7, scopeLine: 10, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized | DISPFlagMainSubprogram, unit: !4) +!3 = !DIFile(filename: "empty_callsite.f90", directory: "/home/alok/openllvm/llvm-project_2/build.shared.d") +!4 = distinct !DICompileUnit(language: DW_LANG_Fortran90, file: !3, producer: " F90 Flang - 1.5 2017-05-01", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !5, retainedTypes: !5, globals: !6, imports: !5, nameTableKind: None) +!5 = !{} +!6 = !{!0} +!7 = !DISubroutineType(cc: DW_CC_program, types: !8) +!8 = !{null} +!9 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, size: 1344, align: 32, elements: !11) +!10 = !DIBasicType(name: "integer", size: 32, align: 32, encoding: DW_ATE_signed) +!11 = !{!12} +!12 = !DISubrange(lowerBound: 1, upperBound: 42) +!13 = !{i32 2, !"Dwarf Version", i32 4} +!14 = !{i32 2, !"Debug Info Version", i32 3} +!15 = distinct !DISubprogram(name: "fun", scope: !4, file: !3, line: 1, type: !16, scopeLine: 1, flags: DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !4) +!16 = !DISubroutineType(types: !17) +!17 = !{null, !18} +!18 = !DICompositeType(tag: DW_TAG_array_type, baseType: !10, align: 32, elements: !19) +!19 = !{!20} +!20 = !DISubrange(lowerBound: 1) +!21 = !DILocalVariable(name: "array", arg: 1, scope: !15, file: !3, line: 1, type: !18) +!22 = !DILocation(line: 0, scope: !15) +!23 = distinct !DILocalVariable(scope: !15, file: !3, line: 4, type: !24, flags: DIFlagArtificial) +!24 = !DIBasicType(name: "integer*8", size: 64, align: 64, encoding: DW_ATE_signed) +!25 = !DILocation(line: 4, column: 1, scope: !15) +!26 = distinct !DILocalVariable(scope: !15, file: !3, line: 4, type: !24, flags: DIFlagArtificial) +!27 = distinct !DILocalVariable(scope: !15, file: !3, line: 4, type: !24, flags: DIFlagArtificial) +!28 = !DILocation(line: 5, column: 1, scope: !15) +!29 = !DILocation(line: 6, column: 1, scope: !15) +!30 = !DILocation(line: 8, column: 1, scope: !15) +!31 = distinct !DILocalVariable(scope: !2, file: !3, line: 18, type: !24, flags: DIFlagArtificial) +!32 = !DILocation(line: 0, scope: !2) +!33 = !DILocation(line: 18, column: 1, scope: !2) +!34 = distinct !DILocalVariable(scope: !2, file: !3, line: 18, type: !24, flags: DIFlagArtificial) +!35 = distinct !DILocalVariable(scope: !2, file: !3, line: 18, type: !24, flags: DIFlagArtificial) +!36 = !DILocation(line: 19, column: 1, scope: !2) +!37 = !DILocation(line: 20, column: 1, scope: !2)