[PATCH] D124691: [Transforms] Fix a wrong debug info intrinsic call in `mem2reg` pass for ref 128-bit
Dmitry Vassiliev via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun May 15 16:23:58 PDT 2022
slydiman updated this revision to Diff 429577.
slydiman added a comment.
I have simplified the test and made it generic.
I tried to update the size of DIDerivedType in llvm/lib/AsmParser/LLParser.cpp:
bool LLParser::parseDIDerivedType(MDNode *&Result, bool IsDistinct) {
...
if (tag.Val == dwarf::DW_TAG_reference_type && size.Val == 0)
size = M->getDataLayout().getPointerSizeInBits();
Result = GET_OR_DISTINCT(DIDerivedType,
(Context, tag.Val, name.Val, file.Val, line.Val,
scope.Val, baseType.Val, size.Val, align.Val,
offset.Val, DWARFAddressSpace, flags.Val,
extraData.Val, annotations.Val));
return false;
}
It solved the problem too, but it caused the appearance of this field `size` for DIDerivedType in the output:
!10 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !4) -> !10 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !4, size: 64)
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D124691/new/
https://reviews.llvm.org/D124691
Files:
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/Util/int128-ref-debuginfo.ll
Index: llvm/test/Transforms/Util/int128-ref-debuginfo.ll
===================================================================
--- /dev/null
+++ llvm/test/Transforms/Util/int128-ref-debuginfo.ll
@@ -0,0 +1,33 @@
+; RUN: opt -mem2reg -S < %s | FileCheck %s
+
+target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-unknown-linux-gnu"
+
+; CHECK-LABEL: @test
+define void @test(i128* %ptr) {
+ %p = alloca i128*, align 8
+ store i128* %ptr, i128** %p, align 8
+; CHECK: call void @llvm.dbg.value(metadata i128* %ptr, metadata !7, metadata !DIExpression()), !dbg !11
+ call void @llvm.dbg.declare(metadata i128** %p, metadata !7, metadata !DIExpression()), !dbg !11
+ ret void
+}
+
+declare void @llvm.dbg.declare(metadata, metadata, metadata) #0
+
+attributes #0 = { nofree nosync nounwind readnone speculatable willreturn }
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!6}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "foo", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3)
+!1 = !DIFile(filename: "test.cu", directory: "/foo/bar")
+!2 = !{}
+!3 = !{!4}
+!4 = !DIDerivedType(tag: DW_TAG_typedef, name: "__int128_t", scope: !1, file: !1, baseType: !5)
+!5 = !DIBasicType(name: "__int128", size: 128, encoding: DW_ATE_signed)
+!6 = !{i32 1, !"Debug Info Version", i32 3}
+!7 = !DILocalVariable(name: "ptr", arg: 1, scope: !8, file: !1, line: 2, type: !10)
+!8 = distinct !DISubprogram(name: "test", linkageName: "test", scope: !1, file: !1, line: 5, type: !9, scopeLine: 5, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2)
+!9 = !DISubroutineType(types: !2)
+!10 = !DIDerivedType(tag: DW_TAG_reference_type, baseType: !4)
+!11 = !DILocation(line: 2, column: 3, scope: !8)
Index: llvm/lib/Transforms/Utils/Local.cpp
===================================================================
--- llvm/lib/Transforms/Utils/Local.cpp
+++ llvm/lib/Transforms/Utils/Local.cpp
@@ -1411,6 +1411,13 @@
static bool valueCoversEntireFragment(Type *ValTy, DbgVariableIntrinsic *DII) {
const DataLayout &DL = DII->getModule()->getDataLayout();
TypeSize ValueSize = DL.getTypeAllocSizeInBits(ValTy);
+
+ // If we are replacing a double indirection with a single-indirection, the
+ // fragment size could be (happens with reference params) that of the object
+ // but the pointer will only be 32/64 bits.
+ if (ValTy->isPointerTy())
+ return true;
+
if (Optional<uint64_t> FragmentSize = DII->getFragmentSizeInBits()) {
assert(!ValueSize.isScalable() &&
"Fragments don't work on scalable types.");
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D124691.429577.patch
Type: text/x-patch
Size: 2667 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220515/2d183032/attachment.bin>
More information about the llvm-commits
mailing list