<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:"Malgun Gothic";
        panose-1:2 11 5 3 2 0 0 2 0 4;}
@font-face
        {font-family:"\@Malgun Gothic";}
@font-face
        {font-family:Menlo-Regular;
        panose-1:0 0 0 0 0 0 0 0 0 0;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:blue;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:purple;
        text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
        {mso-style-name:msonormal;
        mso-margin-top-alt:auto;
        margin-right:0in;
        mso-margin-bottom-alt:auto;
        margin-left:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.apple-converted-space
        {mso-style-name:apple-converted-space;}
span.EmailStyle19
        {mso-style-type:personal-reply;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="blue" vlink="purple">
<div class="WordSection1">
<p class="MsoNormal">Thanks! It looks like SelectionDAG::salvageDebugInfo handles only addition with constant.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Sejong<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<div style="border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal"><b>From:</b> aprantl@apple.com <aprantl@apple.com> <br>
<b>Sent:</b> Monday, April 30, 2018 1:53 PM<br>
<b>To:</b> Se Jong Oh <sejooh@microsoft.com><br>
<b>Cc:</b> jdevlieghere@apple.com; Vedant Kumar <vsk@apple.com>; llvm-dev@lists.llvm.org; pidgeot18@gmail.com<br>
<b>Subject:</b> Re: [llvm-dev] [SelectionDAG] DbgValue nodes aren't transferred<o:p></o:p></p>
</div>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal">On Apr 30, 2018, at 1:49 PM, Se Jong Oh <<a href="mailto:sejooh@microsoft.com">sejooh@microsoft.com</a>> wrote:<o:p></o:p></p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">Hi Jonas,<br>
<br>
I have another case that DBG_VALUE is not produced. I would appreciate it if you could take a quick look at the testcase below.<br>
<br>
<br>
test code:<br>
<br>
llc -mtriple=aarch64 -stop-after=livedebugvalues -o - test.ll<br>
<br>
; Function Attrs: nounwind ssp uwtable<br>
define void @f() #0 !dbg !4 {<br>
entry:<br>
 tail call void @h(i16 0) #2, !dbg !14<br>
 %call = tail call i16 (...) @g() #2, !dbg !15<br>
 tail call void @llvm.dbg.value(metadata i16 %call, metadata !8, metadata !16), !dbg !17<br>
 tail call void @h(i16 %call) #2, !dbg !18<br>
 ret void, !dbg !19<br>
}<br>
<br>
For the second call, the AArch64 ISel lowering produces a 32-bit CopyFromReg from w0.<br>
<br>
 t18: ch,glue = AArch64ISD::CALL t15, TargetGlobalAddress:i64<i16 (...)* @g> 0, RegisterMask:Untyped, test.c:5:11<br>
 t19: ch,glue = callseq_end t18, TargetConstant:i64<0>, TargetConstant:i64<0>, t18:1, test.c:5:11<br>
 t20: i32,ch,glue = CopyFromReg t19, Register:i32 $w0, t19:1, test.c:5:11<br>
<br>
Then, TargetLowering::LowerCallTo adds a truncate node since the function return type is i16.<br>
<br>
t21: i16 = truncate t20, test.c:5:11<br>
<br>
When lowering the dbg.value intrinsic, a SDDbgValue node is attached to the truncate since it is the final result of the call.<span class="apple-converted-space"> </span><br>
<br>
Lowering the third call constructs any_extend(t21) for the 32-bit register type but optimizes out the truncate node by the following code, and it seems that the DbgValue node on the truncate is also lost.</span><o:p></o:p></p>
</div>
</blockquote>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">Without having looked at this in more detail: there is a facility called salvageDebugInfo that is supposed to be called on instructions and SDag nodes right before they are deleted and it attempts to attach the debug info of the dying node
 to another node in situations where this is possible and correct.<o:p></o:p></p>
</div>
<div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<div>
<p class="MsoNormal">-- adrian<o:p></o:p></p>
</div>
<p class="MsoNormal"><br>
<br>
<o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<div>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"><br>
SelectionDAG::getNode(...)<br>
...<br>
   // (ext (trunx x)) -> x<br>
   if (OpOpcode == ISD::TRUNCATE) {<br>
     SDValue OpOp = Operand.getOperand(0);<br>
     if (OpOp.getValueType() == VT)<br>
       return OpOp;<br>
   }<br>
<br>
I am wondering if we can just transfer the dbg node here or we can have a better solution.<br>
<br>
<br>
The entire test file is here:<br>
<br>
; ModuleID = 'test.ll'<br>
target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"<br>
target triple = "x86_64-apple-macosx"<br>
<br>
; Function Attrs: nounwind ssp uwtable<br>
define void @f() #0 !dbg !4 {<br>
entry:<br>
 tail call void @h(i16 0) #2, !dbg !14<br>
 %call = tail call i16 (...) @g() #2, !dbg !15<br>
 tail call void @llvm.dbg.value(metadata i16 %call, metadata !8, metadata !16), !dbg !17<br>
 tail call void @h(i16 %call) #2, !dbg !18<br>
 ret void, !dbg !19<br>
}<br>
<br>
declare void @h(i16)<br>
<br>
declare i16 @g(...)<br>
<br>
; Function Attrs: nounwind readnone<br>
declare void @llvm.dbg.value(metadata, metadata, metadata) #1<br>
<br>
attributes #0 = { nounwind ssp uwtable "no-frame-pointer-elim"="true" }<br>
attributes #1 = { nounwind readnone }<br>
attributes #2 = { nounwind }<br>
<br>
!llvm.dbg.cu = !{!0}<br>
!llvm.module.flags = !{!10, !11, !12}<br>
!llvm.ident = !{!13}<br>
<br>
!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 3.9.0 ", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2)<br>
!1 = !DIFile(filename: "test.c", directory: "/Volumes/Data/llvm")<br>
!2 = !{}<br>
!4 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 3, type: !5, isLocal: false, isDefinition: true, scopeLine: 3, isOptimized: true, unit: !0, variables: !7)<br>
!5 = !DISubroutineType(types: !6)<br>
!6 = !{null}<br>
!7 = !{!8}<br>
!8 = !DILocalVariable(name: "a", scope: !4, file: !1, line: 5, type: !9)<br>
!9 = !DIBasicType(name: "int", size: 32, align: 32, encoding: DW_ATE_signed)<br>
!10 = !{i32 2, !"Dwarf Version", i32 2}<br>
!11 = !{i32 2, !"Debug Info Version", i32 3}<br>
!12 = !{i32 1, !"PIC Level", i32 2}<br>
!13 = !{!"clang version 3.9.0 "}<br>
!14 = !DILocation(line: 4, column: 3, scope: !4)<br>
!15 = !DILocation(line: 5, column: 11, scope: !4)<br>
!16 = !DIExpression()<br>
!17 = !DILocation(line: 5, column: 7, scope: !4)<br>
!18 = !DILocation(line: 6, column: 3, scope: !4)<br>
!19 = !DILocation(line: 7, column: 1, scope: !4)<br>
<br>
<br>
Thanks,<br>
Sejong<br>
<br>
-----Original Message-----<br>
From:<span class="apple-converted-space"> </span></span><a href="mailto:jdevlieghere@apple.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">jdevlieghere@apple.com</span></a><span class="apple-converted-space"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"> </span></span><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"><</span><a href="mailto:jdevlieghere@apple.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">jdevlieghere@apple.com</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">><span class="apple-converted-space"> </span><br>
Sent: Thursday, March 15, 2018 8:43 AM<br>
To: Se Jong Oh <</span><a href="mailto:sejooh@microsoft.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">sejooh@microsoft.com</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">><br>
Cc: Vedant Kumar <</span><a href="mailto:vsk@apple.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">vsk@apple.com</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">>;<span class="apple-converted-space"> </span></span><a href="mailto:llvm-dev@lists.llvm.org"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">llvm-dev@lists.llvm.org</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">;
 Adrian Prantl <</span><a href="mailto:aprantl@apple.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">aprantl@apple.com</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">>;<span class="apple-converted-space"> </span></span><a href="mailto:pidgeot18@gmail.com"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">pidgeot18@gmail.com</span></a><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"><br>
Subject: Re: [llvm-dev] [SelectionDAG] DbgValue nodes aren't transferred<br>
<br>
<br>
<br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif">On Mar 14, 2018, at 7:55 PM, Se Jong Oh <<a href="mailto:sejooh@microsoft.com">sejooh@microsoft.com</a>> wrote:<br>
<br>
Hi Jonas,<br>
<br>
Thanks for taking a look! It makes linear-dbg-value.ll pass for my target by producing DEBUG_VALUEs correctly. I also tried a simple function with few operations and confirmed DEBUG_VALUEs which are not produced without trasferDbgValues in SetPromotedInteger.<o:p></o:p></span></p>
</blockquote>
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"><br>
That’s great news! Do you plan on creating a patch for this upstream?<span class="apple-converted-space"> </span><br>
<br style="caret-color: rgb(0, 0, 0);font-variant-caps: normal;text-align:start;-webkit-text-stroke-width: 0px;word-spacing:0px">
<br>
</span><o:p></o:p></p>
<blockquote style="margin-top:5.0pt;margin-bottom:5.0pt">
<p class="MsoNormal"><span style="font-size:9.0pt;font-family:"Menlo-Regular",serif"><br>
Thanks,<br>
Sejong<br>
<br>
From: <a href="mailto:jdevlieghere@apple.com">jdevlieghere@apple.com</a> <<a href="mailto:jdevlieghere@apple.com">jdevlieghere@apple.com</a>><span class="apple-converted-space"> </span><br>
Sent: Wednesday, March 14, 2018 4:07 AM<br>
To: Se Jong Oh <<a href="mailto:sejooh@microsoft.com">sejooh@microsoft.com</a>><br>
Cc: Vedant Kumar <<a href="mailto:vsk@apple.com">vsk@apple.com</a>>; <a href="mailto:llvm-dev@lists.llvm.org">
llvm-dev@lists.llvm.org</a>; Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>>;
<a href="mailto:pidgeot18@gmail.com">pidgeot18@gmail.com</a><br>
Subject: Re: [llvm-dev] [SelectionDAG] DbgValue nodes aren't transferred<br>
<br>
Hi Sejong,<br>
<br>
Indeed, I think you are right and we should call transferDbgValues in SetPromotedInteger.<br>
<br>
I couldn’t immediately find a suitable in-tree test to verify this though. Can you check and let me know whether this works for your target?<br>
<br>
Thanks,<br>
Jonas<br>
<br>
<br>
On Mar 13, 2018, at 7:45 PM, Se Jong Oh <<a href="mailto:sejooh@microsoft.com">sejooh@microsoft.com</a>> wrote:<br>
<br>
Thanks for help! I think that sign extension is not involved here. PromoteIntegerResult is called since i32 is not a legal type in my target and the legalizer promotes operations with i32 result type to i64 operations. I think that SetPromotedInteger seems
 to be a common place for all promotions like SetExpandedInteger.<br>
<br>
Jonas, I would appreciate it if you can guide me about whether my understanding is correct or not.<br>
<br>
Thanks,<br>
Sejong<br>
<br>
<br>
<br>
From: <a href="mailto:vsk@apple.com">vsk@apple.com</a> <<a href="mailto:vsk@apple.com">vsk@apple.com</a>><span class="apple-converted-space"> </span><br>
Sent: Friday, March 9, 2018 3:19 PM<br>
To: Se Jong Oh <<a href="mailto:sejooh@microsoft.com">sejooh@microsoft.com</a>><br>
Cc: <a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>; Jonas Devlieghere <<a href="mailto:jdevlieghere@apple.com">jdevlieghere@apple.com</a>>; Adrian Prantl <<a href="mailto:aprantl@apple.com">aprantl@apple.com</a>>;
<a href="mailto:pidgeot18@gmail.com">pidgeot18@gmail.com</a><br>
Subject: Re: [llvm-dev] [SelectionDAG] DbgValue nodes aren't transferred<br>
<br>
+ Adrian, Joshua<br>
+ Jonas, since he contributed the transferDbgValues change in DAGTypeLegalizer::SetExpandedInteger<br>
<br>
On Mar 8, 2018, at 5:44 PM, Se Jong Oh via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br>
<br>
Hi,<br>
<br>
I have a problem that dbg_value nodes are not transferred when integer DAG nodes are promoted. For example, an i32 add node is promoted to a i64 add node by DAGTypeLegalizer::PromoteIntegerResult and its dbg_value node is not transferred to the new node.<span class="apple-converted-space"> </span><br>
<br>
t9: i32 = add nsw t5, t8 à  t31: i64 = add t30, t7   ; the dbg_value node is not transferred to the new i64 add node.<br>
<br>
For expansion, DAGTypeLegalizer::SetExpandedInteger calls transferDbgValues() but I couldn’t find any place to call trasnferDbgValues() for integer type promotion in DAGTypeLegalizer ::SetPromotedInteger and other places.<br>
<br>
Maybe the right place to do this is within the PromoteIntRes_ helper for sign extensions?<br>
<br>
best,<br>
vedant<br>
<br>
<br>
<br>
I am wondering If I miss anything or the legalization needs to call transferDbgValues() for this case.<br>
<br>
I found this problem because a recently added unittest, DebugInfo/X86/linear-dbg-value.ll fails for my project, and the x86 and aarch64 backends don’t have this problem since they don’t promote i32 add nodes.<br>
<br>
Thanks,<br>
Sejong<br>
<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=04%7C01%7Csejooh%40microsoft.com%7C1334821c889d440e50ae08d58a8b6a62%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636567253755049370%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1&sdata=dmkgOHDLY6YWx1SISIdOg8a%2BC5hpT3mITrZZGwV715E%3D&reserved=0">https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Flists.llvm.org%2Fcgi-bin%2Fmailman%2Flistinfo%2Fllvm-dev&data=04%7C01%7Csejooh%40microsoft.com%7C1334821c889d440e50ae08d58a8b6a62%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636567253755049370%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwifQ%3D%3D%7C-1&sdata=dmkgOHDLY6YWx1SISIdOg8a%2BC5hpT3mITrZZGwV715E%3D&reserved=0</a><o:p></o:p></span></p>
</blockquote>
</div>
</blockquote>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>