Skip to content

Commit 2808cbd

Browse files
lukaszgotszaldintelsys_zuul
authored andcommitted
use IGC_ASSERT in IGC/AdaptorCommon
Change-Id: I52f0d40afc09f2a63b9c68b6f11136cdfadbda3e
1 parent 48f059a commit 2808cbd

File tree

6 files changed

+68
-65
lines changed

6 files changed

+68
-65
lines changed

IGC/AdaptorCommon/AddImplicitArgs.cpp

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
2929
#include "Compiler/IGCPassSupport.h"
3030
#include "Compiler/CISACodeGen/CISACodeGen.h"
3131
#include "Compiler/Optimizer/OCLBIUtils.h"
32-
3332
#include "LLVM3DBuilder/MetadataBuilder.h"
34-
3533
#include "common/LLVMWarningsPush.hpp"
3634
#include "llvm/ADT/SCCIterator.h"
3735
#include <llvm/IR/Module.h>
@@ -41,12 +39,11 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
4139
#include <llvm/IR/DerivedTypes.h>
4240
#include "llvm/IR/DIBuilder.h"
4341
#include "common/LLVMWarningsPop.hpp"
44-
4542
#include "Compiler/DebugInfo/VISADebugEmitter.hpp"
4643
#include "common/debug/Debug.hpp"
47-
4844
#include <map>
4945
#include <utility>
46+
#include "Probe.h"
5047

5148
using namespace llvm;
5249
using namespace IGC;
@@ -162,7 +159,7 @@ bool AddImplicitArgs::runOnModule(Module &M)
162159
{
163160
Function* pFunc = I->first;
164161

165-
assert(pFunc->use_empty() && "Assume all user function are inlined at this point");
162+
IGC_ASSERT(pFunc->use_empty() && "Assume all user function are inlined at this point");
166163

167164
// Now, after changing funciton signature,
168165
// and validate there are no calls to the old function we can erase it.
@@ -308,12 +305,12 @@ void AddImplicitArgs::updateNewFuncArgs(llvm::Function* pFunc, llvm::Function* p
308305
// struct, image
309306
FunctionInfoMetaDataHandle funcInfo = m_pMdUtils->getFunctionsInfoItem(pFunc);
310307
ArgInfoMetaDataHandle argInfo = funcInfo->getImplicitArgInfoListItem(i);
311-
assert(argInfo->isExplicitArgNumHasValue() && "wrong data in MetaData");
308+
IGC_ASSERT(argInfo->isExplicitArgNumHasValue() && "wrong data in MetaData");
312309

313310
info.DW0.All.argExplictNum = argInfo->getExplicitArgNum();
314311
if (argId <= ImplicitArg::ArgType::STRUCT_END)
315312
{
316-
assert(argInfo->isStructArgOffsetHasValue() && "wrong data in MetaData");
313+
IGC_ASSERT(argInfo->isStructArgOffsetHasValue() && "wrong data in MetaData");
317314
info.DW0.All.argOffset = argInfo->getStructArgOffset();
318315
}
319316
infoToArg[info.DW0.Value] = &(*currArg);
@@ -328,7 +325,7 @@ void AddImplicitArgs::updateNewFuncArgs(llvm::Function* pFunc, llvm::Function* p
328325

329326
void AddImplicitArgs::replaceAllUsesWithNewOCLBuiltinFunction(CodeGenContext* ctx, llvm::Function* old_func, llvm::Function* new_func)
330327
{
331-
assert(!old_func->use_empty());
328+
IGC_ASSERT(!old_func->use_empty());
332329

333330
FunctionInfoMetaDataHandle subFuncInfo = m_pMdUtils->getFunctionsInfoItem(old_func);
334331

@@ -371,7 +368,7 @@ void AddImplicitArgs::replaceAllUsesWithNewOCLBuiltinFunction(CodeGenContext* ct
371368

372369
if (!cInst)
373370
{
374-
assert(0 && "Unknown function usage");
371+
IGC_ASSERT(false && "Unknown function usage");
375372
getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->EmitError(" undefined reference to `jmp()' ");
376373
return;
377374
}
@@ -389,7 +386,7 @@ void AddImplicitArgs::replaceAllUsesWithNewOCLBuiltinFunction(CodeGenContext* ct
389386
llvm::Function::arg_iterator new_arg_iter = new_func->arg_begin();
390387
llvm::Function::arg_iterator new_arg_end = new_func->arg_end();
391388

392-
assert(IGCLLVM::GetFuncArgSize(new_func) >= numArgOperands);
389+
IGC_ASSERT(IGCLLVM::GetFuncArgSize(new_func) >= numArgOperands);
393390

394391
// basic arguments
395392
for (unsigned int i = 0; i < numArgOperands; ++i, ++new_arg_iter)
@@ -423,39 +420,39 @@ void AddImplicitArgs::replaceAllUsesWithNewOCLBuiltinFunction(CodeGenContext* ct
423420

424421
if (argId < ImplicitArg::ArgType::STRUCT_START)
425422
{
426-
assert(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
423+
IGC_ASSERT(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
427424
"Can't find the implicit argument on parent function");
428425
new_args.push_back(infoToArg[info.DW0.Value]);
429426
}
430427
else if (argId <= ImplicitArg::ArgType::STRUCT_END)
431428
{
432-
assert(0 && "wrong argument type in user function");
429+
IGC_ASSERT(false && "wrong argument type in user function");
433430
}
434431
else if (argId <= ImplicitArg::IMAGES_END || argId == ImplicitArg::ArgType::GET_OBJECT_ID || argId == ImplicitArg::ArgType::GET_BLOCK_SIMD_SIZE)
435432
{
436433
// special handling for image info types, such as ImageWidth, ImageHeight, ...
437434
// and struct type
438435

439-
assert(argImpToExpNum.find(&(*new_arg_iter)) != argImpToExpNum.end() &&
436+
IGC_ASSERT(argImpToExpNum.find(&(*new_arg_iter)) != argImpToExpNum.end() &&
440437
"Can't find explicit argument number");
441438

442439
// tracing it on parent function argument list
443440
Value* callArg = CImagesBI::CImagesUtils::traceImageOrSamplerArgument(cInst, argImpToExpNum[&(*new_arg_iter)]);
444441
Argument* arg = dyn_cast<Argument>(callArg);
445442

446-
assert(arg && " Not supported");
443+
IGC_ASSERT(arg && "Not supported");
447444

448445
// build info
449446

450447
info.DW0.All.argExplictNum = arg->getArgNo();
451-
assert(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
448+
IGC_ASSERT(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
452449
"Can't find the implicit argument on parent function");
453450

454451
new_args.push_back(infoToArg[info.DW0.Value]);
455452
}
456453
else
457454
{
458-
assert(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
455+
IGC_ASSERT(infoToArg.find(info.DW0.Value) != infoToArg.end() &&
459456
"Can't find the implicit argument on parent function");
460457
new_args.push_back(infoToArg[info.DW0.Value]);
461458
}
@@ -543,7 +540,7 @@ bool BuiltinCallGraphAnalysis::runOnModule(Module &M)
543540
!ctx->m_DriverInfo.AllowRecursion() &&
544541
hasRecursion(CG))
545542
{
546-
assert(0 && "Recursion detected!");
543+
IGC_ASSERT(false && "Recursion detected!");
547544
ctx->EmitError(" undefined reference to `jmp()' ");
548545
return false;
549546
}
@@ -588,7 +585,7 @@ void BuiltinCallGraphAnalysis::traveseCallGraphSCC(const std::vector<CallGraphNo
588585

589586
// calculate args from sub-routine.
590587
// This function have not beeen processed yet, therefore no map-entry for it yet
591-
assert(argMap.count(f) == 0);
588+
IGC_ASSERT(argMap.count(f) == 0);
592589
for (auto N : (*CGN))
593590
{
594591
Function *sub = N.second->getFunction();
@@ -597,7 +594,7 @@ void BuiltinCallGraphAnalysis::traveseCallGraphSCC(const std::vector<CallGraphNo
597594
// if we have processed the arguments for callee
598595
if (argMapIter != argMap.end())
599596
{
600-
assert(argMapIter->second);
597+
IGC_ASSERT(nullptr != argMapIter->second);
601598
combineTwoArgDetail(*argData, *(argMapIter->second), N.first);
602599
}
603600
}
@@ -685,7 +682,7 @@ void BuiltinCallGraphAnalysis::combineTwoArgDetail(
685682
{
686683
// aggregate implicity argument
687684

688-
assert(0 && "wrong location for this kind of argument type");
685+
IGC_ASSERT(false && "wrong location for this kind of argument type");
689686

690687
}
691688
else if (argId <= ImplicitArg::ArgType::IMAGES_END || argId == ImplicitArg::ArgType::GET_OBJECT_ID || argId == ImplicitArg::ArgType::GET_BLOCK_SIMD_SIZE)
@@ -695,7 +692,7 @@ void BuiltinCallGraphAnalysis::combineTwoArgDetail(
695692
CallInst *cInst = dyn_cast<CallInst>(v);
696693
if (!cInst)
697694
{
698-
assert(0 && " Not supported");
695+
IGC_ASSERT(false && " Not supported");
699696
getAnalysis<CodeGenContextWrapper>().getCodeGenContext()->EmitError(" undefined reference to `jmp()' ");
700697
return;
701698
}
@@ -711,7 +708,7 @@ void BuiltinCallGraphAnalysis::combineTwoArgDetail(
711708
Argument* arg = dyn_cast<Argument>(callArg);
712709
if (!arg)
713710
{
714-
assert(0 && " Not supported");
711+
IGC_ASSERT(false && "Not supported");
715712
}
716713
setx->insert(arg->getArgNo());
717714
}
@@ -729,7 +726,7 @@ void BuiltinCallGraphAnalysis::combineTwoArgDetail(
729726
// aggregate structure
730727
for (unsigned i = 0; i < argD.StructArgSet.size(); i++)
731728
{
732-
assert(0 && "wrong argument type in user function");
729+
IGC_ASSERT(false && "wrong argument type in user function");
733730
}
734731
#endif
735732
}
@@ -754,7 +751,7 @@ void BuiltinCallGraphAnalysis::writeBackAllIntoMetaData(ImplicitArgmentDetail& d
754751
{
755752
// aggregate implicity argument
756753

757-
assert(0 && "wrong location for this kind of argument type");
754+
IGC_ASSERT(false && "wrong location for this kind of argument type");
758755

759756
}
760757
else if (argId <= ImplicitArg::ArgType::IMAGES_END || argId == ImplicitArg::ArgType::GET_OBJECT_ID || argId == ImplicitArg::ArgType::GET_BLOCK_SIMD_SIZE)

IGC/AdaptorCommon/IRUpgrader/UpgraderResourceAccess.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3535
#include <llvm/IR/InstVisitor.h>
3636
#include <llvm/IR/IRBuilder.h>
3737
#include "common/LLVMWarningsPop.hpp"
38+
#include "Probe.h"
3839

3940
using namespace llvm;
4041

@@ -159,7 +160,7 @@ void UpgradeResourceAccess::ChangeIntrinsic(CallInst& C, GenISAIntrinsic::ID ID)
159160
}
160161
break;
161162
default:
162-
assert("unhandled intrinsic upgrade" && 0);
163+
IGC_ASSERT(false && "unhandled intrinsic upgrade");
163164
break;
164165
}
165166
Function* f = GenISAIntrinsic::getDeclaration(m, ID, types);

IGC/AdaptorCommon/ImplicitArgs.cpp

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3333
#include <llvm/IR/Metadata.h>
3434
#include <llvm/IR/Module.h>
3535
#include "common/LLVMWarningsPop.hpp"
36+
#include "Probe.h"
3637

3738
using namespace llvm;
3839
using namespace IGC;
@@ -102,7 +103,7 @@ Type* ImplicitArg::getLLVMType(LLVMContext& context) const
102103
baseType = Type::getInt8Ty(context)->getPointerTo(ADDRESS_SPACE_GLOBAL);
103104
break;
104105
default:
105-
assert(0 && "Unrecognized implicit argument type");
106+
IGC_ASSERT(false && "Unrecognized implicit argument type");
106107
return nullptr;
107108
}
108109

@@ -145,7 +146,7 @@ VISA_Type ImplicitArg::getVISAType(const DataLayout& DL) const
145146
case PRIVATEPTR:
146147
return getPointerSize(DL) == 4 ? VISA_Type::ISA_TYPE_UD : VISA_Type::ISA_TYPE_UQ;
147148
default:
148-
assert(0 && "Unrecognized implicit argument type");
149+
IGC_ASSERT(false && "Unrecognized implicit argument type");
149150
}
150151

151152
return VISA_Type::ISA_TYPE_UD;
@@ -157,7 +158,7 @@ unsigned int ImplicitArg::getPointerSize(const DataLayout& DL) const {
157158
case PRIVATEPTR: return DL.getPointerSize(ADDRESS_SPACE_PRIVATE);
158159
case GLOBALPTR: return DL.getPointerSize(ADDRESS_SPACE_GLOBAL);
159160
default:
160-
assert(false && "Unrecognized pointer type");
161+
IGC_ASSERT(false && "Unrecognized pointer type");
161162
}
162163
return 0;
163164
}
@@ -175,7 +176,7 @@ IGC::e_alignment ImplicitArg::getAlignType(const DataLayout& DL) const
175176
case ALIGN_PTR:
176177
return getPointerSize(DL) == 4 ? IGC::EALIGN_DWORD : IGC::EALIGN_QWORD;
177178
default:
178-
assert(0 && "Uknown alignment");
179+
IGC_ASSERT(false && "Uknown alignment");
179180
}
180181

181182
return IGC::EALIGN_DWORD;
@@ -218,7 +219,7 @@ unsigned int ImplicitArg::getAllocateSize(const DataLayout& DL) const
218219
elemSize = getPointerSize(DL);
219220
break;
220221
default:
221-
assert(0 && "Unrecognized implicit argument type");
222+
IGC_ASSERT(false && "Unrecognized implicit argument type");
222223
}
223224

224225
return m_nbElement * elemSize;
@@ -305,7 +306,7 @@ ImplicitArgs::ImplicitArgs(const llvm::Function& func , const MetaDataUtils* pMd
305306

306307
IMPLICIT_ARGS.push_back(ImplicitArg(ImplicitArg::SYNC_BUFFER, "syncBuffer", ImplicitArg::GLOBALPTR, WIAnalysis::UNIFORM, 1, ImplicitArg::ALIGN_PTR, false));
307308

308-
assert(IMPLICIT_ARGS.size() == ImplicitArg::NUM_IMPLICIT_ARGS && "Mismatch in NUM_IMPLICIT_ARGS and IMPLICIT_ARGS vector");
309+
IGC_ASSERT((IMPLICIT_ARGS.size() == ImplicitArg::NUM_IMPLICIT_ARGS) && "Mismatch in NUM_IMPLICIT_ARGS and IMPLICIT_ARGS vector");
309310

310311
#ifdef _DEBUG
311312
// Note: the order that implicit args are added here must match the
@@ -315,7 +316,7 @@ ImplicitArgs::ImplicitArgs(const llvm::Function& func , const MetaDataUtils* pMd
315316
{
316317
if (Arg.getArgType() != CurArgId++)
317318
{
318-
assert(0 && "enum and vector out of sync!");
319+
IGC_ASSERT(false && "enum and vector out of sync!");
319320
}
320321
}
321322
#endif // _DEBUG
@@ -325,12 +326,12 @@ ImplicitArgs::ImplicitArgs(const llvm::Function& func , const MetaDataUtils* pMd
325326
}
326327

327328
const ImplicitArg& ImplicitArgs::operator[](unsigned int i) const {
328-
assert(IMPLICIT_ARGS.size() == ImplicitArg::NUM_IMPLICIT_ARGS && "Mismatch in NUM_IMPLICIT_ARGS and IMPLICIT_ARGS vector");
329+
IGC_ASSERT((IMPLICIT_ARGS.size() == ImplicitArg::NUM_IMPLICIT_ARGS) && "Mismatch in NUM_IMPLICIT_ARGS and IMPLICIT_ARGS vector");
329330
return IMPLICIT_ARGS[getArgType(i)];
330331
}
331332

332333
unsigned int ImplicitArgs::getArgIndex(ImplicitArg::ArgType argType) {
333-
assert(this->size() > 0 && "There are no implicit arguments!");
334+
IGC_ASSERT((this->size() > 0) && "There are no implicit arguments!");
334335

335336
// Find the first appearance of the given implicit arg type
336337
unsigned int implicitArgIndex = 0;
@@ -343,7 +344,7 @@ unsigned int ImplicitArgs::getArgIndex(ImplicitArg::ArgType argType) {
343344
}
344345
}
345346

346-
assert(implicitArgIndex < this->size() && "Implicit argument not found!");
347+
IGC_ASSERT((implicitArgIndex < this->size()) && "Implicit argument not found!");
347348

348349
return implicitArgIndex;
349350
}
@@ -387,12 +388,12 @@ bool ImplicitArgs::isImplicitArgExist(
387388
}
388389

389390
unsigned int ImplicitArgs::getImageArgIndex(ImplicitArg::ArgType argType, const Argument* image) {
390-
assert(isImplicitImage(argType) && "Non image/sampler implicit arg!");
391+
IGC_ASSERT(isImplicitImage(argType) && "Non image/sampler implicit arg!");
391392
return getNumberedArgIndex(argType, image->getArgNo());
392393
}
393394

394395
unsigned int ImplicitArgs::getNumberedArgIndex(ImplicitArg::ArgType argType, int argNum) {
395-
assert((argNum >= 0) && "objectNum cannot be less than 0");
396+
IGC_ASSERT((argNum >= 0) && "objectNum cannot be less than 0");
396397

397398
for (int i = 0, e = m_funcInfoMD->size_ImplicitArgInfoList() ; i < e; ++i)
398399
{
@@ -403,7 +404,7 @@ unsigned int ImplicitArgs::getNumberedArgIndex(ImplicitArg::ArgType argType, int
403404
}
404405
}
405406

406-
assert(false && "No implicit argument for the given type & argNum");
407+
IGC_ASSERT(false && "No implicit argument for the given type & argNum");
407408
return m_funcInfoMD->size_ImplicitArgInfoList();
408409
}
409410

@@ -488,7 +489,7 @@ void ImplicitArgs::addBufferOffsetArgs(llvm::Function& F, IGCMD::MetaDataUtils*
488489
FunctionInfoMetaDataHandle funcInfoMD =
489490
pMdUtils->getFunctionsInfoItem(const_cast<Function*>(&F));
490491

491-
assert(modMD->FuncMD.find(&F) != modMD->FuncMD.end());
492+
IGC_ASSERT(modMD->FuncMD.find(&F) != modMD->FuncMD.end());
492493

493494
FunctionMetaData* funcMD = &modMD->FuncMD.find(&F)->second;
494495
for (auto& Arg : F.args() )
@@ -540,7 +541,7 @@ bool ImplicitArgs::isImplicitStruct(ImplicitArg::ArgType argType)
540541
}
541542

542543
ImplicitArg::ArgType ImplicitArgs::getArgType(unsigned int index) const {
543-
assert(index < size() && "Index out of range");
544+
IGC_ASSERT((index < size()) && "Index out of range");
544545
ArgInfoMetaDataHandle argInfo = m_funcInfoMD->getImplicitArgInfoListItem(index);
545546
return (ImplicitArg::ArgType)argInfo->getArgId();
546547
}
@@ -572,7 +573,7 @@ int32_t ImplicitArgs::getStructArgOffset(unsigned int index) const
572573

573574
TODO("Refactor code to avoid code triplication for getArgInFunc(), getImplicitArg() and WIFuncResolution::getImplicitArg()")
574575
Argument* ImplicitArgs::getArgInFunc(llvm::Function& F, ImplicitArg::ArgType argType) {
575-
assert(IGCLLVM::GetFuncArgSize(F) >= size() && "Invalid number of argumnents in the function!");
576+
IGC_ASSERT((IGCLLVM::GetFuncArgSize(F) >= size()) && "Invalid number of argumnents in the function!");
576577

577578
unsigned int argIndex = getArgIndex(argType);
578579
unsigned int argIndexInFunc = IGCLLVM::GetFuncArgSize(F) - size() + argIndex;
@@ -599,7 +600,7 @@ Argument* ImplicitArgs::getImplicitArg(llvm::Function& F, ImplicitArg::ArgType a
599600

600601
Argument* ImplicitArgs::getNumberedImplicitArg(llvm::Function& F, ImplicitArg::ArgType argType, int argNum)
601602
{
602-
assert(IGCLLVM::GetFuncArgSize(F) >= size() && "Invalid number of arguments in the function!");
603+
IGC_ASSERT((IGCLLVM::GetFuncArgSize(F) >= size()) && "Invalid number of arguments in the function!");
603604

604605
unsigned int numImplicitArgs = size();
605606
unsigned int implicitArgIndex = this->getNumberedArgIndex(argType, argNum);

0 commit comments

Comments
 (0)