<div dir="ltr">LLVM IR doesn't maintain a lot of information present in the source. What were you hoping to do with that information? Perhaps you'd be best off doing something up in clang/using the AST uinstead of LLVM IR?</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Jun 29, 2019 at 10:36 PM Tingyuan LIANG via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Dear all,</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi! Recently, I notice a situation where I cannot infer the size of the outermost dimension of array in the function interface.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
To concretely depict the problem, I show the C source code and the generated IR code at the end. The array size of A[] is 51 but this information is lost in the generated IR.</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
How can I maintain such information in IR? Should I set some argument for Clang so it can do so?</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
The Clang command I used is : <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px">
<div><span style="color:rgb(206,145,120)"> clang -O1 -emit-llvm -S -g tmp.cc -o tmp.bc</span></div>
</div>
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Thanks in advance for your time and suggestion! ^_^<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
C source code: <br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px">
<div><span style="color:rgb(86,156,214)">int</span><span> </span><span style="color:rgb(220,220,170)">f</span><span> (
</span><span style="color:rgb(86,156,214)">int</span><span> </span><span style="color:rgb(156,220,254)">A</span><span>[</span><span style="color:rgb(181,206,168)">51</span><span>],
</span><span style="color:rgb(86,156,214)">int</span><span> </span><span style="color:rgb(156,220,254)">x</span><span>)
</span></div>
<div><span>{</span></div>
<div><span> </span><span style="color:rgb(197,134,192)">return</span><span> </span><span style="color:rgb(156,220,254)">A</span><span>[x];</span></div>
<div><span>}</span></div>
</div>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
===========================</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
generated IR:</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<div style="color:rgb(212,212,212);background-color:rgb(30,30,30);font-family:"Droid Sans Mono",monospace,monospace,"Droid Sans Fallback";font-weight:normal;font-size:14px;line-height:19px">
<div><span>; Function Attrs: norecurse nounwind readonly uwtable</span></div>
<div><span>define dso_local i32 @_Z1fPii(i32</span><span>*</span><span> nocapture readonly %A, i32 %x) local_unnamed_addr #0 !dbg !7
</span><span>{</span></div>
<div><span>entry:</span></div>
<div><span> call </span><span style="color:rgb(86,156,214)">void</span><span> @llvm.dbg.value(metadata i32</span><span>*</span><span> %A, metadata !13, metadata !DIExpression()), !dbg !15</span></div>
<div><span> call </span><span style="color:rgb(86,156,214)">void</span><span> @llvm.dbg.value(metadata i32 %x, metadata !14, metadata !DIExpression()), !dbg !16</span></div>
<div><span> %idxprom </span><span>=</span><span> sext i32 %x to i64, !dbg !17</span></div>
<div><span> %arrayidx </span><span>=</span><span> getelementptr inbounds i32, i32</span><span>*</span><span> %A, i64 %idxprom, !dbg !17</span></div>
<div><span> %0 </span><span>=</span><span> load i32, i32</span><span>*</span><span> %arrayidx, align
</span><span style="color:rgb(181,206,168)">4</span><span>, !dbg !17, !tbaa !18</span></div>
<div><span> ret i32 %0, !dbg !22</span></div>
<div><span>}</span></div>
</div>
<br>
</div>
<div style="font-family:Calibri,Arial,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div id="gmail-m_-4750863312345150083Signature">
<div id="gmail-m_-4750863312345150083divtagdefaultwrapper" dir="ltr" style="font-size:12pt;color:rgb(0,0,0);font-family:Calibri,Helvetica,sans-serif">
<span id="gmail-m_-4750863312345150083ms-rterangepaste-start"></span>
<div><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Best regards,</span></font><span style="font-size:12pt">
</span><span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">------------------------------------------</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Tingyuan LIANG</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">MPhil Student</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">Department of Electronic and Computer Engineering</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span>
<div><span style="font-size:12pt"></span>
<div style="margin:0px"><font size="2" face="Calibri,sans-serif"><span style="font-size:12pt">The Hong Kong University of Science and Technology</span></font></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span></div>
<span style="font-size:12pt"></span><span style="font-size:12pt"></span><span id="gmail-m_-4750863312345150083ms-rterangepaste-end"></span></div>
</div>
</div>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>