Do you use load to get the value of V? If not then you probably return i32* instead of i32.<div><div><br></div><div>Victor</div><div><br><div class="gmail_quote">On 16 February 2010 11:26, Russell Wallace <span dir="ltr"><<a href="mailto:russell.wallace@gmail.com" target="_blank">russell.wallace@gmail.com</a>></span> wrote:<br>


<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">I'm trying to create a global variable initialized to zero, and return<br>
its value from a newly created function, in JIT context. I'm keeping<br>
all types as i32 for the moment, and I only have the one module<br>
object.<br>
<br>
This is the code I have for creating the global variable:<br>
<br>
        const Type *type = Type::getInt32Ty(getGlobalContext());<br>
//      Constant *zerov = Constant::getNullValue(type);<br>
        Constant *zerov = Constant::getIntegerValue(type, APInt(32, 0));<br>
        V = new GlobalVariable(getGlobalContext(), type, 0,<br>
GlobalValue::PrivateLinkage, zerov, name);<br>
<br>
And these are the error messages given by verifyFunction:<br>
<br>
Function return type does not match operand type of return inst!<br>
  ret i32* @x i32Referencing global in another module!<br>
  ret i32* @xBroken module found, compilation aborted!<br>
<br>
Any idea of what I might be doing wrong? Is this the right way to be<br>
going about it in the first place?<br>
_______________________________________________<br>
LLVM Developers mailing list<br>
<a href="mailto:LLVMdev@cs.uiuc.edu" target="_blank">LLVMdev@cs.uiuc.edu</a>         <a href="http://llvm.cs.uiuc.edu" target="_blank">http://llvm.cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br>
</blockquote></div><br>
</div></div>