Back tracing Variables

Good Morning - Happy Holidays everyone!

I had a question about the best way to do back tracing of variables via the IR. So for example, if I have the following simple IR:

define i32 @squak(i32 %num) #0 {
  %1 = alloca i32, align 4
  store i32 %num, i32* %1, align 4
  %2 = load i32, i32* %1, align 4
  %3 = icmp sgt i32 %2, 10

I’m grabbing the predicate of “icmp”, which in this case is a simple test “>” of the input “%num" and the constant “10" and I want to trace back to “%num" via the slots/virtual registers %2 and %1. I believe I can do this via the SlotTracker (in AsmWriter.cpp) but I wonder if there’s a better, more direct way? Any suggestions? I’m basically trying to track predicate formation in the IR and hence the need…

Thanks for any help!

Hi Juan:

I haven’t looked at SlotTracker, but have been using MemoryDependenceWrapperPass to do something similar.



Thanks so much, I think that’s pretty much what I was looking for!