Hi, I wrote an IR pass and it adds some instructions that are not used. For example: %1 = call i64 @foo() When %1 is not used at all. I thought that running DCE (-dce) or DIE (-die) after my pass will remove such instructions, but it didn't. Why? And is there a way to do that? Thanks, Tehila. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151229/2f6839ec/attachment.html>
Hi Tehila, LLVM should not unconditionally remove such a function call because @foo may have side effects. IIRC, if you mark @foo as "readonly" ( http://llvm.org/docs/LangRef.html#function-attributes), then DCE should be able to remove the call. On Tue, Dec 29, 2015 at 8:55 AM, Tehila Mayzels via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi, > > > > I wrote an IR pass and it adds some instructions that are not used. > > For example: > > > > %1 = call i64 @foo() > > > > When %1 is not used at all. > > > > I thought that running DCE (-dce) or DIE (-die) after my pass will remove > such instructions, but it didn't. > > > > Why? And is there a way to do that? > > > > Thanks, > > Tehila. > > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev > >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151229/c217147f/attachment-0001.html>
I understand. Thanks a lot! From: Jingyue Wu [mailto:jingyue at google.com] Sent: Tuesday, December 29, 2015 8:29 PM To: Tehila Mayzels Cc: llvm-dev Subject: Re: [llvm-dev] Running DCE after my pass Hi Tehila, LLVM should not unconditionally remove such a function call because @foo may have side effects. IIRC, if you mark @foo as "readonly" (http://llvm.org/docs/LangRef.html#function-attributes), then DCE should be able to remove the call. On Tue, Dec 29, 2015 at 8:55 AM, Tehila Mayzels via llvm-dev <llvm-dev at lists.llvm.org> wrote: Hi, I wrote an IR pass and it adds some instructions that are not used. For example: %1 = call i64 @foo() When %1 is not used at all. I thought that running DCE (-dce) or DIE (-die) after my pass will remove such instructions, but it didn't. Why? And is there a way to do that? Thanks, Tehila. _______________________________________________ LLVM Developers mailing list llvm-dev at lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151229/7144c8c3/attachment.html>