[PATCH] D144472: [InstCombine][debuginfo] Update valueCoversEntireFragment for fixed size fragment and scalable value.

Yeting Kuo via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 21 04:06:55 PST 2023


fakepaper56 created this revision.
fakepaper56 added reviewers: efriedma, paulwalker-arm, sdesmalen, fpetrogalli, aprantl, huihuiz, bsmith.
Herald added a subscriber: hiraditya.
Herald added a project: All.
fakepaper56 requested review of this revision.
Herald added subscribers: llvm-commits, alextsao1999.
Herald added a project: LLVM.

Update valueCoversEntireFragment to handle new case and add regression test.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D144472

Files:
  llvm/lib/Transforms/Utils/Local.cpp
  llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll


Index: llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/InstCombine/dbg-scalable-store-fixed-frag.ll
@@ -0,0 +1,33 @@
+; RUN: opt < %s -passes='instcombine' -S
+
+define void @foo(<vscale x 2 x i32> %x) {
+entry:
+  %arr = alloca [4 x i32], align 4
+  call void @llvm.dbg.declare(metadata ptr %arr, metadata !8, metadata !DIExpression()), !dbg !14
+  store volatile <vscale x 2 x i32> %x, ptr %arr, align 4
+  ret void
+}
+
+; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
+
+attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!3, !4, !5, !6, !7}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus_14, file: !1, producer: "clang version 17.0.0 (git at github.com:llvm/llvm-project.git a489e11439e36c7e0ec83b28a6fb1596a5c21faa)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, retainedTypes: !2, splitDebugInlining: false, nameTableKind: None)
+!1 = !DIFile(filename: "u.cpp", directory: "/home/yeting", checksumkind: CSK_MD5, checksum: "42f62c17fb0f0110f515890bc6d69cb5")
+!2 = !{}
+!3 = !{i32 7, !"Dwarf Version", i32 5}
+!4 = !{i32 2, !"Debug Info Version", i32 3}
+!5 = !{i32 1, !"wchar_size", i32 4}
+!6 = !{i32 1, !"target-abi", !"lp64d"}
+!7 = !{i32 8, !"SmallDataLimit", i32 8}
+!8 = !DILocalVariable(name: "arr", scope: !9, file: !1, line: 3, type: !12)
+!9 = distinct !DISubprogram(name: "foo", linkageName: "_Z3foou15__rvv_int32m1_t", scope: !1, file: !1, line: 2, type: !10, scopeLine: 2, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !2)
+!10 = !DISubroutineType(types: !11)
+!11 = !{null}
+!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !13, size: 128, elements: !2)
+!13 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!14 = !DILocation(line: 3, column: 7, scope: !9)
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1494,11 +1494,10 @@
 static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
   const DataLayout &DL = DII->getModule()->getDataLayout();
   TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
-  if (std::optional<uint64_t> FragmentSize = DII->getFragmentSizeInBits()) {
-    assert(!ValueSize.isScalable() &&
-           "Fragments don't work on scalable types.");
-    return ValueSize.getFixedValue() >= *FragmentSize;
-  }
+  if (std::optional<uint64_t> FragmentSize = DII->getFragmentSizeInBits())
+    return !ValueSize.isScalable() &&
+           ValueSize.getFixedValue() >= *FragmentSize;
+
   // We can't always calculate the size of the DI variable (e.g. if it is a
   // VLA). Try to use the size of the alloca that the dbg intrinsic describes
   // intead.


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D144472.499108.patch
Type: text/x-patch
Size: 3121 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230221/31655d36/attachment.bin>


More information about the llvm-commits mailing list