I figured out my problem. I am linking two modules and though the
pointer to the global was created in one of the source modules. So while
getPointerToglobal still seems happy to return an address, it is not the
address of the final linked variable.
On 11/11/12 12:46, edA-qa mort-ora-y wrote:> I'm having some trouble getting access to a global variable with
> getPointerToGlobal. The resulting value is not what I am expecting.
>
> My assembly looks something like this:
>
> @gresult = global i32 undef
>
> define i32 @eval_expr() {
> entry:
> ...
> store i32 %3, i32* @gresult
> ret i32 %3
> }
>
> Where "gresult" is created with:
>
> auto global = new llvm::GlobalVariable( *module, int32Type,
> /*constant*/false, llvm::GlobalValue::ExternalLinkage, /*init*/0,
> "gresult" );
>
>
> I run the function and get the results with:
>
> llvm::GenericValue gv = ee->runFunction( funcPtr, args/*empty*/ );
> void * gptr = ee->getPointerToGlobal( global );
>
> gv.IntVal has the correct value, but *static_cast<int32_t*>(gptr)
does not.
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev
>
--
edA-qa mort-ora-y
-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Sign: Please digitally sign your emails.
Encrypt: I'm also happy to receive encrypted mail.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 259 bytes
Desc: OpenPGP digital signature
URL:
<http://lists.llvm.org/pipermail/llvm-dev/attachments/20121111/bbae922e/attachment.sig>