@@ -235,8 +235,6 @@ getDeviceLibraries(const ArgList &Args, DiagnosticsEngine &Diags) {
235235 {" libsycl-itt-user-wrappers" , " internal" },
236236 {" libsycl-itt-compiler-wrappers" , " internal" },
237237 {" libsycl-itt-stubs" , " internal" }};
238- const SYCLDeviceLibsList SYCLDeviceSanitizerLibs = {
239- {" libsycl-sanitizer" , " internal" }};
240238
241239 SmallVector<std::string, 8 > LibraryList;
242240 StringRef LibSuffix = " .bc" ;
@@ -258,44 +256,6 @@ getDeviceLibraries(const ArgList &Args, DiagnosticsEngine &Diags) {
258256 AddLibraries (SYCLDeviceAnnotationLibs);
259257 }
260258
261- if (Arg *A = Args.getLastArg (OPT_fsanitize_EQ, OPT_fno_sanitize_EQ)) {
262- if (A->getOption ().matches (OPT_fsanitize_EQ) &&
263- A->getValues ().size () == 1 ) {
264- std::string SanitizeVal = A->getValue ();
265- if (SanitizeVal == " address" ) {
266- AddLibraries (SYCLDeviceSanitizerLibs);
267- }
268- }
269- } else {
270- // User can pass -fsanitize=address to device compiler via
271- // -Xsycl-target-frontend, sanitize device library must be
272- // linked with user's device image if so.
273- bool IsDeviceAsanEnabled = false ;
274- auto SyclFEArg = Args.getAllArgValues (OPT_Xsycl_frontend);
275- IsDeviceAsanEnabled = (std::count (SyclFEArg.begin (), SyclFEArg.end (),
276- " -fsanitize=address" ) > 0 );
277- if (!IsDeviceAsanEnabled) {
278- auto SyclFEArgEq = Args.getAllArgValues (OPT_Xsycl_frontend_EQ);
279- IsDeviceAsanEnabled = (std::count (SyclFEArgEq.begin (), SyclFEArgEq.end (),
280- " -fsanitize=address" ) > 0 );
281- }
282-
283- // User can also enable asan for SYCL device via -Xarch_device option.
284- if (!IsDeviceAsanEnabled) {
285- auto DeviceArchVals = Args.getAllArgValues (OPT_Xarch_device);
286- for (auto DArchVal : DeviceArchVals) {
287- if (DArchVal.find (" -fsanitize=address" ) != std::string::npos) {
288- IsDeviceAsanEnabled = true ;
289- break ;
290- }
291- }
292- }
293-
294- if (IsDeviceAsanEnabled) {
295- AddLibraries (SYCLDeviceSanitizerLibs);
296- }
297- }
298-
299259 return LibraryList;
300260}
301261
@@ -357,5 +317,48 @@ jit_compiler::parseUserArgs(View<const char *> UserArgs) {
357317 " User option '%s' at index %d is missing an argument" ,
358318 UserArgsRef[MissingArgIndex], MissingArgIndex);
359319 }
320+
321+ // Check for unsupported options.
322+ // TODO: There are probably more, e.g. requesting non-SPIR-V targets.
323+ {
324+ // -fsanitize=address
325+ bool IsDeviceAsanEnabled = false ;
326+ if (Arg *A = AL.getLastArg (OPT_fsanitize_EQ, OPT_fno_sanitize_EQ)) {
327+ if (A->getOption ().matches (OPT_fsanitize_EQ) &&
328+ A->getValues ().size () == 1 ) {
329+ std::string SanitizeVal = A->getValue ();
330+ IsDeviceAsanEnabled = SanitizeVal == " address" ;
331+ }
332+ } else {
333+ // User can pass -fsanitize=address to device compiler via
334+ // -Xsycl-target-frontend.
335+ auto SyclFEArg = AL.getAllArgValues (OPT_Xsycl_frontend);
336+ IsDeviceAsanEnabled = (std::count (SyclFEArg.begin (), SyclFEArg.end (),
337+ " -fsanitize=address" ) > 0 );
338+ if (!IsDeviceAsanEnabled) {
339+ auto SyclFEArgEq = AL.getAllArgValues (OPT_Xsycl_frontend_EQ);
340+ IsDeviceAsanEnabled =
341+ (std::count (SyclFEArgEq.begin (), SyclFEArgEq.end (),
342+ " -fsanitize=address" ) > 0 );
343+ }
344+
345+ // User can also enable asan for SYCL device via -Xarch_device option.
346+ if (!IsDeviceAsanEnabled) {
347+ auto DeviceArchVals = AL.getAllArgValues (OPT_Xarch_device);
348+ for (auto DArchVal : DeviceArchVals) {
349+ if (DArchVal.find (" -fsanitize=address" ) != std::string::npos) {
350+ IsDeviceAsanEnabled = true ;
351+ break ;
352+ }
353+ }
354+ }
355+ }
356+
357+ if (IsDeviceAsanEnabled) {
358+ return createStringError (
359+ " Device ASAN is not supported for runtime compilation" );
360+ }
361+ }
362+
360363 return Expected<InputArgList>{std::move (AL)};
361364}
0 commit comments