<div dir="auto">Hi Tim, <div dir="auto">I had similar problem a couple of weeks ago but I somehow circumvented it. However, I dont understand much from the description. Can you please provide some example of backend which does this? probably what functions in X86 backend handle this lowering? If I look at the code I will be able to understand more clearly.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Mar 22, 2021, 3:27 PM Tim Northover 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:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Mon, 22 Mar 2021 at 07:36, Zhang via llvm-dev<br>
<<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>> wrote:<br>
> For CallSites that contains a GlobalValue as one of the arguments, where exactly does the lowering from GlobalAddress to iPTR took place?.<br>
<br>
It's generally no different for a callsite than any other GlobalValue<br>
user. The generic SelectionDAGBuilder code will create a GlobalAddress<br>
SDNode with iPTR type because the type of a GlobalValue is actually a<br>
pointer to the type of the underlying object.<br>
<br>
The call lowering code will get this iPTR node, and may well decide to<br>
pass it to the callee in a register.<br>
<br>
As for the GlobalAddress node, that goes through normal lowering to a<br>
target-specific instruction sequence to materialize the address of the<br>
global object. Often this is via custom C++ in LegalizeDAG (i.e.<br>
`setOperationAction(ISD::GlobalValue, MVT::i64, Custom)`).<br>
<br>
Cheers.<br>
<br>
Tim.<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a><br>
<a href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer noreferrer" target="_blank">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a><br>
</blockquote></div>