<div dir="auto">Can you share your code?</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 17, 2021 at 9:44 PM 周书林 <<a href="mailto:zhoushulin1992@gmail.com">zhoushulin1992@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">Hi Craig,<div><br></div><div>I have tried to visit the Users of current GEPOperator, but the results are not what I am looking for.</div><div>In detail, when I tried to get the Users of GEPOperator of the LoadInst, i.e. <b>

<i>getelementptr inbounds (%struct.TTT, %struct.TTT* @ttt, i32 0, i32 2) </i></b>,</div><div>the results are turned out to be Users of GlobalVariable <i style="font-weight:bold">@ttt, </i>i.e. something like </div><div><b><i>i8* bitcast (%struct.TTT* @ttt to i8*)</i></b>, or <b><i>i32* getelementptr inbounds (%struct.TTT, %struct.TTT* @ttt, i32 0, i32 1)</i></b>.<br></div><div><br>I am not sure what happened here. Is that the def-use chain of structural global variables always contains the whole information related to the global variable?</div><div><br></div><div>Sincerely,</div><div>Shulin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> 于2021年6月18日周五 上午10:14写道:<br></div></div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">I see so you want to see where the GlobalVariable is accesssed. You should be able to get the Users of the ConstantExpr as well, those will either be another ConstantExpr or an Instruction. In your example, one of the Users of the GEPOperator should be the LoadInst.<div><div><br clear="all"><div><div dir="ltr">~Craig</div></div><br></div></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 17, 2021 at 7:06 PM 周书林 <<a href="mailto:zhoushulin1992@gmail.com" target="_blank">zhoushulin1992@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr"><div>Hi Craig,</div><div><br></div>I started from GlobalVaribles, so there are situations that I met the ConstantExprs, i.e. some Operators.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Craig Topper <<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>> 于2021年6月18日周五 上午8:37写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">How did you choose where you started from? An Instruction can only be used by another Instruction, but it seems you've started from a Constant which can be used by ConstantExprs.<div><br clear="all"><div><div dir="ltr">~Craig</div></div><br></div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, Jun 17, 2021 at 5:25 PM 周书林 via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)"><div dir="ltr">Hi Michael, <div><br></div><div>Thank you very much! </div><div>I have a further question: if I want to get the dataflow of a target Value, is there any way to handle these situations when iterate the Users?Or only by iterator all the instructions and their operands? </div><div><br></div><div>Sincerely,</div><div>Shulin</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Michael Kruse <<a href="mailto:llvmdev@meinersbur.de" target="_blank">llvmdev@meinersbur.de</a>> 于2021年6月18日周五 上午5:11写道:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-style:solid;padding-left:1ex;border-left-color:rgb(204,204,204)">Am Do., 17. Juni 2021 um 10:24 Uhr schrieb 周书林 via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>>:<br>
> %39 = load i32, i32* getelementptr inbounds (%struct.TTT, %struct.TTT* @ttt, i32 0, i32 2), align 8, !dbg !971<br>
<br>
%39 is the LoadInst, while getelementptr is its second operand. It is<br>
inlined because it is an llvm::Constant, not an instruction. Constants<br>
do not participate in use/user-chains and hence there is no link from<br>
GEP to the LoadInst that is using it. The constant GEP object may be<br>
used by an arbitrary number of other instructions, other constants in<br>
the same or other functions.<br>
<br>
Node that there "GEPOperator" can represent either a GetElementPtrInst<br>
(i.e. an instruction) or a GEP constant expression (derived from<br>
ConstantExpr)<br>
<br>
Michael<br>
</blockquote></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>
</blockquote></div>
</blockquote></div>
</blockquote></div>
</blockquote></div></div>-- <br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature">~Craig</div>