[LLVMdev] GetElementPtrInst question

James Molloy James.Molloy at arm.com
Sun Dec 2 08:26:55 PST 2012


Hi Eduardo,

"inst2" is a LoadInst, which inherits from Value. You can simply pass "inst2" to CreateGEP.

I'd recommend using an IRBuilder instead of manually new'ing the instructions anyway, because an IRBuilder will associate those instructions with a BasicBlock, and your code is currently not doing that (so you'll run into problems later).

Cheers,

James
________________________________________
From: Eduardo [erocha.ssa at gmail.com]
Sent: 02 December 2012 16:26
To: James Molloy
Cc: llvmdev at cs.uiuc.edu
Subject: Re: [LLVMdev] GetElementPtrInst question

Hi James,

Thanks for your quick reply.

> I assume because you asked this question, something went wrong when using the above method. What was it? :)

No, I am not using this method. I was trying to create a
llvm::GetElementPtrInst . I didn't create IRBuilder. I am writing a
ModulePass that insert new instruction to an existing Module.

Besides, how can you get a reference to myreg1 ? Looking at your
snippet this variable would be a llvm::Value* (I saw that in the
documentation of IRBuilder). All I have in my code is something like:

  llvm::LoadInst *inst2 = new llvm::LoadInst( oneGlobalVariable,
"myreg1", inst1);

Probably I can get a Value pointer to the output register from the
inst2 variable, but I don't know how (I couldn't figure out myself by
just reading the documentation).

Any help is very welcome,
Eduardo






More information about the llvm-dev mailing list