Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 35 additions & 1 deletion llvm/lib/CheerpWriter/PreExecute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,38 @@ static GenericValue pre_execute_typed_ptrcast(FunctionType* FT, ArrayRef<Generic
return Args[0];
}

static GenericValue pre_execute_print_value_handler(FunctionType *FT,
ArrayRef<GenericValue> Args, AttributeList Attrs)

{
ExecutionEngine *currentEE = PreExecute::currentPreExecutePass->currentEE;
const char* msg = reinterpret_cast <char*>(currentEE->GVTORP(Args[0]));

llvm::errs() << msg;

for (int i = 1; i < Args.size(); ++i){
Type* valueType = FT->getParamType(i);

if (valueType->isDoubleTy()){
llvm::errs() << " " << llvm::format("%.10f", Args[i].DoubleVal);
}
else if (valueType->isFloatTy()){
llvm::errs() << " " << llvm::format("%.10f", Args[i].FloatVal);
}
else if (valueType->isIntegerTy()){
llvm::errs() << " " << Args[i].IntVal.getSExtValue();
}
else if (valueType->isPointerTy()){
llvm::errs() << " " << reinterpret_cast<char *>(currentEE->GVTORP(Args[i]));
}
else if (valueType)
llvm::errs() << " incompatible value type";
}

llvm::errs() << "\n";
return GenericValue(0);
}

static GenericValue assertEqualImpl(FunctionType *FT,
ArrayRef<GenericValue> Args, AttributeList Attrs)
{
Expand Down Expand Up @@ -561,8 +593,10 @@ static void* LazyFunctionCreator(const std::string& funcName)
return (void*)(void(*)())pre_execute_smax;
if (strncmp(funcName.c_str(), "llvm.abs.", strlen("llvm.abs."))==0)
return (void*)(void(*)())pre_execute_abs;
if (strcmp(funcName.c_str(), "assertEqualImpl") == 0)
if (strcmp(funcName.c_str(), "assertEqualImpl")==0)
return (void*)(void(*)())assertEqualImpl;
if (funcName.find("__preexecute_print_case") != std::string::npos)
return (void*)(void(*)())pre_execute_print_value_handler;
if (strcmp(funcName.c_str(), "llvm.dbg.value") == 0)
return (void*)(void(*)())emptyFunction;

Expand Down
Loading