Skip to content

Commit 031c5c6

Browse files
lukaszgotszaldintelsys_zuul
authored andcommitted
replace "report_fatal_error" in IGC/Compiler by IGC_ASSERT_EXIT
Change-Id: I4b30478676af1bfbfcefae9b43b35ee7252cef46
1 parent f654be0 commit 031c5c6

File tree

2 files changed

+30
-30
lines changed

2 files changed

+30
-30
lines changed

IGC/Compiler/Optimizer/OpenCLPasses/DeviceEnqueueFuncs/TransformBlocks.cpp

Lines changed: 29 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -718,7 +718,7 @@ namespace //Anonymous
718718
, _waitEventsList(nullptr)
719719
, _retEvent(nullptr)
720720
{
721-
if (_calledFunc == nullptr) report_fatal_error("indirect calls are not supported");
721+
IGC_ASSERT_EXIT_MESSAGE(nullptr != _calledFunc, "indirect calls are not supported");
722722
}
723723

724724
public:
@@ -746,7 +746,7 @@ namespace //Anonymous
746746
virtual llvm::Function* getEnqueuedFunction()
747747
{
748748
auto invokeFunc = dyn_cast<llvm::Function>(getInvokeArg()->stripPointerCasts());
749-
if (invokeFunc == nullptr) report_fatal_error("Device enqueue invoke param is not a function");
749+
IGC_ASSERT_EXIT_MESSAGE(nullptr != invokeFunc, "Device enqueue invoke param is not a function");
750750
return invokeFunc;
751751
}
752752

@@ -823,7 +823,7 @@ namespace //Anonymous
823823
}
824824
else
825825
{
826-
report_fatal_error("enqueue_kernel signature does not match");
826+
IGC_ASSERT_EXIT_MESSAGE(0, "enqueue_kernel signature does not match");
827827
}
828828
}
829829
}
@@ -884,7 +884,7 @@ namespace //Anonymous
884884
SPIRVOpEnqueueKernelCallArgs(llvm::CallInst& call, DataContext& dataContext)
885885
: DeviceExecCallArgs(call, dataContext)
886886
{
887-
if (_call.getNumArgOperands() < 8) report_fatal_error("OpEnqueueKernel signature does not match");
887+
IGC_ASSERT_EXIT_MESSAGE(8 <= _call.getNumArgOperands(), "OpEnqueueKernel signature does not match");
888888

889889
_queue = _call.getArgOperand(0);
890890
_flags = _call.getArgOperand(1);
@@ -908,19 +908,23 @@ namespace //Anonymous
908908
for (unsigned i = localSizesStartArgNum; i < argsNum; i++)
909909
{
910910
auto arg = _call.getArgOperand(i);
911+
IGC_ASSERT(nullptr != arg);
912+
IGC_ASSERT(nullptr != arg->getType());
913+
911914
if (arg->getType()->isPointerTy()) {
912915
IRBuilder<> builder(&_call);
913916
arg = builder.CreateLoad(arg);
914917
}
915918

916-
if (!arg->getType()->isIntegerTy(64) && !arg->getType()->isIntegerTy(32))
917-
report_fatal_error("OpEnqueueKernel signature does not match");
918-
919919
if (arg->getType()->isIntegerTy(64))
920920
{
921921
Type* int32Ty = Type::getInt32Ty(_call.getParent()->getContext());
922922
arg = CastInst::CreateTruncOrBitCast(arg, int32Ty, "", &_call);
923923
}
924+
else
925+
{
926+
IGC_ASSERT_EXIT_MESSAGE(arg->getType()->isIntegerTy(32), "OpEnqueueKernel signature does not match");
927+
}
924928
_local_sizes.push_back(arg);
925929
}
926930
}
@@ -964,11 +968,11 @@ namespace //Anonymous
964968
llvm::Value* AdjustNDRangeType(llvm::Value* nDRange)
965969
{
966970
auto expectedNdrangeTy = getNDRangeType();
967-
971+
IGC_ASSERT(nullptr != nDRange);
972+
IGC_ASSERT(nullptr != nDRange->getType());
968973
IGC_ASSERT(nDRange->getType()->isPointerTy());
969974
auto actualNDRangeTy = KindQuery::toStructType(nDRange->getType());
970-
IGC_ASSERT(actualNDRangeTy);
971-
if (actualNDRangeTy == nullptr) report_fatal_error("NDRange type mismatch");
975+
IGC_ASSERT_EXIT_MESSAGE(nullptr != actualNDRangeTy, "NDRange type mismatch");
972976

973977
if (actualNDRangeTy->isLayoutIdentical(expectedNdrangeTy))
974978
{
@@ -1016,7 +1020,7 @@ namespace //Anonymous
10161020

10171021
const auto newName = "__builtin_IB_get_block_simd_size";
10181022
auto calledFunction = _deviceExecCall->getCalledFunction();
1019-
if (calledFunction == nullptr) report_fatal_error("indirect calls are not supported");
1023+
IGC_ASSERT_EXIT_MESSAGE(nullptr != calledFunction, "indirect calls are not supported");
10201024
return CreateNewCall(newName, calledFunction->getReturnType(), blockIdValue);
10211025
}
10221026
};
@@ -1031,7 +1035,7 @@ namespace //Anonymous
10311035
{
10321036
const auto newName = "__builtin_IB_get_max_workgroup_size";
10331037
auto calledFunction = _deviceExecCall->getCalledFunction();
1034-
if (calledFunction == nullptr) report_fatal_error("indirect calls are not supported");
1038+
IGC_ASSERT_EXIT_MESSAGE(nullptr != calledFunction, "indirect calls are not supported");
10351039
return CreateNewCall(newName, calledFunction->getReturnType(), {});
10361040
}
10371041
};
@@ -1057,7 +1061,7 @@ namespace //Anonymous
10571061

10581062
const auto newName = "IGIL_calc_sub_group_count_for_ndrange";
10591063
auto calledFunction = _deviceExecCall->getCalledFunction();
1060-
if (calledFunction == nullptr) report_fatal_error("indirect calls are not supported");
1064+
IGC_ASSERT_EXIT_MESSAGE(nullptr != calledFunction, "indirect calls are not supported");
10611065
return CreateNewCall(newName, calledFunction->getReturnType(), args);
10621066
}
10631067
};
@@ -1082,7 +1086,7 @@ namespace //Anonymous
10821086

10831087
const auto newName = "__intel_calc_kernel_local_size_for_sub_group_count";
10841088
auto calledFunction = _deviceExecCall->getCalledFunction();
1085-
if (calledFunction == nullptr) report_fatal_error("indirect calls are not supported");
1089+
IGC_ASSERT_EXIT_MESSAGE(nullptr != calledFunction, "indirect calls are not supported");
10861090
return CreateNewCall(newName, calledFunction->getReturnType(), args);
10871091
}
10881092
};
@@ -1105,7 +1109,7 @@ namespace //Anonymous
11051109

11061110
const auto newName = "__intel_calc_kernel_max_num_subgroups";
11071111
auto calledFunction = _deviceExecCall->getCalledFunction();
1108-
if (calledFunction == nullptr) report_fatal_error("indirect calls are not supported");
1112+
IGC_ASSERT_EXIT_MESSAGE(nullptr != calledFunction, "indirect calls are not supported");
11091113
return CreateNewCall(newName, calledFunction->getReturnType(), args);
11101114
}
11111115
};
@@ -1791,7 +1795,7 @@ namespace //Anonymous
17911795

17921796
// get list of calls which "enqueue" this dispatcher
17931797
auto parentCalls = _dataContext.getCallHandlersFor(invokeFunc);
1794-
if (parentCalls.size() == 0) report_fatal_error("parent calls for invoke are not set");
1798+
IGC_ASSERT_EXIT_MESSAGE(parentCalls.size(), "parent calls for invoke are not set");
17951799

17961800
// lookup for a call which located in a "__kernel"
17971801
// if __kernel call will not found, use the one which is not self
@@ -1810,7 +1814,7 @@ namespace //Anonymous
18101814
}
18111815
}
18121816

1813-
if (parentCallHandler == nullptr) report_fatal_error("Fail parent call lookup: possible closed self-enqueue");
1817+
IGC_ASSERT_EXIT_MESSAGE(nullptr != parentCallHandler, "Fail parent call lookup: possible closed self-enqueue");
18141818

18151819
auto capturedValues = parentCallHandler->getArgs()->getParamValue()->getCapturedValues(_dataContext.getDispatcherForInvokeFunc(invokeFunc)->getCaptureIndicies());
18161820
auto& capture = capturedValues[captureNum];
@@ -1925,8 +1929,7 @@ namespace //Anonymous
19251929
if (!_invocations[invokeFunc]._dispatcher)
19261930
{
19271931
const Function* parentKernel = getParentKernel(invokeFunc);
1928-
if (!parentKernel)
1929-
report_fatal_error("Fail parent kernel lookup: possible closed self-enqueue");
1932+
IGC_ASSERT_EXIT_MESSAGE(nullptr != parentKernel, "Fail parent kernel lookup: possible closed self-enqueue");
19301933

19311934
_invocations[invokeFunc]._dispatcher.reset(new Dispatcher(invokeFunc, parentKernel->getName(), _blocksNum++));
19321935
}
@@ -1960,7 +1963,7 @@ namespace //Anonymous
19601963

19611964
const llvm::Function* DataContext::getParentKernelImpl(const llvm::Function* invokeFunc, std::set<const llvm::Function*>& processedFuncs)
19621965
{
1963-
if (invokeFunc == nullptr) report_fatal_error("invoke function should not be null");
1966+
IGC_ASSERT_EXIT_MESSAGE(nullptr != invokeFunc, "invoke function should not be null");
19641967

19651968
processedFuncs.insert(invokeFunc);
19661969

@@ -2383,7 +2386,7 @@ namespace //Anonymous
23832386

23842387
Capture::Capture(llvm::Value* val, DataContext& context)
23852388
{
2386-
if (val == nullptr) report_fatal_error("captured value is null");
2389+
IGC_ASSERT_EXIT_MESSAGE(nullptr != val, "captured value is null");
23872390
value = val;
23882391
if (auto arg = context.getArgForValue(value))
23892392
{
@@ -2436,7 +2439,7 @@ namespace //Anonymous
24362439
, _block_invokeFunction(nullptr)
24372440
, _dataContext(dataContext)
24382441
{
2439-
if (!_paramStruct) report_fatal_error("Enqueue param is not a struct");
2442+
IGC_ASSERT_EXIT_MESSAGE(nullptr != _paramStruct, "Enqueue param is not a struct");
24402443

24412444
if (_dataContext.getKindQuery().isBlockStructType(_paramStruct->getType())) {
24422445
/// ObjectiveC block value passed to OCL "device execution" call.
@@ -2455,12 +2458,9 @@ namespace //Anonymous
24552458
{
24562459
if (_paramValue == nullptr)
24572460
{
2458-
if (auto param = getParamArg()) {
2459-
_paramValue = _dataContext.getDeviceEnqueueParamValue(param->stripPointerCasts());
2460-
}
2461-
else {
2462-
report_fatal_error("Enqueue param is not set");
2463-
}
2461+
auto param = getParamArg();
2462+
IGC_ASSERT_EXIT_MESSAGE(nullptr != param, "Enqueue param is not set");
2463+
_paramValue = _dataContext.getDeviceEnqueueParamValue(param->stripPointerCasts());
24642464
}
24652465
return _paramValue;
24662466
}
@@ -2610,7 +2610,7 @@ namespace //Anonymous
26102610
case CaptureKind::IMAGE:
26112611
case CaptureKind::SAMPLER:
26122612
{
2613-
if (Capture::ARG_NUM_NONE == capturedValue.argNum) report_fatal_error("unknown argument number for an object");
2613+
IGC_ASSERT_EXIT_MESSAGE(Capture::ARG_NUM_NONE != capturedValue.argNum, "unknown argument number for an object");
26142614
auto objArgNumValue = llvm::ConstantInt::get(int32ty, capturedValue.argNum);
26152615
auto getObjIDFunc = getOrCreateFunc("__builtin_IB_get_object_id", int32ty, int32ty);
26162616
auto objIdValue = builder.CreateCall(getObjIDFunc, objArgNumValue, "obj_id");

IGC/Compiler/Optimizer/OpenCLPasses/GenericAddressResolution/GenericAddressDynamicResolution.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ bool GenericAddressDynamicResolution::visitLoadStoreInst(Instruction& I)
220220
pointerAddressSpace = store->getPointerAddressSpace();
221221
}
222222
else {
223-
report_fatal_error("Unable to resolve generic address space pointer");
223+
IGC_ASSERT_EXIT_MESSAGE(0, "Unable to resolve generic address space pointer");
224224
}
225225

226226
if (pointerAddressSpace == ADDRESS_SPACE_GENERIC) {

0 commit comments

Comments
 (0)