Skip to content

Commit e64fdad

Browse files
smilczekigcbot
authored andcommitted
Handle missing single quotes for -igc_opts.
In igc_ocl_tranlation_ctx_impl there is handling of -igc_opts passed to ocloc. The implementation however doesn't handle improper format, which results in an infinite loop in case no single quotes were provided, or the second single quote is missing. This commit adds handling of these cases.
1 parent 6d3f69e commit e64fdad

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

IGC/AdaptorOCL/ocl_igc_interface/impl/igc_ocl_translation_ctx_impl.h

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -256,12 +256,14 @@ CIF_DECLARE_INTERFACE_PIMPL(IgcOclTranslationCtx) : CIF::PimplBase {
256256

257257
std::size_t foundFirstSingleQuote = optionsWithFlags.find('\'', found);
258258
std::size_t foundSecondSingleQuote = optionsWithFlags.find('\'', foundFirstSingleQuote + 1);
259-
if (foundFirstSingleQuote != std::string::npos && foundSecondSingleQuote) {
260-
RegKeysFlagsFromOptions +=
261-
optionsWithFlags.substr(foundFirstSingleQuote + 1, (foundSecondSingleQuote - foundFirstSingleQuote - 1));
262-
RegKeysFlagsFromOptions = RegKeysFlagsFromOptions + ',';
263-
optionsWithFlags = optionsWithFlags.substr(foundSecondSingleQuote + 1, optionsWithFlags.length());
259+
if (foundFirstSingleQuote == std::string::npos || foundSecondSingleQuote == std::string::npos) {
260+
outputInterface->GetImpl()->SetError(TranslationErrorType::Unused, "Missing single quotes for -igc_opts");
261+
return outputInterface.release();
264262
}
263+
RegKeysFlagsFromOptions +=
264+
optionsWithFlags.substr(foundFirstSingleQuote + 1, (foundSecondSingleQuote - foundFirstSingleQuote - 1));
265+
RegKeysFlagsFromOptions = RegKeysFlagsFromOptions + ',';
266+
optionsWithFlags = optionsWithFlags.substr(foundSecondSingleQuote + 1, optionsWithFlags.length());
265267
}
266268
}
267269
bool RegFlagNameError = 0;
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// REQUIRES: regkeys, dg2-supported
2+
3+
// RUN: ocloc compile -file %s -options " -igc_opts 'DumpVISAASMToConsole=1" -device dg2 | FileCheck %s
4+
5+
// XFAIL: *
6+
// CHECK: Missing single quotes for -igc_opts
7+
__kernel void foo(int a, int b, __global int *res) { *res = a + b; }

0 commit comments

Comments
 (0)