[prev in list] [next in list] [prev in thread] [next in thread] 

List:       llvm-dev
Subject:    Re: [llvm-dev] Inserting an external call in FunctionPass
From:       Reid Kleckner via llvm-dev <llvm-dev () lists ! llvm ! org>
Date:       2017-03-29 18:54:47
Message-ID: CACs=ty+SfCkX9Ecs51yENP4YxtaDSuRgifVshRGBNs1uZB=ztQ () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


I think the documentation is wrong. Existing function passes frequently
insert new intrinsic function declarations, and we expect that to work. The
loop vectorizer also inserts calls to non-intrinsic library functions.

The intention is that function passes don't introduce new function
definitions, because then an outer pass manager would need to discover them
and add them to its worklist.

On Thu, Mar 23, 2017 at 5:19 PM, Evgenii Stepanov via llvm-dev <
llvm-dev@lists.llvm.org> wrote:

> Hi,
>
> how do I insert a call to an external function in a FunctionPass?
> My problem is with creation of the declaration for the external function.
>
> According to http://llvm.org/docs/WritingAnLLVMPass.html#the-
> functionpass-class,
> a FunctionPass is not supposed to add or remove functions. I assume
> it's also true for function declarations.
>
> A declaration inserted in doInitialization is cleaned up in
> GlobalOptLegacyPass::runOnModule, which happens to run before my pass'
> runOnFunction().
>
> Do I need a ModulePass for this?
> _______________________________________________
> LLVM Developers mailing list
> llvm-dev@lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev
>

[Attachment #5 (text/html)]

<div dir="ltr">I think the documentation is wrong. Existing function passes \
frequently insert new intrinsic function declarations, and we expect that to work. \
The loop vectorizer also inserts calls to non-intrinsic library \
functions.<div><br></div><div>The intention is that function passes don&#39;t \
introduce new function definitions, because then an outer pass manager would need to \
discover them and add them to its worklist.</div></div><div \
class="gmail_extra"><br><div class="gmail_quote">On Thu, Mar 23, 2017 at 5:19 PM, \
Evgenii Stepanov via llvm-dev <span dir="ltr">&lt;<a \
href="mailto:llvm-dev@lists.llvm.org" \
target="_blank">llvm-dev@lists.llvm.org</a>&gt;</span> wrote:<br><blockquote \
class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc \
solid;padding-left:1ex">Hi,<br> <br>
how do I insert a call to an external function in a FunctionPass?<br>
My problem is with creation of the declaration for the external function.<br>
<br>
According to <a href="http://llvm.org/docs/WritingAnLLVMPass.html#the-functionpass-class" \
rel="noreferrer" target="_blank">http://llvm.org/docs/<wbr>WritingAnLLVMPass.html#the-<wbr>functionpass-class</a>,<br>
 a FunctionPass is not supposed to add or remove functions. I assume<br>
it&#39;s also true for function declarations.<br>
<br>
A declaration inserted in doInitialization is cleaned up in<br>
GlobalOptLegacyPass::<wbr>runOnModule, which happens to run before my pass&#39;<br>
runOnFunction().<br>
<br>
Do I need a ModulePass for this?<br>
______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" \
target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br> \
</blockquote></div><br></div>


[Attachment #6 (text/plain)]

_______________________________________________
LLVM Developers mailing list
llvm-dev@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic