Gleb Popov via llvm-dev
2019-Sep-24 10:22 UTC
[llvm-dev] Finding "last uses" of an alloca in the function.
Hello, LLVMDev. Given an alloca in the entry block, I want to find all its uses after which it is used no more. I tried naive approach by recursively iterating over uses(), but faced 2 problems: 1. I have to take into account "indirect" uses introduced by stores/loads. 2. In case of loops the use chain I built become circular. I came up with an idea by tracking current "use path", but wanted to ask if there is a LLVM analysis for this first. Thanks in advance. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190924/ac23400b/attachment.html>
Min-Yih Hsu via llvm-dev
2019-Sep-24 16:45 UTC
[llvm-dev] Finding "last uses" of an alloca in the function.
Hi, I think you can sort all basic blocks in SCC order by using SCCIterator. Then you can get a total order of all alloca users. Regards, - Min> On Sep 24, 2019, at 3:22 AM, Gleb Popov via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hello, LLVMDev. > > Given an alloca in the entry block, I want to find all its uses after which it is used no more. I tried naive approach by recursively iterating over uses(), but faced 2 problems: > > 1. I have to take into account "indirect" uses introduced by stores/loads. > 2. In case of loops the use chain I built become circular. > > I came up with an idea by tracking current "use path", but wanted to ask if there is a LLVM analysis for this first. > > Thanks in advance. > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev