[LLVMdev] Load from abs address generated bad code on LLVM 2.4

Óscar Fuentes ofv at wanadoo.es
Wed Jan 21 09:36:39 PST 2009


Andrew Haley <aph at redhat.com> writes:

>>>> IIRC, one workaround is to use a GlobalValue instead of a IntToPtr on a
>>>> Constant.
>>> Err, how?  I can't figure out how to do it.  The only documentation for
>>> GlobalValue describes it as a superclass of GlobalVariables and Functions.
>> 
>> IIRC, the stuff I used was something like...
>> 
>> GlobalVariable *gv = new GlobalVariable( /* your pointer type */,
>>                          other required parameters...);
>> AddGlobalMapping(gv, your_pointer_value); // i.e. (void*)0x938742
>> 
>> then, where you use
>> 
>>   Constant* thp = ConstantExpr::getCast(Instruction::IntToPtr,
>>   your_pointer_value, /* i.e. 0x938742 */
>>   /* your pointer type */);
>> 
>> /* Now use thp */
>> 
>> change it to
>> 
>> /* Now just use gv */
>> 
>> GetGlobalValueAtAddress may be useful for housekeeping.
>
> How does one use GetGlobalValueAtAddress?

Sorry, GetGlobalValueAtAddress is a helper function on my code, it is
not LLVM.

The getGlobalValueAtAddress method is not required for what you need. Go
ahead without it.

[snip]

-- 
Oscar




More information about the llvm-dev mailing list