<div dir="ltr">Never mind. I found Module has a getTargetTriple method. </div><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Sep 6, 2015 at 10:46 PM, Jingyue Wu <span dir="ltr"><<a href="mailto:jingyue@google.com" target="_blank">jingyue@google.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">jingyue added inline comments.<br>
<span class=""><br>
================<br>
Comment at: lib/Target/NVPTX/NVPTXAliasAnalysis.cpp:71<br>
@@ +70,3 @@<br>
+      if (auto A = dyn_cast<Argument>(Obj)) {<br>
+        if (TM && TM->getDrvInterface() == NVPTX::CUDA &&<br>
+            isKernelFunction(*A->getParent()))<br>
----------------<br>
</span><span class="">hfinkel wrote:<br>
> jingyue wrote:<br>
> > hfinkel wrote:<br>
> > > Can you please explain why this DvrInterface == CUDA check is necessary? isKernelFunction always checks for NVVM metadata, and lacking that, a specific calling convention. Is that not enough?<br>
> > ><br>
> > Sure. As mentioned in the comment, if `Obj` is a **CUDA** kernel parameter, it must reside in global memory. But if the driver interface is NVCL, for example, a kernel parameter is not guaranteed to point to global memory.<br>
> ><br>
> > This is also why we have a similar check in `NVPTXLowerKernelArgs`: <a href="https://github.com/llvm-mirror/llvm/blob/master/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp#L201" rel="noreferrer" target="_blank">https://github.com/llvm-mirror/llvm/blob/master/lib/Target/NVPTX/NVPTXLowerKernelArgs.cpp#L201</a>.<br>
> Okay; I did not realize this might not hold for NVCL.<br>
><br>
> This it the only place you use TM in this pass, and thus, the only check that can't be done early in the pipeline. However, the driver interface variable is (at least currently) completely determined by the target triple. Is it worth checking the triple directly and dropping the direct TM dependency?<br>
><br>
</span>I wanted to avoid using `TM` too, but wonder how I can get it without passing in `TargetMachine`.<br>
<br>
<br>
<a href="http://reviews.llvm.org/D12414" rel="noreferrer" target="_blank">http://reviews.llvm.org/D12414</a><br>
<br>
<br>
<br>
</blockquote></div><br></div>