[llvm-dev] Finding Store Instructions that possibly affect load instruction or func call instruction

Florian Hahn via llvm-dev llvm-dev at lists.llvm.org
Mon Mar 8 09:03:47 PST 2021


Hi,

> On Mar 8, 2021, at 03:46, sushant gokhale via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> 
> Hi,
> 
> I want to track StoreInst that affect loadInst/CallInst.
> 
> e.g %1 = alloc i32
>       store 10,%1
>       foo(%1)      -------> %1 should take the value 10 (defined by store ins)
> 
> I tried to use MemSSA for this but for situations I can't find these correct dependencies possibly due to insufficient Alias information 


MemorySSA should be helpful here. One thing to note is that MemorySSA is not completely optimized at construction, but it guarantees that all potentially clobbering instructions are in the memory def-use chain. 

It is up the the so-called walkers to skip over non-aliasing accesses. Please take a look at https://llvm.org/doxygen/classllvm_1_1MemorySSAWalker.html . They provide getClobberingMemoryAccess, which skip non-aliasing instructions, depending on the walker implementation. You can use MemorySSA::getWalker to get the default walker. If that doesn’t do what you want, you probably need to define your own walker. At last LLVM Developers meeting, there was a talk covering MemorySSA: https://www.youtube.com/watch?v=1e5y6WDbXCQ

Cheers,
Florian


More information about the llvm-dev mailing list