Hi all, How can i find the instruction that uses the result of a load instruction. For example: %16 = load i32, i32* %ptr %add = add i32 4, %16 In this case, i would like to get the add instruction. Best, Mo -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20160204/bdef6f63/attachment.html>
Walk the uses of the load instruction: http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html#ac27deb3d41124ec9e679d39021405005 On Thu, Feb 4, 2016 at 9:46 AM, Mohammad Norouzi via llvm-dev < llvm-dev at lists.llvm.org> wrote:> Hi all, > > How can i find the instruction that uses the result of a load instruction. > For example: > > %16 = load i32, i32* %ptr > > %add = add i32 4, %16 > > In this case, i would like to get the add instruction. > > Best, > Mo > > _______________________________________________ > 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/20160204/612701ae/attachment.html>
Hi, If you have access to the LoadInst, you can iterate over LI->uses(). See: http://llvm.org/docs/doxygen/html/classllvm_1_1Value.html best, vedant> On Feb 4, 2016, at 9:46 AM, Mohammad Norouzi via llvm-dev <llvm-dev at lists.llvm.org> wrote: > > Hi all, > > How can i find the instruction that uses the result of a load instruction. For example: > %16 = load i32, i32* %ptr > %add = add i32 4, %16 > > In this case, i would like to get the add instruction. > > Best, > Mo > _______________________________________________ > LLVM Developers mailing list > llvm-dev at lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev