I'm instrumenting memory loads and stores in a LLVM module pass. In this work, I need to do (1) Getting memory address of the operand, (Looks I've done correctly) (2) Getting memory read/write size, (Question) (3) Location id of the load/store instruction. (Easy, I've done) For example, say that I'm reading a local variable 'a': %1 = load i32* %a, align 4 I need to know the address of the variable 'a' and the size. Of course, memory loads/stores could be from general GEP or global variables. Getting the address was easily doable by using "PtrToIntInst(load_inst->getPointerOperand(), ...)". However, getting load/store size wasn't that straight forward. In this example, it should be four bytes. I tried to get the Type* from the getPointerOperand() and tried to retrieve the size of the type, but failed. Question: [1] How can I retrieve the read/write size of load/store instruction? I have another question. If I can get the size, then what would be the maximum size? Obviously, 1 ~ 8 bytes for built-in types, but wondering even the larger size could be obtained. I suspect a vector load instruction could load up to 32 bytes (= 256 bits, in case of x86 AVX). Question: [2] What would be the maximum size of load/store operand? Thank you! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20110217/4c409f59/attachment.html>
Hi nullnull,> I'm instrumenting memory loads and stores in a LLVM module pass. In this work, I > need to do > (1) Getting memory address of the operand, (Looks I've done correctly) > (2) Getting memory read/write size, (Question)use getTypeStoreSize defined in TargetData. Ciao, Duncan.
You can take a look at http://code.google.com/p/data-race-test/source/browse/trunk/llvm/opt/ThreadSanitizer/ThreadSanitizer.cpp, where I do practically the same. The routine that obtains the size is getMopPtrSize(), getting the addresses is done in instrumentMop(). Alex On Thu, Feb 17, 2011 at 9:06 PM, nullnull <null.function at gmail.com> wrote:> I'm instrumenting memory loads and stores in a LLVM module pass. In this > work, I need to do > (1) Getting memory address of the operand, (Looks I've done correctly) > (2) Getting memory read/write size, (Question) > (3) Location id of the load/store instruction. (Easy, I've done) > > For example, say that I'm reading a local variable 'a': > > %1 = load i32* %a, align 4 > > I need to know the address of the variable 'a' and the size. Of course, > memory loads/stores could be from general GEP or global variables. > > Getting the address was easily doable by using > "PtrToIntInst(load_inst->getPointerOperand(), ...)". However, getting > load/store size wasn't that straight forward. In this example, it should be > four bytes. I tried to get the Type* from the getPointerOperand() and tried > to retrieve the size of the type, but failed. > > Question: > [1] How can I retrieve the read/write size of load/store instruction? > > > I have another question. If I can get the size, then what would be the > maximum size? Obviously, 1 ~ 8 bytes for built-in types, but wondering even > the larger size could be obtained. I suspect a vector load instruction could > load up to 32 bytes (= 256 bits, in case of x86 AVX). > > Question: > [2] What would be the maximum size of load/store operand? > > > Thank you!
Possibly Parallel Threads
- [LLVMdev] SwitchInst::addCase with BlockAddress
- [LLVMdev] SwitchInst::addCase with BlockAddress
- 6 separate instances of static getPointerOperand(). Time to consolidate?
- 6 separate instances of static getPointerOperand(). Time to consolidate?
- 6 separate instances of static getPointerOperand(). Time to consolidate?