Hif
Hif

Reputation: 165

How can we extract pointer type in LLVM

I have the following LLVM IR

%6 = load i32** %imw, align 8
%arrayidx = getelementptr inbounds i32* %6, i64 10

I want to extract i32 from these instructions in my LLVM pass. Can anyone guide me on how can I go about doing this?

Upvotes: 5

Views: 4040

Answers (1)

arrowd
arrowd

Reputation: 34391

First you access an operand you are interested in with instruction->getOperand(i) and then call ->getType() on it. The llvm::Type class has a lot of helper classes and ->isPointerTy() is what you are probably interested in.

Upvotes: 3

Related Questions