<div dir="ltr">I am developing a data-flow analysis optimization pass on the IR produced from a HIP program. But when I am trying to get the input Value of a CallInst calling GPU kernel like what we used to do on a CallInst of CPU function, I found that it's totally different.<div><br></div><div>First, all GPU kernel CallInst is like:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(86,156,214)">%</span><span style="color:rgb(86,156,214)">%105</span> = <span style="color:rgb(86,156,214)">call</span> <span style="color:rgb(86,156,214)">i32</span> <span style="color:rgb(86,156,214)">@hipLaunchKernel</span>(<span style="color:rgb(86,156,214)">i8*</span> <span style="color:rgb(86,156,214)">bitcast</span> (<span style="color:rgb(86,156,214)">void</span> (<span style="color:rgb(86,156,214)">float</span>*, <span style="color:rgb(86,156,214)">float</span>*, <span style="color:rgb(86,156,214)">float</span>*, <span style="color:rgb(86,156,214)">i32</span>, <span style="color:rgb(86,156,214)">i32</span>)* <span style="color:rgb(86,156,214)">@_Z30__device_stub__vectoradd_floatPfPKfS1_ii</span> <span style="color:rgb(86,156,214)">to</span> <span style="color:rgb(86,156,214)">i8*</span>), <span style="color:rgb(86,156,214)">i64</span> <span style="color:rgb(86,156,214)">%98</span>, <span style="color:rgb(86,156,214)">i32</span> <span style="color:rgb(86,156,214)">%100</span>, <span style="color:rgb(86,156,214)">i64</span> <span style="color:rgb(86,156,214)">%102</span>, <span style="color:rgb(86,156,214)">i32</span> <span style="color:rgb(86,156,214)">%104</span>, <span style="color:rgb(86,156,214)">i8**</span> nonnull <span style="color:rgb(86,156,214)">%83</span>, <span style="color:rgb(86,156,214)">i64</span> <span style="color:rgb(86,156,214)">%94</span>, <span style="color:rgb(86,156,214)">%struct.ihipStream_t*</span> <span style="color:rgb(86,156,214)">%96</span></div><div>  </div></div></blockquote><div><br></div><div>I cannot connect them with the variable which I defined to be used for the passed argument in HIP program via use-def chain.</div><div><br></div><div>Second, when I look further, some instructions producing these arguments which are involved in this callinst, has a context called !13, and they are like something below:</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(86,156,214)">%98</span> = <span style="color:rgb(86,156,214)">load</span> <span style="color:rgb(86,156,214)">i64</span>, <span style="color:rgb(86,156,214)">i64*</span> <span style="color:rgb(86,156,214)">%97</span>, <span style="color:rgb(86,156,214)">align</span> <span style="color:rgb(181,206,168)">8</span>, !<span style="color:rgb(86,156,214)">noalias</span> <span style="color:rgb(156,220,254)">!13</span></div></div></blockquote><div>which locates in: </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;border-left-color:rgb(204,204,204);padding-left:1ex"><div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:Menlo,Monaco,"Courier New",monospace;font-size:12px;line-height:18px;white-space:pre"><div><span style="color:rgb(156,220,254)">!13</span> = !{<span style="color:rgb(156,220,254)">!14</span>, <span style="color:rgb(156,220,254)">!16</span>, <span style="color:rgb(156,220,254)">!17</span>}</div><div><span style="color:rgb(156,220,254)">!14</span> = distinct !{<span style="color:rgb(156,220,254)">!14</span>, <span style="color:rgb(156,220,254)">!15</span>, !<span style="color:rgb(206,145,120)">"_Z30__device_stub__vectoradd_floatPfPKfS1_ii: argument 0"</span>}</div><div><span style="color:rgb(156,220,254)">!15</span> = distinct !{<span style="color:rgb(156,220,254)">!15</span>, !<span style="color:rgb(206,145,120)">"_Z30__device_stub__vectoradd_floatPfPKfS1_ii"</span>}</div><div><span style="color:rgb(156,220,254)">!16</span> = distinct !{<span style="color:rgb(156,220,254)">!16</span>, <span style="color:rgb(156,220,254)">!15</span>, !<span style="color:rgb(206,145,120)">"_Z30__device_stub__vectoradd_floatPfPKfS1_ii: argument 1"</span>}</div><div><span style="color:rgb(156,220,254)">!17</span> = distinct !{<span style="color:rgb(156,220,254)">!17</span>, <span style="color:rgb(156,220,254)">!15</span>, !<span style="color:rgb(206,145,120)">"_Z30__device_stub__vectoradd_floatPfPKfS1_ii: argument 2"</span>}</div></div></blockquote><div><br></div><div>So now I am confused about how to track the input Value of each GPU kernel CallInst in such a situation.</div><div>If I have to take them through the !13 variable, there are some IR files that are not including such variables to keep arguments of gpu kernel in them, and what should I do about those? Is there some specific rules for handling such a IR file produced from HIP program?</div><div><br></div><div>I also posted my IR file for people who are interested in this. I really appreciate any help or discussion on this, thank you.</div><div><br></div><div><br></div></div>