[LLVMdev] getAnalysis<DataLayout>() Causing Compilation Error

Nick Lewycky nicholas at mxc.ca
Sun Jun 21 17:16:45 PDT 2015


Peter Finn wrote:
> Thank you, but how can I determine whether a given Value* V is an Instruction, or a GlobalValue, or an Argument?

http://llvm.org/docs/ProgrammersManual.html#the-isa-cast-and-dyn-cast-templates

Nick

>> On Jun 21, 2015, at 7:41 PM, Daniel Berlin<dberlin at dberlin.org>  wrote:
>>
>> So, this is because AllocatorInfo is an ImmutablePass.
>>
>> This leaves you having to grab it the hard way:
>>
>> If value* is an instruction,
>>
>> dyn_cast<Instruction>(V)->getModule()->getDataLayout().
>>
>> if value * is a GlobalValue
>> /* getParent gives a module here */
>>
>> dyn_cast<GlobalValue>(V)->getParent()->getDataLayout();
>>
>> if value * is an argument
>> /* getParent gives a function, and getParent on the function gives our module */
>> dyn_cast<Argument>(V)->getParent()->getParent()->getDataLayout();
>>
>> It may be worth making a helper (or making this consistent in some way
>> by adding getDataLayout() to Value* and overriding it in subclasses or
>> something).
>>
>>
>>
>>
>> On Sun, Jun 21, 2015 at 4:31 PM, Peter Finn<peterdfinn at icloud.com>  wrote:
>>> I’m debugging SAFECode source code files, and in AllocatorInfo.cpp, in the function getObjectSize(Value* V), the function getAnalysis<DataLayout>() is called.  I’ve run into this problem before, and the first time I saw it, my employer recommended I use M.getDataLayout() instead, where M was a reference to a Module.  However, in getObjectSize(Value* V), there is no Module reference in the list of parameters.  Is there a way to obtain a Module affiliated with the Value* argument, which I can then use to call M.getDataLayout?  Is there some other way I can get the DataLayout reference I need?
>>>
>>> Thanks,
>>> Peter Finn
>>> _______________________________________________
>>> LLVM Developers mailing list
>>> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
>>> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev





More information about the llvm-dev mailing list