summaryrefslogtreecommitdiffstats
path: root/lib/ExecutionEngine
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ExecutionEngine')
-rw-r--r--lib/ExecutionEngine/ExecutionEngine.cpp44
-rw-r--r--lib/ExecutionEngine/ExecutionEngineBindings.cpp34
-rw-r--r--lib/ExecutionEngine/Interpreter/Execution.cpp78
-rw-r--r--lib/ExecutionEngine/JIT/JIT.cpp11
-rw-r--r--lib/ExecutionEngine/JIT/JITEmitter.cpp60
-rw-r--r--lib/ExecutionEngine/JIT/JITMemoryManager.cpp2
-rw-r--r--lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp16
7 files changed, 127 insertions, 118 deletions
diff --git a/lib/ExecutionEngine/ExecutionEngine.cpp b/lib/ExecutionEngine/ExecutionEngine.cpp
index cb30748..89c4290 100644
--- a/lib/ExecutionEngine/ExecutionEngine.cpp
+++ b/lib/ExecutionEngine/ExecutionEngine.cpp
@@ -138,7 +138,7 @@ void *ExecutionEngineState::RemoveMapping(
void ExecutionEngine::addGlobalMapping(const GlobalValue *GV, void *Addr) {
MutexGuard locked(lock);
- DEBUG(errs() << "JIT: Map \'" << GV->getName()
+ DEBUG(dbgs() << "JIT: Map \'" << GV->getName()
<< "\' to [" << Addr << "]\n";);
void *&CurVal = EEState.getGlobalAddressMap(locked)[GV];
assert((CurVal == 0 || Addr == 0) && "GlobalMapping already established!");
@@ -246,13 +246,13 @@ static void *CreateArgv(LLVMContext &C, ExecutionEngine *EE,
unsigned PtrSize = EE->getTargetData()->getPointerSize();
char *Result = new char[(InputArgv.size()+1)*PtrSize];
- DEBUG(errs() << "JIT: ARGV = " << (void*)Result << "\n");
+ DEBUG(dbgs() << "JIT: ARGV = " << (void*)Result << "\n");
const Type *SBytePtr = Type::getInt8PtrTy(C);
for (unsigned i = 0; i != InputArgv.size(); ++i) {
unsigned Size = InputArgv[i].size()+1;
char *Dest = new char[Size];
- DEBUG(errs() << "JIT: ARGV[" << i << "] = " << (void*)Dest << "\n");
+ DEBUG(dbgs() << "JIT: ARGV[" << i << "] = " << (void*)Dest << "\n");
std::copy(InputArgv[i].begin(), InputArgv[i].end(), Dest);
Dest[Size-1] = 0;
@@ -343,9 +343,7 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
// Check main() type
unsigned NumArgs = Fn->getFunctionType()->getNumParams();
const FunctionType *FTy = Fn->getFunctionType();
- const Type* PPInt8Ty =
- PointerType::getUnqual(PointerType::getUnqual(
- Type::getInt8Ty(Fn->getContext())));
+ const Type* PPInt8Ty = Type::getInt8PtrTy(Fn->getContext())->getPointerTo();
switch (NumArgs) {
case 3:
if (FTy->getParamType(2) != PPInt8Ty) {
@@ -358,13 +356,13 @@ int ExecutionEngine::runFunctionAsMain(Function *Fn,
}
// FALLS THROUGH
case 1:
- if (FTy->getParamType(0) != Type::getInt32Ty(Fn->getContext())) {
+ if (!FTy->getParamType(0)->isInteger(32)) {
llvm_report_error("Invalid type for first argument of main() supplied");
}
// FALLS THROUGH
case 0:
if (!isa<IntegerType>(FTy->getReturnType()) &&
- FTy->getReturnType() != Type::getVoidTy(FTy->getContext())) {
+ !FTy->getReturnType()->isVoidTy()) {
llvm_report_error("Invalid return type of main() supplied");
}
break;
@@ -493,8 +491,22 @@ void *ExecutionEngine::getPointerToGlobal(const GlobalValue *GV) {
/// @brief Get a GenericValue for a Constant*
GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
// If its undefined, return the garbage.
- if (isa<UndefValue>(C))
- return GenericValue();
+ if (isa<UndefValue>(C)) {
+ GenericValue Result;
+ switch (C->getType()->getTypeID()) {
+ case Type::IntegerTyID:
+ case Type::X86_FP80TyID:
+ case Type::FP128TyID:
+ case Type::PPC_FP128TyID:
+ // Although the value is undefined, we still have to construct an APInt
+ // with the correct bit width.
+ Result.IntVal = APInt(C->getType()->getPrimitiveSizeInBits(), 0);
+ break;
+ default:
+ break;
+ }
+ return Result;
+ }
// If the value is a ConstantExpr
if (const ConstantExpr *CE = dyn_cast<ConstantExpr>(C)) {
@@ -620,13 +632,11 @@ GenericValue ExecutionEngine::getConstantValue(const Constant *C) {
GV.DoubleVal = GV.IntVal.bitsToDouble();
break;
case Type::FloatTyID:
- assert(DestTy == Type::getInt32Ty(DestTy->getContext()) &&
- "Invalid bitcast");
+ assert(DestTy->isInteger(32) && "Invalid bitcast");
GV.IntVal.floatToBits(GV.FloatVal);
break;
case Type::DoubleTyID:
- assert(DestTy == Type::getInt64Ty(DestTy->getContext()) &&
- "Invalid bitcast");
+ assert(DestTy->isInteger(64) && "Invalid bitcast");
GV.IntVal.doubleToBits(GV.DoubleVal);
break;
case Type::PointerTyID:
@@ -832,7 +842,7 @@ void ExecutionEngine::StoreValueToMemory(const GenericValue &Val,
*((PointerTy*)Ptr) = Val.PointerVal;
break;
default:
- errs() << "Cannot store value of type " << *Ty << "!\n";
+ dbgs() << "Cannot store value of type " << *Ty << "!\n";
}
if (sys::isLittleEndianHost() != getTargetData()->isLittleEndian())
@@ -908,7 +918,7 @@ void ExecutionEngine::LoadValueFromMemory(GenericValue &Result,
// specified memory location...
//
void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
- DEBUG(errs() << "JIT: Initializing " << Addr << " ");
+ DEBUG(dbgs() << "JIT: Initializing " << Addr << " ");
DEBUG(Init->dump());
if (isa<UndefValue>(Init)) {
return;
@@ -939,7 +949,7 @@ void ExecutionEngine::InitializeMemory(const Constant *Init, void *Addr) {
return;
}
- errs() << "Bad Type: " << *Init->getType() << "\n";
+ dbgs() << "Bad Type: " << *Init->getType() << "\n";
llvm_unreachable("Unknown constant type to initialize memory with!");
}
diff --git a/lib/ExecutionEngine/ExecutionEngineBindings.cpp b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
index 5901cd7..412b493 100644
--- a/lib/ExecutionEngine/ExecutionEngineBindings.cpp
+++ b/lib/ExecutionEngine/ExecutionEngineBindings.cpp
@@ -24,7 +24,7 @@ using namespace llvm;
LLVMGenericValueRef LLVMCreateGenericValueOfInt(LLVMTypeRef Ty,
unsigned long long N,
- int IsSigned) {
+ LLVMBool IsSigned) {
GenericValue *GenVal = new GenericValue();
GenVal->IntVal = APInt(unwrap<IntegerType>(Ty)->getBitWidth(), N, IsSigned);
return wrap(GenVal);
@@ -56,7 +56,7 @@ unsigned LLVMGenericValueIntWidth(LLVMGenericValueRef GenValRef) {
}
unsigned long long LLVMGenericValueToInt(LLVMGenericValueRef GenValRef,
- int IsSigned) {
+ LLVMBool IsSigned) {
GenericValue *GenVal = unwrap(GenValRef);
if (IsSigned)
return GenVal->IntVal.getSExtValue();
@@ -87,9 +87,9 @@ void LLVMDisposeGenericValue(LLVMGenericValueRef GenVal) {
/*===-- Operations on execution engines -----------------------------------===*/
-int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
- LLVMModuleProviderRef MP,
- char **OutError) {
+LLVMBool LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
+ LLVMModuleProviderRef MP,
+ char **OutError) {
std::string Error;
EngineBuilder builder(unwrap(MP));
builder.setEngineKind(EngineKind::Either)
@@ -102,9 +102,9 @@ int LLVMCreateExecutionEngine(LLVMExecutionEngineRef *OutEE,
return 1;
}
-int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
- LLVMModuleProviderRef MP,
- char **OutError) {
+LLVMBool LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
+ LLVMModuleProviderRef MP,
+ char **OutError) {
std::string Error;
EngineBuilder builder(unwrap(MP));
builder.setEngineKind(EngineKind::Interpreter)
@@ -117,10 +117,10 @@ int LLVMCreateInterpreter(LLVMExecutionEngineRef *OutInterp,
return 1;
}
-int LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
- LLVMModuleProviderRef MP,
- unsigned OptLevel,
- char **OutError) {
+LLVMBool LLVMCreateJITCompiler(LLVMExecutionEngineRef *OutJIT,
+ LLVMModuleProviderRef MP,
+ unsigned OptLevel,
+ char **OutError) {
std::string Error;
EngineBuilder builder(unwrap(MP));
builder.setEngineKind(EngineKind::JIT)
@@ -177,9 +177,9 @@ void LLVMAddModuleProvider(LLVMExecutionEngineRef EE, LLVMModuleProviderRef MP){
unwrap(EE)->addModuleProvider(unwrap(MP));
}
-int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
- LLVMModuleProviderRef MP,
- LLVMModuleRef *OutMod, char **OutError) {
+LLVMBool LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
+ LLVMModuleProviderRef MP,
+ LLVMModuleRef *OutMod, char **OutError) {
std::string Error;
if (Module *Gone = unwrap(EE)->removeModuleProvider(unwrap(MP), &Error)) {
*OutMod = wrap(Gone);
@@ -190,8 +190,8 @@ int LLVMRemoveModuleProvider(LLVMExecutionEngineRef EE,
return 1;
}
-int LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
- LLVMValueRef *OutFn) {
+LLVMBool LLVMFindFunction(LLVMExecutionEngineRef EE, const char *Name,
+ LLVMValueRef *OutFn) {
if (Function *F = unwrap(EE)->FindFunctionNamed(Name)) {
*OutFn = wrap(F);
return 0;
diff --git a/lib/ExecutionEngine/Interpreter/Execution.cpp b/lib/ExecutionEngine/Interpreter/Execution.cpp
index b59cfd1..73f5558 100644
--- a/lib/ExecutionEngine/Interpreter/Execution.cpp
+++ b/lib/ExecutionEngine/Interpreter/Execution.cpp
@@ -56,7 +56,7 @@ static void executeFAddInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(+, Float);
IMPLEMENT_BINARY_OPERATOR(+, Double);
default:
- errs() << "Unhandled type for FAdd instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FAdd instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -67,7 +67,7 @@ static void executeFSubInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(-, Float);
IMPLEMENT_BINARY_OPERATOR(-, Double);
default:
- errs() << "Unhandled type for FSub instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FSub instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -78,7 +78,7 @@ static void executeFMulInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(*, Float);
IMPLEMENT_BINARY_OPERATOR(*, Double);
default:
- errs() << "Unhandled type for FMul instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FMul instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -89,7 +89,7 @@ static void executeFDivInst(GenericValue &Dest, GenericValue Src1,
IMPLEMENT_BINARY_OPERATOR(/, Float);
IMPLEMENT_BINARY_OPERATOR(/, Double);
default:
- errs() << "Unhandled type for FDiv instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FDiv instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -104,7 +104,7 @@ static void executeFRemInst(GenericValue &Dest, GenericValue Src1,
Dest.DoubleVal = fmod(Src1.DoubleVal, Src2.DoubleVal);
break;
default:
- errs() << "Unhandled type for Rem instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for Rem instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
}
@@ -131,7 +131,7 @@ static GenericValue executeICMP_EQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(eq,Ty);
IMPLEMENT_POINTER_ICMP(==);
default:
- errs() << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_EQ predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -144,7 +144,7 @@ static GenericValue executeICMP_NE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ne,Ty);
IMPLEMENT_POINTER_ICMP(!=);
default:
- errs() << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_NE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -157,7 +157,7 @@ static GenericValue executeICMP_ULT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ult,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
- errs() << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_ULT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -170,7 +170,7 @@ static GenericValue executeICMP_SLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(slt,Ty);
IMPLEMENT_POINTER_ICMP(<);
default:
- errs() << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_SLT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -183,7 +183,7 @@ static GenericValue executeICMP_UGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ugt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
- errs() << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_UGT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -196,7 +196,7 @@ static GenericValue executeICMP_SGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sgt,Ty);
IMPLEMENT_POINTER_ICMP(>);
default:
- errs() << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_SGT predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -209,7 +209,7 @@ static GenericValue executeICMP_ULE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(ule,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
- errs() << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_ULE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -222,7 +222,7 @@ static GenericValue executeICMP_SLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sle,Ty);
IMPLEMENT_POINTER_ICMP(<=);
default:
- errs() << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_SLE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -235,7 +235,7 @@ static GenericValue executeICMP_UGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(uge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
- errs() << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_UGE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -248,7 +248,7 @@ static GenericValue executeICMP_SGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_INTEGER_ICMP(sge,Ty);
IMPLEMENT_POINTER_ICMP(>=);
default:
- errs() << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
+ dbgs() << "Unhandled type for ICMP_SGE predicate: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -273,7 +273,7 @@ void Interpreter::visitICmpInst(ICmpInst &I) {
case ICmpInst::ICMP_UGE: R = executeICMP_UGE(Src1, Src2, Ty); break;
case ICmpInst::ICMP_SGE: R = executeICMP_SGE(Src1, Src2, Ty); break;
default:
- errs() << "Don't know how to handle this ICmp predicate!\n-->" << I;
+ dbgs() << "Don't know how to handle this ICmp predicate!\n-->" << I;
llvm_unreachable(0);
}
@@ -292,7 +292,7 @@ static GenericValue executeFCMP_OEQ(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(==, Float);
IMPLEMENT_FCMP(==, Double);
default:
- errs() << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp EQ instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -306,7 +306,7 @@ static GenericValue executeFCMP_ONE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(!=, Double);
default:
- errs() << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp NE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -319,7 +319,7 @@ static GenericValue executeFCMP_OLE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<=, Float);
IMPLEMENT_FCMP(<=, Double);
default:
- errs() << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp LE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -332,7 +332,7 @@ static GenericValue executeFCMP_OGE(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>=, Float);
IMPLEMENT_FCMP(>=, Double);
default:
- errs() << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp GE instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -345,7 +345,7 @@ static GenericValue executeFCMP_OLT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(<, Float);
IMPLEMENT_FCMP(<, Double);
default:
- errs() << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp LT instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -358,7 +358,7 @@ static GenericValue executeFCMP_OGT(GenericValue Src1, GenericValue Src2,
IMPLEMENT_FCMP(>, Float);
IMPLEMENT_FCMP(>, Double);
default:
- errs() << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled type for FCmp GT instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
return Dest;
@@ -467,7 +467,7 @@ void Interpreter::visitFCmpInst(FCmpInst &I) {
case FCmpInst::FCMP_UGE: R = executeFCMP_UGE(Src1, Src2, Ty); break;
case FCmpInst::FCMP_OGE: R = executeFCMP_OGE(Src1, Src2, Ty); break;
default:
- errs() << "Don't know how to handle this FCmp predicate!\n-->" << I;
+ dbgs() << "Don't know how to handle this FCmp predicate!\n-->" << I;
llvm_unreachable(0);
}
@@ -513,7 +513,7 @@ static GenericValue executeCmpInst(unsigned predicate, GenericValue Src1,
return Result;
}
default:
- errs() << "Unhandled Cmp predicate\n";
+ dbgs() << "Unhandled Cmp predicate\n";
llvm_unreachable(0);
}
}
@@ -542,7 +542,7 @@ void Interpreter::visitBinaryOperator(BinaryOperator &I) {
case Instruction::Or: R.IntVal = Src1.IntVal | Src2.IntVal; break;
case Instruction::Xor: R.IntVal = Src1.IntVal ^ Src2.IntVal; break;
default:
- errs() << "Don't know how to handle this binary operator!\n-->" << I;
+ dbgs() << "Don't know how to handle this binary operator!\n-->" << I;
llvm_unreachable(0);
}
@@ -602,7 +602,7 @@ void Interpreter::popStackAndReturnValueToCaller(const Type *RetTy,
ExecutionContext &CallingSF = ECStack.back();
if (Instruction *I = CallingSF.Caller.getInstruction()) {
// Save result...
- if (CallingSF.Caller.getType() != Type::getVoidTy(RetTy->getContext()))
+ if (!CallingSF.Caller.getType()->isVoidTy())
SetValue(I, Result, CallingSF);
if (InvokeInst *II = dyn_cast<InvokeInst> (I))
SwitchToNewBasicBlock (II->getNormalDest (), CallingSF);
@@ -744,7 +744,7 @@ void Interpreter::visitAllocaInst(AllocaInst &I) {
// Allocate enough memory to hold the type...
void *Memory = malloc(MemToAlloc);
- DEBUG(errs() << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x "
+ DEBUG(dbgs() << "Allocated Type: " << *Ty << " (" << TypeSize << " bytes) x "
<< NumElements << " (Total: " << MemToAlloc << ") at "
<< uintptr_t(Memory) << '\n');
@@ -794,7 +794,7 @@ GenericValue Interpreter::executeGEPOperation(Value *Ptr, gep_type_iterator I,
GenericValue Result;
Result.PointerVal = ((char*)getOperandValue(Ptr, SF).PointerVal) + Total;
- DEBUG(errs() << "GEP Index " << Total << " bytes.\n");
+ DEBUG(dbgs() << "GEP Index " << Total << " bytes.\n");
return Result;
}
@@ -812,7 +812,7 @@ void Interpreter::visitLoadInst(LoadInst &I) {
LoadValueFromMemory(Result, Ptr, I.getType());
SetValue(&I, Result, SF);
if (I.isVolatile() && PrintVolatile)
- errs() << "Volatile load " << I;
+ dbgs() << "Volatile load " << I;
}
void Interpreter::visitStoreInst(StoreInst &I) {
@@ -822,7 +822,7 @@ void Interpreter::visitStoreInst(StoreInst &I) {
StoreValueToMemory(Val, (GenericValue *)GVTOP(SRC),
I.getOperand(0)->getType());
if (I.isVolatile() && PrintVolatile)
- errs() << "Volatile store: " << I;
+ dbgs() << "Volatile store: " << I;
}
//===----------------------------------------------------------------------===//
@@ -1164,7 +1164,7 @@ void Interpreter::visitVAArgInst(VAArgInst &I) {
IMPLEMENT_VAARG(Float);
IMPLEMENT_VAARG(Double);
default:
- errs() << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
+ dbgs() << "Unhandled dest type for vaarg instruction: " << *Ty << "\n";
llvm_unreachable(0);
}
@@ -1251,7 +1251,7 @@ GenericValue Interpreter::getConstantExprValue (ConstantExpr *CE,
Dest.IntVal = Op0.IntVal.ashr(Op1.IntVal.getZExtValue());
break;
default:
- errs() << "Unhandled ConstantExpr: " << *CE << "\n";
+ dbgs() << "Unhandled ConstantExpr: " << *CE << "\n";
llvm_unreachable(0);
return GenericValue();
}
@@ -1324,24 +1324,24 @@ void Interpreter::run() {
// Track the number of dynamic instructions executed.
++NumDynamicInsts;
- DEBUG(errs() << "About to interpret: " << I);
+ DEBUG(dbgs() << "About to interpret: " << I);
visit(I); // Dispatch to one of the visit* methods...
#if 0
// This is not safe, as visiting the instruction could lower it and free I.
DEBUG(
if (!isa<CallInst>(I) && !isa<InvokeInst>(I) &&
I.getType() != Type::VoidTy) {
- errs() << " --> ";
+ dbgs() << " --> ";
const GenericValue &Val = SF.Values[&I];
switch (I.getType()->getTypeID()) {
default: llvm_unreachable("Invalid GenericValue Type");
- case Type::VoidTyID: errs() << "void"; break;
- case Type::FloatTyID: errs() << "float " << Val.FloatVal; break;
- case Type::DoubleTyID: errs() << "double " << Val.DoubleVal; break;
- case Type::PointerTyID: errs() << "void* " << intptr_t(Val.PointerVal);
+ case Type::VoidTyID: dbgs() << "void"; break;
+ case Type::FloatTyID: dbgs() << "float " << Val.FloatVal; break;
+ case Type::DoubleTyID: dbgs() << "double " << Val.DoubleVal; break;
+ case Type::PointerTyID: dbgs() << "void* " << intptr_t(Val.PointerVal);
break;
case Type::IntegerTyID:
- errs() << "i" << Val.IntVal.getBitWidth() << " "
+ dbgs() << "i" << Val.IntVal.getBitWidth() << " "
<< Val.IntVal.toStringUnsigned(10)
<< " (0x" << Val.IntVal.toStringUnsigned(16) << ")\n";
break;
diff --git a/lib/ExecutionEngine/JIT/JIT.cpp b/lib/ExecutionEngine/JIT/JIT.cpp
index ebc2567..faf724f 100644
--- a/lib/ExecutionEngine/JIT/JIT.cpp
+++ b/lib/ExecutionEngine/JIT/JIT.cpp
@@ -411,11 +411,10 @@ GenericValue JIT::runFunction(Function *F,
// Handle some common cases first. These cases correspond to common `main'
// prototypes.
- if (RetTy == Type::getInt32Ty(F->getContext()) ||
- RetTy == Type::getVoidTy(F->getContext())) {
+ if (RetTy->isInteger(32) || RetTy->isVoidTy()) {
switch (ArgValues.size()) {
case 3:
- if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
+ if (FTy->getParamType(0)->isInteger(32) &&
isa<PointerType>(FTy->getParamType(1)) &&
isa<PointerType>(FTy->getParamType(2))) {
int (*PF)(int, char **, const char **) =
@@ -430,7 +429,7 @@ GenericValue JIT::runFunction(Function *F,
}
break;
case 2:
- if (FTy->getParamType(0) == Type::getInt32Ty(F->getContext()) &&
+ if (FTy->getParamType(0)->isInteger(32) &&
isa<PointerType>(FTy->getParamType(1))) {
int (*PF)(int, char **) = (int(*)(int, char **))(intptr_t)FPtr;
@@ -443,7 +442,7 @@ GenericValue JIT::runFunction(Function *F,
break;
case 1:
if (FTy->getNumParams() == 1 &&
- FTy->getParamType(0) == Type::getInt32Ty(F->getContext())) {
+ FTy->getParamType(0)->isInteger(32)) {
GenericValue rv;
int (*PF)(int) = (int(*)(int))(intptr_t)FPtr;
rv.IntVal = APInt(32, PF(ArgValues[0].IntVal.getZExtValue()));
@@ -548,7 +547,7 @@ GenericValue JIT::runFunction(Function *F,
"", StubBB);
TheCall->setCallingConv(F->getCallingConv());
TheCall->setTailCall();
- if (TheCall->getType() != Type::getVoidTy(F->getContext()))
+ if (!TheCall->getType()->isVoidTy())
// Return result of the call.
ReturnInst::Create(F->getContext(), TheCall, StubBB);
else
diff --git a/lib/ExecutionEngine/JIT/JITEmitter.cpp b/lib/ExecutionEngine/JIT/JITEmitter.cpp
index ef323b5..0f604ac 100644
--- a/lib/ExecutionEngine/JIT/JITEmitter.cpp
+++ b/lib/ExecutionEngine/JIT/JITEmitter.cpp
@@ -377,7 +377,7 @@ namespace {
MemMgr = JMM ? JMM : JITMemoryManager::CreateDefaultMemManager();
if (jit.getJITInfo().needsGOT()) {
MemMgr->AllocateGOT();
- DEBUG(errs() << "JIT is managing a GOT\n");
+ DEBUG(dbgs() << "JIT is managing a GOT\n");
}
if (DwarfExceptionHandling || JITEmitDebugInfo) {
@@ -431,7 +431,7 @@ namespace {
if (MBBLocations.size() <= (unsigned)MBB->getNumber())
MBBLocations.resize((MBB->getNumber()+1)*2);
MBBLocations[MBB->getNumber()] = getCurrentPCValue();
- DEBUG(errs() << "JIT: Emitting BB" << MBB->getNumber() << " at ["
+ DEBUG(dbgs() << "JIT: Emitting BB" << MBB->getNumber() << " at ["
<< (void*) getCurrentPCValue() << "]\n");
}
@@ -547,7 +547,7 @@ void *JITResolver::getLazyFunctionStub(Function *F) {
TheJIT->updateGlobalMapping(F, Stub);
}
- DEBUG(errs() << "JIT: Lazy stub emitted at [" << Stub << "] for function '"
+ DEBUG(dbgs() << "JIT: Lazy stub emitted at [" << Stub << "] for function '"
<< F->getName() << "'\n");
// Finally, keep track of the stub-to-Function mapping so that the
@@ -577,7 +577,7 @@ void *JITResolver::getGlobalValueIndirectSym(GlobalValue *GV, void *GVAddress) {
IndirectSym = TheJIT->getJITInfo().emitGlobalValueIndirectSym(GV, GVAddress,
JE);
- DEBUG(errs() << "JIT: Indirect symbol emitted at [" << IndirectSym
+ DEBUG(dbgs() << "JIT: Indirect symbol emitted at [" << IndirectSym
<< "] for GV '" << GV->getName() << "'\n");
return IndirectSym;
@@ -595,7 +595,7 @@ void *JITResolver::getExternalFunctionStub(void *FnAddr) {
Stub = TheJIT->getJITInfo().emitFunctionStub(0, FnAddr, JE);
JE.finishGVStub();
- DEBUG(errs() << "JIT: Stub emitted at [" << Stub
+ DEBUG(dbgs() << "JIT: Stub emitted at [" << Stub
<< "] for external function at '" << FnAddr << "'\n");
return Stub;
}
@@ -605,7 +605,7 @@ unsigned JITResolver::getGOTIndexForAddr(void* addr) {
if (!idx) {
idx = ++nextGOTIndex;
revGOTMap[addr] = idx;
- DEBUG(errs() << "JIT: Adding GOT entry " << idx << " for addr ["
+ DEBUG(dbgs() << "JIT: Adding GOT entry " << idx << " for addr ["
<< addr << "]\n");
}
return idx;
@@ -701,7 +701,7 @@ void *JITResolver::JITCompilerFn(void *Stub) {
+ F->getName() + "' when lazy compiles are disabled!");
}
- DEBUG(errs() << "JIT: Lazily resolving function '" << F->getName()
+ DEBUG(dbgs() << "JIT: Lazily resolving function '" << F->getName()
<< "' In stub ptr = " << Stub << " actual ptr = "
<< ActualPtr << "\n");
@@ -864,7 +864,7 @@ unsigned JITEmitter::addSizeOfGlobal(const GlobalVariable *GV, unsigned Size) {
size_t GVSize = (size_t)TheJIT->getTargetData()->getTypeAllocSize(ElTy);
size_t GVAlign =
(size_t)TheJIT->getTargetData()->getPreferredAlignment(GV);
- DEBUG(errs() << "JIT: Adding in size " << GVSize << " alignment " << GVAlign);
+ DEBUG(dbgs() << "JIT: Adding in size " << GVSize << " alignment " << GVAlign);
DEBUG(GV->dump());
// Assume code section ends with worst possible alignment, so first
// variable needs maximal padding.
@@ -992,7 +992,7 @@ unsigned JITEmitter::GetSizeOfGlobalsInBytes(MachineFunction &MF) {
}
}
}
- DEBUG(errs() << "JIT: About to look through initializers\n");
+ DEBUG(dbgs() << "JIT: About to look through initializers\n");
// Look for more globals that are referenced only from initializers.
// GVSet.end is computed each time because the set can grow as we go.
for (SmallPtrSet<const GlobalVariable *, 8>::iterator I = GVSet.begin();
@@ -1006,14 +1006,14 @@ unsigned JITEmitter::GetSizeOfGlobalsInBytes(MachineFunction &MF) {
}
void JITEmitter::startFunction(MachineFunction &F) {
- DEBUG(errs() << "JIT: Starting CodeGen of Function "
+ DEBUG(dbgs() << "JIT: Starting CodeGen of Function "
<< F.getFunction()->getName() << "\n");
uintptr_t ActualSize = 0;
// Set the memory writable, if it's not already
MemMgr->setMemoryWritable();
if (MemMgr->NeedsExactSize()) {
- DEBUG(errs() << "JIT: ExactSize\n");
+ DEBUG(dbgs() << "JIT: ExactSize\n");
const TargetInstrInfo* TII = F.getTarget().getInstrInfo();
MachineJumpTableInfo *MJTI = F.getJumpTableInfo();
MachineConstantPool *MCP = F.getConstantPool();
@@ -1040,12 +1040,12 @@ void JITEmitter::startFunction(MachineFunction &F) {
// Add the function size
ActualSize += TII->GetFunctionSizeInBytes(F);
- DEBUG(errs() << "JIT: ActualSize before globals " << ActualSize << "\n");
+ DEBUG(dbgs() << "JIT: ActualSize before globals " << ActualSize << "\n");
// Add the size of the globals that will be allocated after this function.
// These are all the ones referenced from this function that were not
// previously allocated.
ActualSize += GetSizeOfGlobalsInBytes(F);
- DEBUG(errs() << "JIT: ActualSize after globals " << ActualSize << "\n");
+ DEBUG(dbgs() << "JIT: ActualSize after globals " << ActualSize << "\n");
} else if (SizeEstimate > 0) {
// SizeEstimate will be non-zero on reallocation attempts.
ActualSize = SizeEstimate;
@@ -1104,7 +1104,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
if (MR.isExternalSymbol()) {
ResultPtr = TheJIT->getPointerToNamedFunction(MR.getExternalSymbol(),
false);
- DEBUG(errs() << "JIT: Map \'" << MR.getExternalSymbol() << "\' to ["
+ DEBUG(dbgs() << "JIT: Map \'" << MR.getExternalSymbol() << "\' to ["
<< ResultPtr << "]\n");
// If the target REALLY wants a stub for this function, emit it now.
@@ -1136,7 +1136,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
unsigned idx = Resolver.getGOTIndexForAddr(ResultPtr);
MR.setGOTIndex(idx);
if (((void**)MemMgr->getGOTBase())[idx] != ResultPtr) {
- DEBUG(errs() << "JIT: GOT was out of date for " << ResultPtr
+ DEBUG(dbgs() << "JIT: GOT was out of date for " << ResultPtr
<< " pointing at " << ((void**)MemMgr->getGOTBase())[idx]
<< "\n");
((void**)MemMgr->getGOTBase())[idx] = ResultPtr;
@@ -1153,7 +1153,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
if (MemMgr->isManagingGOT()) {
unsigned idx = Resolver.getGOTIndexForAddr((void*)BufferBegin);
if (((void**)MemMgr->getGOTBase())[idx] != (void*)BufferBegin) {
- DEBUG(errs() << "JIT: GOT was out of date for " << (void*)BufferBegin
+ DEBUG(dbgs() << "JIT: GOT was out of date for " << (void*)BufferBegin
<< " pointing at " << ((void**)MemMgr->getGOTBase())[idx]
<< "\n");
((void**)MemMgr->getGOTBase())[idx] = (void*)BufferBegin;
@@ -1182,7 +1182,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
TheJIT->NotifyFunctionEmitted(*F.getFunction(), FnStart, FnEnd-FnStart,
EmissionDetails);
- DEBUG(errs() << "JIT: Finished CodeGen of [" << (void*)FnStart
+ DEBUG(dbgs() << "JIT: Finished CodeGen of [" << (void*)FnStart
<< "] Function: " << F.getFunction()->getName()
<< ": " << (FnEnd-FnStart) << " bytes of text, "
<< Relocations.size() << " relocations\n");
@@ -1195,31 +1195,31 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
DEBUG(
if (sys::hasDisassembler()) {
- errs() << "JIT: Disassembled code:\n";
- errs() << sys::disassembleBuffer(FnStart, FnEnd-FnStart,
+ dbgs() << "JIT: Disassembled code:\n";
+ dbgs() << sys::disassembleBuffer(FnStart, FnEnd-FnStart,
(uintptr_t)FnStart);
} else {
- errs() << "JIT: Binary code:\n";
+ dbgs() << "JIT: Binary code:\n";
uint8_t* q = FnStart;
for (int i = 0; q < FnEnd; q += 4, ++i) {
if (i == 4)
i = 0;
if (i == 0)
- errs() << "JIT: " << (long)(q - FnStart) << ": ";
+ dbgs() << "JIT: " << (long)(q - FnStart) << ": ";
bool Done = false;
for (int j = 3; j >= 0; --j) {
if (q + j >= FnEnd)
Done = true;
else
- errs() << (unsigned short)q[j];
+ dbgs() << (unsigned short)q[j];
}
if (Done)
break;
- errs() << ' ';
+ dbgs() << ' ';
if (i == 3)
- errs() << '\n';
+ dbgs() << '\n';
}
- errs()<< '\n';
+ dbgs()<< '\n';
}
);
@@ -1268,7 +1268,7 @@ bool JITEmitter::finishFunction(MachineFunction &F) {
}
void JITEmitter::retryWithMoreMemory(MachineFunction &F) {
- DEBUG(errs() << "JIT: Ran out of space for native code. Reattempting.\n");
+ DEBUG(dbgs() << "JIT: Ran out of space for native code. Reattempting.\n");
Relocations.clear(); // Clear the old relocations or we'll reapply them.
ConstPoolAddresses.clear();
++NumRetries;
@@ -1319,7 +1319,7 @@ void JITEmitter::deallocateMemForFunction(const Function *F) {
// in the JITResolver. Were there a memory manager deallocateStub routine,
// we could call that at this point too.
if (FnRefs.empty()) {
- DEBUG(errs() << "\nJIT: Invalidated Stub at [" << Stub << "]\n");
+ DEBUG(dbgs() << "\nJIT: Invalidated Stub at [" << Stub << "]\n");
StubFnRefs.erase(Stub);
// Invalidate the stub. If it is a GV stub, update the JIT's global
@@ -1365,7 +1365,7 @@ void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
if (ConstantPoolBase == 0) return; // Buffer overflow.
- DEBUG(errs() << "JIT: Emitted constant pool at [" << ConstantPoolBase
+ DEBUG(dbgs() << "JIT: Emitted constant pool at [" << ConstantPoolBase
<< "] (size: " << Size << ", alignment: " << Align << ")\n");
// Initialize the memory for all of the constant pool entries.
@@ -1383,8 +1383,8 @@ void JITEmitter::emitConstantPool(MachineConstantPool *MCP) {
"entry has not been implemented!");
}
TheJIT->InitializeMemory(CPE.Val.ConstVal, (void*)CAddr);
- DEBUG(errs() << "JIT: CP" << i << " at [0x";
- errs().write_hex(CAddr) << "]\n");
+ DEBUG(dbgs() << "JIT: CP" << i << " at [0x";
+ dbgs().write_hex(CAddr) << "]\n");
const Type *Ty = CPE.Val.ConstVal->getType();
Offset += TheJIT->getTargetData()->getTypeAllocSize(Ty);
diff --git a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
index 80cb999..a17caa1 100644
--- a/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
+++ b/lib/ExecutionEngine/JIT/JITMemoryManager.cpp
@@ -352,7 +352,7 @@ namespace {
// another block of memory and add it to the free list.
if (largest < ActualSize ||
largest <= FreeRangeHeader::getMinBlockSize()) {
- DEBUG(errs() << "JIT: Allocating another slab of memory for function.");
+ DEBUG(dbgs() << "JIT: Allocating another slab of memory for function.");
candidateBlock = allocateNewCodeSlab((size_t)ActualSize);
}
diff --git a/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp b/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp
index 52a8f71..d01c4b2 100644
--- a/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp
+++ b/lib/ExecutionEngine/JIT/OProfileJITEventListener.cpp
@@ -50,9 +50,9 @@ OProfileJITEventListener::OProfileJITEventListener()
: Agent(op_open_agent()) {
if (Agent == NULL) {
const std::string err_str = sys::StrError();
- DEBUG(errs() << "Failed to connect to OProfile agent: " << err_str << "\n");
+ DEBUG(dbgs() << "Failed to connect to OProfile agent: " << err_str << "\n");
} else {
- DEBUG(errs() << "Connected to OProfile agent.\n");
+ DEBUG(dbgs() << "Connected to OProfile agent.\n");
}
}
@@ -60,10 +60,10 @@ OProfileJITEventListener::~OProfileJITEventListener() {
if (Agent != NULL) {
if (op_close_agent(Agent) == -1) {
const std::string err_str = sys::StrError();
- DEBUG(errs() << "Failed to disconnect from OProfile agent: "
+ DEBUG(dbgs() << "Failed to disconnect from OProfile agent: "
<< err_str << "\n");
} else {
- DEBUG(errs() << "Disconnected from OProfile agent.\n");
+ DEBUG(dbgs() << "Disconnected from OProfile agent.\n");
}
}
}
@@ -92,7 +92,7 @@ static debug_line_info LineStartToOProfileFormat(
const DebugLocTuple &tuple = MF.getDebugLocTuple(Loc);
Result.lineno = tuple.Line;
Result.filename = Filenames.getFilename(tuple.Scope);
- DEBUG(errs() << "Mapping " << reinterpret_cast<void*>(Result.vma) << " to "
+ DEBUG(dbgs() << "Mapping " << reinterpret_cast<void*>(Result.vma) << " to "
<< Result.filename << ":" << Result.lineno << "\n");
return Result;
}
@@ -105,7 +105,7 @@ void OProfileJITEventListener::NotifyFunctionEmitted(
if (op_write_native_code(Agent, F.getName().data(),
reinterpret_cast<uint64_t>(FnStart),
FnStart, FnSize) == -1) {
- DEBUG(errs() << "Failed to tell OProfile about native function "
+ DEBUG(dbgs() << "Failed to tell OProfile about native function "
<< F.getName() << " at ["
<< FnStart << "-" << ((char*)FnStart + FnSize) << "]\n");
return;
@@ -133,7 +133,7 @@ void OProfileJITEventListener::NotifyFunctionEmitted(
if (!LineInfo.empty()) {
if (op_write_debug_line_info(Agent, FnStart,
LineInfo.size(), &*LineInfo.begin()) == -1) {
- DEBUG(errs()
+ DEBUG(dbgs()
<< "Failed to tell OProfile about line numbers for native function "
<< F.getName() << " at ["
<< FnStart << "-" << ((char*)FnStart + FnSize) << "]\n");
@@ -145,7 +145,7 @@ void OProfileJITEventListener::NotifyFunctionEmitted(
void OProfileJITEventListener::NotifyFreeingMachineCode(void *FnStart) {
assert(FnStart && "Invalid function pointer");
if (op_unload_native_code(Agent, reinterpret_cast<uint64_t>(FnStart)) == -1) {
- DEBUG(errs()
+ DEBUG(dbgs()
<< "Failed to tell OProfile about unload of native function at "
<< FnStart << "\n");
}
OpenPOWER on IntegriCloud