<html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; ">I can duplicate this and a quick look shows that at one point we're passing the argument on the stack and then expecting it in a different location. A bug filed about this when I can take some more time to look at it would be good.<div><br></div><div>Thanks!</div><div><br></div><div>-eric<br><div><br></div><div><br><div><div>On Oct 12, 2011, at 9:24 PM, Nick Walters wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">Hello,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">I am trying to run this test program via JIT on my Mac (10.7.1) where I have compiled the latest LLVM code for 32-bit and it is not working properly. Running the same code against LLVM 2.9 works fine. I also tried recompiling my same checkout of LLVM as 64-bit and re-compiled my test program and that works fine, for some reason the 32-bit version is yielding unexpected behavior. I believe I am linking with all of the required LLVM .a files. Here's my code:</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include <iostream></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/LLVMContext.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Module.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Constants.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/DerivedTypes.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Instructions.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/ExecutionEngine/JIT.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/ExecutionEngine/Interpreter.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/ExecutionEngine/GenericValue.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Support/TargetSelect.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Support/ManagedStatic.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Support/raw_ostream.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">#include "llvm/Support/IRBuilder.h"</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">using namespace std;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">using namespace llvm;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">int main(int argc, char** argv){</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> InitializeNativeTarget();</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> LLVMContext context;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> Module* module = new Module("test", context);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> vector<Type*> args;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> args.push_back(Type::getInt32Ty(context));</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> FunctionType* ft = FunctionType::get(Type::getInt32Ty(context),</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span> args, false);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> Function* f = Function::Create(ft,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span> GlobalValue::ExternalLinkage,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"><span class="Apple-tab-span" style="white-space:pre"> </span> "f", module);</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> Value* arg = f->arg_begin();</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> BasicBlock* bb = BasicBlock::Create(context, "entry", f);</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> IRBuilder<> builder(bb);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> Value* one = builder.getInt32(1);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> Value* v = builder.CreateAdd(one, arg);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> builder.CreateRet(v);</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> ExecutionEngine* engine = EngineBuilder(module).create();</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> void* vpf = engine->getPointerToFunction(f);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> int32_t (*fp)(int32_t) = </font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> (int32_t (*)(int32_t))(intptr_t)vpf;</font></div><p style="margin: 0.0px 0.0px 0.0px 0.0px; font: 13.0px Verdana; min-height: 16.0px"><font class="Apple-style-span" face="Helvetica"> <br class="webkit-block-placeholder"></font></p><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> int32_t out = fp(10);</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> cout << "out is: " << out << endl;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica"> return 0;</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">}</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">I appreciate your help. Thanks,</font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; min-height: 16px; "><font class="Apple-style-span" face="Helvetica"><br></font></div><div style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; font: normal normal normal 13px/normal Verdana; "><font class="Apple-style-span" face="Helvetica">Nick</font></div>
_______________________________________________<br>LLVM Developers mailing list<br><a href="mailto:LLVMdev@cs.uiuc.edu">LLVMdev@cs.uiuc.edu</a> <a href="http://llvm.cs.uiuc.edu">http://llvm.cs.uiuc.edu</a><br><a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev">http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev</a><br></blockquote></div><br></div></div></body></html>