CUDA: get thread id in a pass


I am writing my first pass in LLVM.

I need to collect the threadId in each kernel call and then associate that with the corresponding load/store calls.

I am stuck at extracting the threadId.

LLVM intrinsic for thread ID declaration:


Actual call:

; What is my ID?
  %id = tail call i32 readnone nounwind

So in the above LLVM IR instruction* is the operand 1, is that right? And then is %id operand 0?

So I need to check for an instruction with the operand type matching above expression and then extract operand 0.

Is my understanding right?

Thank you.


Sorry, %id is a register! so I need* I guess.