[LLVMbugs] [Bug 11178] New: Mac JIT code fails on 32-bit compile of LLVM - LLVM 2.9 OK, 64-bit OK
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Oct 18 17:44:46 PDT 2011
http://llvm.org/bugs/show_bug.cgi?id=11178
Summary: Mac JIT code fails on 32-bit compile of LLVM - LLVM
2.9 OK, 64-bit OK
Product: libraries
Version: trunk
Platform: Macintosh
OS/Version: MacOS X
Status: NEW
Severity: normal
Priority: P
Component: Backend: X86
AssignedTo: unassignedbugs at nondot.org
ReportedBy: nickwalters99 at gmail.com
CC: llvmbugs at cs.uiuc.edu
I am trying to run this test program via JIT on my Mac (10.7.1) also tested
10.7.2 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. I am building LLVM with CMake using:
cmake -DCMAKE_BUILD_TYPE="Release" -DCMAKE_OSX_ARCHITECTURES="i386" ../llvm)
Here's my code:
#include <iostream>
#include "llvm/LLVMContext.h"
#include "llvm/Module.h"
#include "llvm/Constants.h"
#include "llvm/DerivedTypes.h"
#include "llvm/Instructions.h"
#include "llvm/ExecutionEngine/JIT.h"
#include "llvm/ExecutionEngine/Interpreter.h"
#include "llvm/ExecutionEngine/GenericValue.h"
#include "llvm/Support/TargetSelect.h"
#include "llvm/Support/ManagedStatic.h"
#include "llvm/Support/raw_ostream.h"
#include "llvm/Support/IRBuilder.h"
using namespace std;
using namespace llvm;
int main(int argc, char** argv){
InitializeNativeTarget();
LLVMContext context;
Module* module = new Module("test", context);
vector<Type*> args;
args.push_back(Type::getInt32Ty(context));
FunctionType* ft = FunctionType::get(Type::getInt32Ty(context),
args, false);
Function* f = Function::Create(ft,
GlobalValue::ExternalLinkage,
"f", module);
Value* arg = f->arg_begin();
BasicBlock* bb = BasicBlock::Create(context, "entry", f);
IRBuilder<> builder(bb);
Value* one = builder.getInt32(1);
Value* v = builder.CreateAdd(one, arg);
builder.CreateRet(v);
ExecutionEngine* engine = EngineBuilder(module).create();
void* vpf = engine->getPointerToFunction(f);
int32_t (*fp)(int32_t) =
(int32_t (*)(int32_t))(intptr_t)vpf;
int32_t out = fp(10);
cout << "out is: " << out << endl;
return 0;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list