Index: clang/lib/Frontend/CompilerInvocation.cpp =================================================================== --- clang/lib/Frontend/CompilerInvocation.cpp +++ clang/lib/Frontend/CompilerInvocation.cpp @@ -1661,7 +1661,8 @@ const llvm::Triple::ArchType DebugEntryValueArchs[] = { llvm::Triple::x86, llvm::Triple::x86_64, llvm::Triple::aarch64, llvm::Triple::arm, llvm::Triple::armeb, llvm::Triple::mips, - llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el}; + llvm::Triple::mipsel, llvm::Triple::mips64, llvm::Triple::mips64el, + llvm::Triple::riscv32, llvm::Triple::riscv64}; if (Opts.OptimizationLevel > 0 && Opts.hasReducedDebugInfo() && llvm::is_contained(DebugEntryValueArchs, T.getArch())) Index: llvm/lib/Target/RISCV/RISCVISelLowering.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVISelLowering.cpp +++ llvm/lib/Target/RISCV/RISCVISelLowering.cpp @@ -8985,6 +8985,9 @@ MachineFunction &MF = DAG.getMachineFunction(); + // Call site info for function parameters tracking. + MachineFunction::CallSiteInfo CSInfo; + // Analyze the operands of the call, assigning locations to each operand. SmallVector ArgLocs; CCState ArgCCInfo(CallConv, IsVarArg, MF, ArgLocs, *DAG.getContext()); @@ -9134,6 +9137,11 @@ if (VA.isRegLoc()) { // Queue up the argument copies and emit them at the end. RegsToPass.push_back(std::make_pair(VA.getLocReg(), ArgValue)); + + const TargetOptions &Options = DAG.getTarget().Options; + if (Options.SupportsDebugEntryValues) + CSInfo.emplace_back(VA.getLocReg(), i); + continue; } else { assert(VA.isMemLoc() && "Argument not register or memory"); assert(!IsTailCall && "Tail call not allowed if stack is used " @@ -9222,13 +9230,17 @@ if (IsTailCall) { MF.getFrameInfo().setHasTailCall(); - return DAG.getNode(RISCVISD::TAIL, DL, NodeTys, Ops); + SDValue Ret = DAG.getNode(RISCVISD::TAIL, DL, NodeTys, Ops); + DAG.addCallSiteInfo(Ret.getNode(), std::move(CSInfo)); + return Ret; } Chain = DAG.getNode(RISCVISD::CALL, DL, NodeTys, Ops); DAG.addNoMergeSiteInfo(Chain.getNode(), CLI.NoMerge); Glue = Chain.getValue(1); + DAG.addCallSiteInfo(Chain.getNode(), std::move(CSInfo)); + // Mark the end of the call, which is glued to the call itself. Chain = DAG.getCALLSEQ_END(Chain, DAG.getConstant(NumBytes, DL, PtrVT, true), Index: llvm/lib/Target/RISCV/RISCVInstrInfo.h =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfo.h +++ llvm/lib/Target/RISCV/RISCVInstrInfo.h @@ -177,6 +177,12 @@ Optional> isRVVSpillForZvlsseg(unsigned Opcode) const; + Optional isAddImmediate(const MachineInstr &MI, + Register Reg) const override; + + Optional describeLoadedValue(const MachineInstr &MI, + Register Reg) const override; + protected: const RISCVSubtarget &STI; }; Index: llvm/lib/Target/RISCV/RISCVInstrInfo.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVInstrInfo.cpp +++ llvm/lib/Target/RISCV/RISCVInstrInfo.cpp @@ -25,6 +25,7 @@ #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/RegisterScavenging.h" +#include "llvm/IR/DebugInfoMetadata.h" #include "llvm/MC/MCInstBuilder.h" #include "llvm/MC/TargetRegistry.h" #include "llvm/Support/ErrorHandling.h" @@ -1899,3 +1900,176 @@ return std::make_pair(8u, 1u); } } + +Optional +RISCVInstrInfo::describeLoadedValue(const MachineInstr &MI, + Register Reg) const { + DIExpression *Expr = + DIExpression::get(MI.getMF()->getFunction().getContext(), {}); + + // TODO: Special RISCV instructions that need to be described separately. + if (auto RegImm = isAddImmediate(MI, Reg)) { + Register SrcReg = RegImm->Reg; + int64_t Offset = RegImm->Imm; + + // When SrcReg is $x0, treat loaded value as immediate only, $x0 is a zero + // register. Ex. $x10 = ADDI $x0, 10 + if (SrcReg == RISCV::X0) + return ParamLoadedValue(MachineOperand::CreateImm(Offset), Expr); + + Expr = DIExpression::prepend(Expr, DIExpression::ApplyOffset, Offset); + return ParamLoadedValue(MachineOperand::CreateReg(SrcReg, false), Expr); + } else if (auto DestSrc = isCopyInstr(MI)) { + const MachineFunction *MF = MI.getMF(); + const TargetRegisterInfo *TRI = MF->getSubtarget().getRegisterInfo(); + Register DestReg = DestSrc->Destination->getReg(); + // TODO: Handle cases where the Reg is sub- or super-register of the + // DestReg. + if (TRI->isSuperRegister(Reg, DestReg) || TRI->isSubRegister(Reg, DestReg)) + return None; + } + + return TargetInstrInfo::describeLoadedValue(MI, Reg); +} + +Optional RISCVInstrInfo::isAddImmediate(const MachineInstr &MI, + Register Reg) const { + const MachineOperand &Op0 = MI.getOperand(0); + if (!Op0.isReg() || Reg != Op0.getReg()) + return None; + + switch (MI.getOpcode()) { + case RISCV::ADDI: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isImm()) + return RegImmPair{Sop1.getReg(), Sop2.getImm()}; + break; + } + case RISCV::LUI: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + if (Dop.isReg() && Sop1.isImm()) + return RegImmPair{RISCV::X0, Sop1.getImm() << 12}; + break; + } + case RISCV::ANDI: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isImm()) + if (Sop1.getReg() == RISCV::X0 || Sop2.getImm() == (uint64_t)0) + return RegImmPair{RISCV::X0, (uint64_t)0}; + break; + } + case RISCV::ORI: + case RISCV::XORI: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isImm()) { + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{RISCV::X0, Sop2.getImm()}; + if (Sop2.getImm() == (uint64_t)0) + return RegImmPair{Sop1.getReg(), Sop2.getImm()}; + } + break; + } + case RISCV::SLLI: + case RISCV::SRLI: + case RISCV::SRAI: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isImm()) { + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{RISCV::X0, (uint64_t)0}; + if (Sop2.getImm() == (uint64_t)0) + return RegImmPair{Sop1.getReg(), Sop2.getImm()}; + } + break; + } + case RISCV::AND: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == Sop2.getReg()) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + if (Sop1.getReg() == RISCV::X0 || Sop2.getReg() == RISCV::X0) + return RegImmPair{RISCV::X0, (uint64_t)0}; + } + break; + } + case RISCV::OR: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == Sop2.getReg()) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{Sop2.getReg(), (uint64_t)0}; + if (Sop2.getReg() == RISCV::X0) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + } + break; + } + case RISCV::XOR: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == Sop2.getReg()) + return RegImmPair{RISCV::X0, (uint64_t)0}; + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{Sop2.getReg(), (uint64_t)0}; + if (Sop2.getReg() == RISCV::X0) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + } + break; + } + case RISCV::ADD: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == RISCV::X0 && Sop2.getReg() == RISCV::X0) + return RegImmPair{RISCV::X0, (uint64_t)0}; + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{Sop2.getReg(), (uint64_t)0}; + if (Sop2.getReg() == RISCV::X0) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + } + break; + } + case RISCV::SUB: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == Sop2.getReg()) + return RegImmPair{RISCV::X0, (uint64_t)0}; + if (Sop2.getReg() == RISCV::X0) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + } + break; + } + case RISCV::SLL: + case RISCV::SRL: + case RISCV::SRA: { + const MachineOperand &Dop = MI.getOperand(0); + const MachineOperand &Sop1 = MI.getOperand(1); + const MachineOperand &Sop2 = MI.getOperand(2); + if (Dop.isReg() && Sop1.isReg() && Sop2.isReg()) { + if (Sop1.getReg() == RISCV::X0) + return RegImmPair{RISCV::X0, (uint64_t)0}; + if (Sop2.getReg() == RISCV::X0) + return RegImmPair{Sop1.getReg(), (uint64_t)0}; + } + break; + } + } + return None; +} Index: llvm/lib/Target/RISCV/RISCVTargetMachine.cpp =================================================================== --- llvm/lib/Target/RISCV/RISCVTargetMachine.cpp +++ llvm/lib/Target/RISCV/RISCVTargetMachine.cpp @@ -71,6 +71,9 @@ // RISC-V supports the MachineOutliner. setMachineOutliner(true); + + // RISC-V supports the debug entry values. + setSupportsDebugEntryValues(true); } const RISCVSubtarget * Index: llvm/test/CodeGen/RISCV/call-site-info-output_riscv32.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/RISCV/call-site-info-output_riscv32.ll @@ -0,0 +1,145 @@ +; RUN: llc -mtriple=riscv32 -emit-call-site-info -stop-before=livedebugvalues %s -o - | FileCheck %s + +;; extern void fn1 (long int, long int, long int); +;; long int fn2 (long int a, long int b, long int c) +;; { +;; long int q = 2 * a; +;; fn1 (5, 6, 7); +;; return 0; +;; } +;; long int fn3 (long int x, long int (*fn4) (long int *)) +;; { +;; long int v, w, w2, z; +;; w = (*fn4) (&w2); +;; v = (*fn4) (&w2); +;; z = fn2 (1, v + 1, w); +;; { +;; int v1 = v + 4; +;; z += fn2 (w, v * 2, x); +;; } +;; return z; +;; } + +;; Test riscv32: +; CHECK: name: fn3 +; CHECK: callSites: +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: arg: 1, reg: '$x11' +; CHECK-NEXT: arg: 2, reg: '$x12' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: arg: 1, reg: '$x11' +; CHECK-NEXT: arg: 2, reg: '$x12' + +; ModuleID = '../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c' +source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" +target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" +target triple = "riscv32-unknown-linux-elf-unknown" + +; Function Attrs: noinline nounwind +define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 +} + +; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + +declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + +; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + +; Function Attrs: noinline nounwind +define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + +attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } +attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn } +attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } +attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } +attributes #4 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6, !7} +!llvm.ident = !{!8} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"target-abi", !"ilp32d"} +!7 = !{i32 1, !"SmallDataLimit", i32 8} +!8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} +!9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) +!10 = !DISubroutineType(types: !11) +!11 = !{!12, !12, !12, !12} +!12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) +!13 = !{!14, !15, !16, !17} +!14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) +!15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) +!16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) +!17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) +!18 = !DILocation(line: 0, scope: !9) +!19 = !DILocation(line: 5, column: 3, scope: !9) +!20 = !DILocation(line: 6, column: 3, scope: !9) +!21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) +!22 = !DISubroutineType(types: !23) +!23 = !{null, !12, !12, !12} +!24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) +!25 = !DISubroutineType(types: !26) +!26 = !{!12, !12, !27} +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) +!28 = !DISubroutineType(types: !29) +!29 = !{!12, !30} +!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) +!31 = !{!32, !33, !34, !35, !36, !37, !38} +!32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) +!33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) +!34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) +!35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) +!36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) +!37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) +!38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) +!39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) +!40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!41 = !DILocation(line: 0, scope: !24) +!42 = !DILocation(line: 10, column: 3, scope: !24) +!43 = !DILocation(line: 11, column: 7, scope: !24) +!44 = !DILocation(line: 12, column: 7, scope: !24) +!45 = !DILocation(line: 13, column: 7, scope: !24) +!46 = !DILocation(line: 0, scope: !39) +!47 = !DILocation(line: 16, column: 10, scope: !39) +!48 = !DILocation(line: 34, column: 1, scope: !24) +!49 = !DILocation(line: 33, column: 3, scope: !24) Index: llvm/test/CodeGen/RISCV/call-site-info-output_riscv64.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/RISCV/call-site-info-output_riscv64.ll @@ -0,0 +1,145 @@ +; RUN: llc -mtriple=riscv64 -emit-call-site-info -stop-before=livedebugvalues %s -o - | FileCheck %s + +;; extern void fn1 (long int, long int, long int); +;; long int fn2 (long int a, long int b, long int c) +;; { +;; long int q = 2 * a; +;; fn1 (5, 6, 7); +;; return 0; +;; } +;; long int fn3 (long int x, long int (*fn4) (long int *)) +;; { +;; long int v, w, w2, z; +;; w = (*fn4) (&w2); +;; v = (*fn4) (&w2); +;; z = fn2 (1, v + 1, w); +;; { +;; int v1 = v + 4; +;; z += fn2 (w, v * 2, x); +;; } +;; return z; +;; } + +;; Test riscv64: +; CHECK: name: fn3 +; CHECK: callSites: +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: arg: 1, reg: '$x11' +; CHECK-NEXT: arg: 2, reg: '$x12' +; CHECK-NEXT: bb: {{.*}}, offset: {{.*}}, fwdArgRegs: +; CHECK-NEXT: arg: 0, reg: '$x10' +; CHECK-NEXT: arg: 1, reg: '$x11' +; CHECK-NEXT: arg: 2, reg: '$x12' + +; ModuleID = '../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c' +source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" +target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" +target triple = "riscv64-unknown-linux-elf-unknown" + +; Function Attrs: noinline nounwind +define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 +} + +; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn +declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + +declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + +; Function Attrs: argmemonly mustprogress nofree nosync nounwind willreturn +declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + +; Function Attrs: noinline nounwind +define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 +} + +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn +declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + +attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } +attributes #1 = { argmemonly mustprogress nofree nosync nounwind willreturn } +attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } +attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } +attributes #4 = { nounwind } + +!llvm.dbg.cu = !{!0} +!llvm.module.flags = !{!3, !4, !5, !6, !7} +!llvm.ident = !{!8} + +!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) +!1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") +!2 = !{} +!3 = !{i32 7, !"Dwarf Version", i32 4} +!4 = !{i32 2, !"Debug Info Version", i32 3} +!5 = !{i32 1, !"wchar_size", i32 4} +!6 = !{i32 1, !"target-abi", !"lp64d"} +!7 = !{i32 1, !"SmallDataLimit", i32 8} +!8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} +!9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) +!10 = !DISubroutineType(types: !11) +!11 = !{!12, !12, !12, !12} +!12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) +!13 = !{!14, !15, !16, !17} +!14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) +!15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) +!16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) +!17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) +!18 = !DILocation(line: 0, scope: !9) +!19 = !DILocation(line: 5, column: 3, scope: !9) +!20 = !DILocation(line: 6, column: 3, scope: !9) +!21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) +!22 = !DISubroutineType(types: !23) +!23 = !{null, !12, !12, !12} +!24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) +!25 = !DISubroutineType(types: !26) +!26 = !{!12, !12, !27} +!27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) +!28 = !DISubroutineType(types: !29) +!29 = !{!12, !30} +!30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) +!31 = !{!32, !33, !34, !35, !36, !37, !38} +!32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) +!33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) +!34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) +!35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) +!36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) +!37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) +!38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) +!39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) +!40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) +!41 = !DILocation(line: 0, scope: !24) +!42 = !DILocation(line: 10, column: 3, scope: !24) +!43 = !DILocation(line: 11, column: 7, scope: !24) +!44 = !DILocation(line: 12, column: 7, scope: !24) +!45 = !DILocation(line: 13, column: 7, scope: !24) +!46 = !DILocation(line: 0, scope: !39) +!47 = !DILocation(line: 16, column: 10, scope: !39) +!48 = !DILocation(line: 34, column: 1, scope: !24) +!49 = !DILocation(line: 33, column: 3, scope: !24) Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-add-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-add-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000085 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000014) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x00000028) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ADD $x10, $x0, debug-location !19 + $x11 = ADD $x0, $x0, debug-location !19 + $x12 = ADD $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-add-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-add-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000091 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000014) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000028) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ADD $x10, $x0, debug-location !19 + $x11 = ADD $x0, $x0, debug-location !19 + $x12 = ADD $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-addi-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-addi-32bit.mir @@ -0,0 +1,263 @@ +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000081 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000012) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit7) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit6) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x00000026) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000002a) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ADDI $x0, 5, debug-location !19 + $x11 = ADDI $x0, 6, debug-location !19 + $x12 = ADDI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-addi-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-addi-64bit.mir @@ -0,0 +1,264 @@ +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008d "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000012) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit7) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit6) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000026) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002a) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ADDI $x0, 5, debug-location !19 + $x11 = ADDI $x0, 6, debug-location !19 + $x12 = ADDI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-and-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-and-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000081 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = AND $x10, $x0, debug-location !19 + $x11 = AND $x10, $x10, debug-location !19 + $x12 = AND $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-and-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-and-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008d "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = AND $x10, $x0, debug-location !19 + $x11 = AND $x10, $x10, debug-location !19 + $x12 = AND $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-andi-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-andi-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000081 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ANDI $x0, 5, debug-location !19 + $x11 = ANDI $x0, 6, debug-location !19 + $x12 = ANDI $x10, 0, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-andi-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-andi-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008d "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ANDI $x0, 5, debug-location !19 + $x11 = ANDI $x0, 6, debug-location !19 + $x12 = ANDI $x10, 0, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-lui-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-lui-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck -v --color %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008a "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000012) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x7000) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x6000) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x5000) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x00000026) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000002a) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = LUI 5, debug-location !19 + $x11 = LUI 6, debug-location !19 + $x12 = LUI 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-lui-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-lui-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000096 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000012) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x7000) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x6000) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_constu 0x5000) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000026) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002a) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = LUI 5, debug-location !19 + $x11 = LUI 6, debug-location !19 + $x12 = LUI 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-or-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-or-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000087 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = OR $x10, $x0, debug-location !19 + $x11 = OR $x10, $x10, debug-location !19 + $x12 = OR $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-or-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-or-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000093 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = OR $x10, $x0, debug-location !19 + $x11 = OR $x10, $x10, debug-location !19 + $x12 = OR $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-ori-xori-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-ori-xori-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000081 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit7) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ORI $x0, 5, debug-location !19 + $x11 = ORI $x10, 0, debug-location !19 + $x12 = XORI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-ori-xori-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-ori-xori-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008d "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit7) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit5) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = ORI $x0, 5, debug-location !19 + $x11 = ORI $x10, 0, debug-location !19 + $x12 = XORI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sll-srl-sra-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sll-srl-sra-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000083 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SLL $x10, $x0, debug-location !19 + $x11 = SRL $x0, $x11, debug-location !19 + $x12 = SRA $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sll-srl-sra-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sll-srl-sra-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008f "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SLL $x10, $x0, debug-location !19 + $x11 = SRL $x0, $x11, debug-location !19 + $x12 = SRA $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-slli-srli-srai-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-slli-srli-srai-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000083 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SLLI $x10, 0, debug-location !19 + $x11 = SRAI $x0, 6, debug-location !19 + $x12 = SRLI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-slli-srli-srai-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-slli-srli-srai-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008f "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SLLI $x10, 0, debug-location !19 + $x11 = SRAI $x0, 6, debug-location !19 + $x12 = SRLI $x0, 7, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sub-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sub-32bit.mir @@ -0,0 +1,262 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000007e "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SUB $x10, $x0, debug-location !19 + $x11 = SUB $x10, $x10, debug-location !19 + $x12 = SUB $x10, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sub-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-sub-64bit.mir @@ -0,0 +1,263 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x0000008a "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = SUB $x10, $x0, debug-location !19 + $x11 = SUB $x10, $x10, debug-location !19 + $x12 = SUB $x10, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-xor-32bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-xor-32bit.mir @@ -0,0 +1,265 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv32 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv32: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000085 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x00000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x0000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x00000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +4) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv32.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:32:32-i64:64-n32-S128" + target triple = "riscv32-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn2(i32 %0, i32 %1, i32 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i32 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i32 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i32 5, i32 6, i32 7) #4, !dbg !19 + ret i32 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i32, i32, i32) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i32 @fn3(i32 %0, i32 (i32*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i32, align 4 + call void @llvm.dbg.value(metadata i32 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 (i32*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i32* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 4, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i32* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i32 %1(i32* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i32 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i32 %1(i32* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i32 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !45 + call void @llvm.dbg.value(metadata i32 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i32 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value)), !dbg !46 + %8 = call i32 @fn2(i32 undef, i32 undef, i32 undef), !dbg !47 + call void @llvm.dbg.value(metadata i32 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 4, i8* nonnull %4) #4, !dbg !48 + ret i32 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"ilp32d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 32, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 32) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 32) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12, debug-location !18 :: (store (s32) into %stack.0) + CFI_INSTRUCTION offset $x1, -4 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = XOR $x10, $x0, debug-location !19 + $x11 = XOR $x10, $x10, debug-location !19 + $x12 = XOR $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LW $x2, 12, debug-location !20 :: (load (s32) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -12, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -4, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -8, size: 4, alignment: 4, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SW killed $x1, $x2, 12 :: (store (s32) into %stack.1) + SW killed $x8, $x2, 8 :: (store (s32) into %stack.2) + CFI_INSTRUCTION offset $x1, -4 + CFI_INSTRUCTION offset $x8, -8 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 4, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LW $x2, 8, debug-location !49 :: (load (s32) from %stack.2) + $x1 = LW $x2, 12, debug-location !49 :: (load (s32) from %stack.1) + $x2 = frame-destroy ADDI $x2, 16, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +... Index: llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-xor-64bit.mir =================================================================== --- /dev/null +++ llvm/test/DebugInfo/MIR/RISCV/dbg-call-site-param-xor-64bit.mir @@ -0,0 +1,266 @@ +## Hardcoding for testing purposes + +# RUN: llc -mtriple=riscv64 -emit-call-site-info -start-after=machineverifier -filetype=obj %s -o %t.o +# RUN: llvm-dwarfdump %t.o | FileCheck %s + + +## extern void fn1 (long int, long int, long int); +## long int fn2 (long int a, long int b, long int c) +## { +## long int q = 2 * a; +## fn1 (5, 6, 7); +## return 0; +## } +## long int fn3 (long int x, long int (*fn4) (long int *)) +## { +## long int v, w, w2, z; +## w = (*fn4) (&w2); +## v = (*fn4) (&w2); +## z = fn2 (1, v + 1, w); +## { +## int v1 = v + 4; +## z += fn2 (w, v * 2, x); +## } +## return z; +## } + +## Test riscv64: + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_abstract_origin (0x00000091 "fn1") +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000018) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_lit0) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg12 X12) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg12 X12)) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_GNU_entry_value(DW_OP_reg10 X10)) + +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg11 X11) +# CHECK-NEXT: DW_AT_low_pc (0x000000000000002c) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +# CHECK: DW_TAG_GNU_call_site +# CHECK-NEXT: DW_AT_GNU_call_site_target (DW_OP_reg8 X8) +# CHECK-NEXT: DW_AT_low_pc (0x0000000000000030) +# CHECK-EMPTY: +# CHECK-NEXT: DW_TAG_GNU_call_site_parameter +# CHECK-NEXT: DW_AT_location (DW_OP_reg10 X10) +# CHECK-NEXT: DW_AT_GNU_call_site_value (DW_OP_fbreg +8) +--- | + + ; ModuleID = '../llvm-project/llvm/test/DebugInfo/MIR/RISCV/dwarf_riscv64.ll' + source_filename = "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c" + target datalayout = "e-m:e-p:64:64-i64:64-i128:128-n64-S128" + target triple = "riscv64-unknown-linux-elf-unknown" + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn2(i64 %0, i64 %1, i64 %2) local_unnamed_addr #0 !dbg !9 { + call void @llvm.dbg.value(metadata i64 undef, metadata !14, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !15, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !16, metadata !DIExpression()), !dbg !18 + call void @llvm.dbg.value(metadata i64 undef, metadata !17, metadata !DIExpression()), !dbg !18 + tail call void @fn1(i64 5, i64 6, i64 7) #4, !dbg !19 + ret i64 0, !dbg !20 + } + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.start.p0i8(i64 immarg, i8* nocapture) #1 + + declare !dbg !21 dso_local void @fn1(i64, i64, i64) local_unnamed_addr #2 + + ; Function Attrs: argmemonly nofree nosync nounwind willreturn + declare void @llvm.lifetime.end.p0i8(i64 immarg, i8* nocapture) #1 + + ; Function Attrs: noinline nounwind + define dso_local i64 @fn3(i64 %0, i64 (i64*)* nocapture %1) local_unnamed_addr #0 !dbg !24 { + %3 = alloca i64, align 8 + call void @llvm.dbg.value(metadata i64 %0, metadata !32, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 (i64*)* %1, metadata !33, metadata !DIExpression()), !dbg !41 + %4 = bitcast i64* %3 to i8*, !dbg !42 + call void @llvm.lifetime.start.p0i8(i64 8, i8* nonnull %4) #4, !dbg !42 + call void @llvm.dbg.value(metadata i64* %3, metadata !36, metadata !DIExpression(DW_OP_deref)), !dbg !41 + %5 = call i64 %1(i64* nonnull %3) #4, !dbg !43 + call void @llvm.dbg.value(metadata i64 %5, metadata !35, metadata !DIExpression()), !dbg !41 + %6 = call i64 %1(i64* nonnull %3) #4, !dbg !44 + call void @llvm.dbg.value(metadata i64 %6, metadata !34, metadata !DIExpression()), !dbg !41 + %7 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !45 + call void @llvm.dbg.value(metadata i64 0, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.dbg.value(metadata i64 %6, metadata !38, metadata !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value)), !dbg !46 + %8 = call i64 @fn2(i64 undef, i64 undef, i64 undef), !dbg !47 + call void @llvm.dbg.value(metadata i64 -1, metadata !37, metadata !DIExpression()), !dbg !41 + call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %4) #4, !dbg !48 + ret i64 -1, !dbg !49 + } + + ; Function Attrs: nofree nosync nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) #3 + + attributes #0 = { noinline nounwind "frame-pointer"="none" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #1 = { argmemonly nofree nosync nounwind willreturn } + attributes #2 = { "frame-pointer"="none" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+f,+m,+relax,-save-restore" } + attributes #3 = { nofree nosync nounwind readnone speculatable willreturn } + attributes #4 = { nounwind } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!3, !4, !5, !6, !7} + !llvm.ident = !{!8} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "../llvm-project/llvm/test/CodeGen/RISCV/dwarf.c", directory: "/home/syrmia/FORK/buildReleaseMode") + !2 = !{} + !3 = !{i32 7, !"Dwarf Version", i32 4} + !4 = !{i32 2, !"Debug Info Version", i32 3} + !5 = !{i32 1, !"wchar_size", i32 4} + !6 = !{i32 1, !"target-abi", !"lp64d"} + !7 = !{i32 1, !"SmallDataLimit", i32 8} + !8 = !{!"clang version 13.0.0 (https://github.com/mmatic05/llvm-project.git 77c12b90754642b38e244a18477e3711a45cdf99)"} + !9 = distinct !DISubprogram(name: "fn2", scope: !1, file: !1, line: 3, type: !10, scopeLine: 3, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !13) + !10 = !DISubroutineType(types: !11) + !11 = !{!12, !12, !12, !12} + !12 = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + !13 = !{!14, !15, !16, !17} + !14 = !DILocalVariable(name: "a", arg: 1, scope: !9, file: !1, line: 3, type: !12) + !15 = !DILocalVariable(name: "b", arg: 2, scope: !9, file: !1, line: 3, type: !12) + !16 = !DILocalVariable(name: "c", arg: 3, scope: !9, file: !1, line: 3, type: !12) + !17 = !DILocalVariable(name: "q", scope: !9, file: !1, line: 4, type: !12) + !18 = !DILocation(line: 0, scope: !9) + !19 = !DILocation(line: 5, column: 3, scope: !9) + !20 = !DILocation(line: 6, column: 3, scope: !9) + !21 = !DISubprogram(name: "fn1", scope: !1, file: !1, line: 1, type: !22, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !22 = !DISubroutineType(types: !23) + !23 = !{null, !12, !12, !12} + !24 = distinct !DISubprogram(name: "fn3", scope: !1, file: !1, line: 9, type: !25, scopeLine: 9, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !31) + !25 = !DISubroutineType(types: !26) + !26 = !{!12, !12, !27} + !27 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !28, size: 64) + !28 = !DISubroutineType(types: !29) + !29 = !{!12, !30} + !30 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !31 = !{!32, !33, !34, !35, !36, !37, !38} + !32 = !DILocalVariable(name: "x", arg: 1, scope: !24, file: !1, line: 9, type: !12) + !33 = !DILocalVariable(name: "fn4", arg: 2, scope: !24, file: !1, line: 9, type: !27) + !34 = !DILocalVariable(name: "v", scope: !24, file: !1, line: 10, type: !12) + !35 = !DILocalVariable(name: "w", scope: !24, file: !1, line: 10, type: !12) + !36 = !DILocalVariable(name: "w2", scope: !24, file: !1, line: 10, type: !12) + !37 = !DILocalVariable(name: "z", scope: !24, file: !1, line: 10, type: !12) + !38 = !DILocalVariable(name: "v1", scope: !39, file: !1, line: 15, type: !40) + !39 = distinct !DILexicalBlock(scope: !24, file: !1, line: 14, column: 3) + !40 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !41 = !DILocation(line: 0, scope: !24) + !42 = !DILocation(line: 10, column: 3, scope: !24) + !43 = !DILocation(line: 11, column: 7, scope: !24) + !44 = !DILocation(line: 12, column: 7, scope: !24) + !45 = !DILocation(line: 13, column: 7, scope: !24) + !46 = !DILocation(line: 0, scope: !39) + !47 = !DILocation(line: 16, column: 10, scope: !39) + !48 = !DILocation(line: 34, column: 1, scope: !24) + !49 = !DILocation(line: 33, column: 3, scope: !24) + +... +--- +name: fn2 +alignment: 2 +liveins: [] +stack: + - { id: 0, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 11, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.3): + liveins: $x1 + + DBG_VALUE $noreg, $noreg, !14, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !15, !DIExpression(), debug-location !18 + DBG_VALUE $noreg, $noreg, !16, !DIExpression(), debug-location !18 + $x2 = frame-setup ADDI $x2, -16 + CFI_INSTRUCTION def_cfa_offset 16 + SD killed $x1, $x2, 8, debug-location !18 :: (store (s64) into %stack.0) + CFI_INSTRUCTION offset $x1, -8 + DBG_VALUE $noreg, $noreg, !17, !DIExpression(), debug-location !18 + $x10 = XOR $x10, $x0, debug-location !19 + $x11 = XOR $x10, $x10, debug-location !19 + $x12 = XOR $x0, $x12, debug-location !19 + PseudoCALL target-flags(riscv-call) @fn1, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit killed $x11, implicit killed $x12, implicit-def $x2, debug-location !19 + $x10 = ADDI $x0, 0, debug-location !20 + $x1 = LD $x2, 8, debug-location !20 :: (load (s64) from %stack.0) + $x2 = frame-destroy ADDI $x2, 16, debug-location !20 + PseudoRET implicit killed $x10, debug-location !20 + +... +--- +name: fn3 +alignment: 2 +liveins: + - { reg: '$x11', virtual-reg: '' } +stack: + - { id: 0, name: '', type: default, offset: -24, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 1, name: '', type: spill-slot, offset: -8, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x1', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } + - { id: 2, name: '', type: spill-slot, offset: -16, size: 8, alignment: 8, + stack-id: default, callee-saved-register: '$x8', callee-saved-restored: true, + debug-info-variable: '', debug-info-expression: '', debug-info-location: '' } +callSites: + - { bb: 0, offset: 13, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 16, fwdArgRegs: + - { arg: 0, reg: '$x10' } } + - { bb: 0, offset: 19, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } + - { bb: 0, offset: 21, fwdArgRegs: + - { arg: 0, reg: '$x10' } + - { arg: 1, reg: '$x11' } + - { arg: 2, reg: '$x12' } } +body: | + bb.0 (%ir-block.2): + liveins: $x11, $x1, $x8 + + DBG_VALUE $x10, $noreg, !32, !DIExpression(), debug-location !41 + DBG_VALUE $x11, $noreg, !33, !DIExpression(), debug-location !41 + $x2 = frame-setup ADDI $x2, -32 + CFI_INSTRUCTION def_cfa_offset 32 + SD killed $x1, $x2, 24 :: (store (s64) into %stack.1) + SD killed $x8, $x2, 16 :: (store (s64) into %stack.2) + CFI_INSTRUCTION offset $x1, -8 + CFI_INSTRUCTION offset $x8, -16 + $x8 = ADDI $x11, 0 + DBG_VALUE $x2, $noreg, !36, !DIExpression(DW_OP_plus_uconst, 8, DW_OP_deref), debug-location !41 + DBG_VALUE $x8, $noreg, !33, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !43 + DBG_VALUE $x10, $noreg, !32, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !41 + PseudoCALLIndirect $x11, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !43 + DBG_VALUE $noreg, $noreg, !35, !DIExpression(), debug-location !41 + $x10 = ADDI $x2, 8, debug-location !44 + PseudoCALLIndirect killed renamable $x8, csr_ilp32d_lp64d, implicit-def dead $x1, implicit killed $x10, implicit-def $x2, implicit-def dead $x10, debug-location !44 + DBG_VALUE $noreg, $noreg, !38, !DIExpression(DW_OP_plus_uconst, 4, DW_OP_LLVM_convert, 64, DW_ATE_unsigned, DW_OP_LLVM_convert, 32, DW_ATE_unsigned, DW_OP_stack_value), debug-location !46 + DBG_VALUE $noreg, $noreg, !34, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !45 + DBG_VALUE 0, $noreg, !37, !DIExpression(), debug-location !41 + PseudoCALL target-flags(riscv-call) @fn2, csr_ilp32d_lp64d, implicit-def dead $x1, implicit undef $x10, implicit undef $x11, implicit undef $x12, implicit-def $x2, implicit-def dead $x10, debug-location !47 + DBG_VALUE -1, $noreg, !37, !DIExpression(), debug-location !41 + $x10 = ADDI $x0, -1, debug-location !49 + $x8 = LD $x2, 16, debug-location !49 :: (load (s64) from %stack.2) + $x1 = LD $x2, 24, debug-location !49 :: (load (s64) from %stack.1) + $x2 = frame-destroy ADDI $x2, 32, debug-location !49 + PseudoRET implicit killed $x10, debug-location !49 + +...