Fix triggered an assetion when replacing __cl_printf
Fix LLVM assertion was triggered when replacing calls to __cl_printf
to __pocl_printf due to return value type mismatch.  LLVM changed
return value of __cl_printf to void when no one was using the value
and thus lead to the issue.
@@ -546,9 +546,15 @@ static void replacePrintfCalls(Value *pb, Value *pbp, Value *pbc, bool isKernel,
CallInst *CI = it.first;
CallInst *newCI = it.second;
+ // LLVM may modify the result type of the called function to void.
+ if (CI->getType()->isVoidTy()) {
+ newCI->insertBefore(CI);
+ CI->eraseFromParent();
+ } else {
CI->replaceAllUsesWith(newCI);
ReplaceInstWithInst(CI, newCI);
}
+ }
replaceCIMap.clear();
