[PATCH] D112829: [RISCV][DebugInfo] fix crash

Luke via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 29 09:30:46 PDT 2021


luke957 created this revision.
luke957 added reviewers: craig.topper, frasercrmck.
Herald added subscribers: VincentWu, achieveartificialintelligence, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, shiva0217, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, asb, hiraditya.
luke957 requested review of this revision.
Herald added subscribers: llvm-commits, MaskRay.
Herald added a project: LLVM.

Fix crash when processing debug info.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D112829

Files:
  llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
  llvm/lib/Target/RISCV/RISCVRegisterInfo.h
  llvm/test/CodeGen/RISCV/rvv/rvv-debuginfo.ll


Index: llvm/test/CodeGen/RISCV/rvv/rvv-debuginfo.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/RISCV/rvv/rvv-debuginfo.ll
@@ -0,0 +1,46 @@
+; RUN: llc -mtriple=riscv64 -mattr=+experimental-v -riscv-v-vector-bits-min=128 \
+; RUN:     -verify-machineinstrs < %s | FileCheck %s
+
+; CHECK: .section	.debug_info
+
+; Function Attrs: noinline nounwind optnone
+define dso_local <vscale x 8 x i16> @f1() #0 !dbg !9 {
+entry:
+  %ret = alloca <vscale x 8 x i16>, align 2
+  call void @llvm.dbg.declare(metadata <vscale x 8 x i16>* %ret, metadata !18, metadata !DIExpression()), !dbg !19
+  %0 = load <vscale x 8 x i16>, <vscale x 8 x i16>* %ret, align 2, !dbg !20
+  ret <vscale x 8 x i16> %0, !dbg !21
+}
+
+; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
+
+attributes #0 = { noinline nounwind optnone "frame-pointer"="all" "min-legal-vector-width"="128" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-features"="+64bit,+a,+c,+d,+experimental-v,+experimental-zvlsseg,+f,+m,+relax,-save-restore" }
+attributes #1 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2, !3, !4, !5, !6, !7}
+!llvm.ident = !{!8}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 14.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "test.c", directory: "llvm-project")
+!2 = !{i32 7, !"Dwarf Version", i32 4}
+!3 = !{i32 2, !"Debug Info Version", i32 3}
+!4 = !{i32 1, !"wchar_size", i32 4}
+!5 = !{i32 1, !"target-abi", !"lp64d"}
+!6 = !{i32 7, !"frame-pointer", i32 2}
+!7 = !{i32 1, !"SmallDataLimit", i32 8}
+!8 = !{!"clang version 14.0.0"}
+!9 = distinct !DISubprogram(name: "f1", scope: !1, file: !1, line: 6, type: !10, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !17)
+!10 = !DISubroutineType(types: !11)
+!11 = !{!12}
+!12 = !DIDerivedType(tag: DW_TAG_typedef, name: "__rvv_int16m2_t", file: !1, baseType: !13)
+!13 = !DICompositeType(tag: DW_TAG_array_type, baseType: !14, flags: DIFlagVector, elements: !15)
+!14 = !DIBasicType(name: "short", size: 16, encoding: DW_ATE_signed)
+!15 = !{!16}
+!16 = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_bregx, 7202, 0, DW_OP_constu, 2, DW_OP_div, DW_OP_constu, 2, DW_OP_mul))
+!17 = !{}
+!18 = !DILocalVariable(name: "ret", scope: !9, file: !1, line: 7, type: !12)
+!19 = !DILocation(line: 7, column: 19, scope: !9)
+!20 = !DILocation(line: 8, column: 10, scope: !9)
+!21 = !DILocation(line: 8, column: 3, scope: !9)
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.h
===================================================================
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.h
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.h
@@ -63,6 +63,9 @@
   const TargetRegisterClass *
   getLargestLegalSuperClass(const TargetRegisterClass *RC,
                             const MachineFunction &) const override;
+
+  void getOffsetOpcodes(const StackOffset &Offset,
+                        SmallVectorImpl<uint64_t> &Ops) const override;
 };
 }
 
Index: llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
+++ llvm/lib/Target/RISCV/RISCVRegisterInfo.cpp
@@ -20,6 +20,7 @@
 #include "llvm/CodeGen/RegisterScavenging.h"
 #include "llvm/CodeGen/TargetFrameLowering.h"
 #include "llvm/CodeGen/TargetInstrInfo.h"
+#include "llvm/IR/DebugInfoMetadata.h"
 #include "llvm/Support/ErrorHandling.h"
 
 #define GET_REGINFO_TARGET_DESC
@@ -320,3 +321,9 @@
     return &RISCV::VRRegClass;
   return RC;
 }
+
+void RISCVRegisterInfo::getOffsetOpcodes(const StackOffset &Offset,
+                                         SmallVectorImpl<uint64_t> &Ops) const {
+  // FIXME: Need to check Offset.getScalable()
+  DIExpression::appendOffset(Ops, Offset.getFixed());
+}


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D112829.383393.patch
Type: text/x-patch
Size: 4083 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211029/fbd535cf/attachment.bin>


More information about the llvm-commits mailing list