Skip to content

Commit

Permalink
Emit recoverable errors in VC
Browse files Browse the repository at this point in the history
VC emits recoverable errors, when it's possible. This is required for
online compilation, where the device compiler should not terminate the
user's application.
  • Loading branch information
vmustya authored and igcbot committed Sep 20, 2024
1 parent e22d8fd commit 60b6d28
Show file tree
Hide file tree
Showing 13 changed files with 172 additions and 138 deletions.
8 changes: 1 addition & 7 deletions IGC/VectorCompiler/include/vc/Utils/GenX/KernelInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -143,15 +143,9 @@ template <typename Ty = llvm::Value> Ty *getValueAsMetadata(llvm::Metadata *M) {
static unsigned alignBarrierCnt(unsigned BarrierCnt) {
if (BarrierCnt == 0)
return 0;
if (BarrierCnt > 32) {
llvm::report_fatal_error("named barrier count must not exceed 32");
return 0;
}
if (BarrierCnt > 16 && BarrierCnt <= 24)
return 24;
if (llvm::isPowerOf2_32(BarrierCnt))
return BarrierCnt;
return llvm::NextPowerOf2(BarrierCnt);
return llvm::PowerOf2Ceil(BarrierCnt);
}

struct ImplicitLinearizationInfo {
Expand Down
3 changes: 2 additions & 1 deletion IGC/VectorCompiler/lib/GenXCodeGen/ConstantEncoder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,8 @@ encodeGlobalValue(const GlobalValue &GV, const DataLayout &DL) {
RelType = vISA::GenRelocType::R_SYM_ADDR;
break;
default:
report_fatal_error("Relocation of the provided pointer is not supported");
vc::diagnose(GV.getContext(), "ConstantEncoder",
"Relocation of the provided pointer is not supported", &GV);
}
return {APInt::getNullValue(Size.inBits()),
{vISA::ZERelocEntry{RelType, 0, GV.getName().str()}}};
Expand Down
12 changes: 8 additions & 4 deletions IGC/VectorCompiler/lib/GenXCodeGen/GenXBuiltinFunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ SPDX-License-Identifier: MIT
#include "GenXSubtarget.h"
#include "GenXTargetMachine.h"

#include "vc/Support/GenXDiagnostic.h"
#include "vc/Utils/GenX/IntrinsicsWrapper.h"
#include "vc/Utils/GenX/KernelInfo.h"
#include "vc/Utils/General/BiF.h"
Expand Down Expand Up @@ -113,10 +114,13 @@ bool GenXBuiltinFunctions::runOnModule(Module &M) {
.getTM<GenXTargetMachine>()
.getGenXSubtarget();

auto Lib =
loadBuiltinLib(M.getContext(), M.getDataLayout(), M.getTargetTriple());
if (Lib && Linker::linkModules(M, std::move(Lib)))
report_fatal_error("Error linking built-in functions");
auto &Ctx = M.getContext();
auto Lib = loadBuiltinLib(Ctx, M.getDataLayout(), M.getTargetTriple());
if (Lib && Linker::linkModules(M, std::move(Lib))) {
vc::diagnose(Ctx, "GenXBuiltinFunctions",
"Error linking built-in functions");
return true;
}

for (auto &F : M.getFunctionList())
runOnFunction(F);
Expand Down
Loading

0 comments on commit 60b6d28

Please sign in to comment.