|
264 | 264 | #define XNN_UNPREDICTABLE(condition) (!!(condition)) |
265 | 265 | #endif |
266 | 266 |
|
| 267 | +#if defined(__clang__) |
| 268 | +// Clang ignores sanitizer attributes on functions that get inlined. Also: |
| 269 | +// - GCC does not allow this attribute to be specified after a function |
| 270 | +// - It takes precedence over always_inline, so we can specify both. |
| 271 | +#define XNN_NO_INLINE_SANITIZER __attribute__((__noinline__)) |
| 272 | +#else |
| 273 | +#define XNN_NO_INLINE_SANITIZER |
| 274 | +#endif |
| 275 | + |
267 | 276 | #if XNN_COMPILER_HAS_FEATURE(thread_sanitizer) |
268 | | -#define XNN_DISABLE_TSAN __attribute__((__no_sanitize__("thread"))) |
| 277 | +#define XNN_DISABLE_TSAN \ |
| 278 | + __attribute__((__no_sanitize__("thread"))) XNN_NO_INLINE_SANITIZER |
269 | 279 | #else |
270 | 280 | #define XNN_DISABLE_TSAN |
271 | 281 | #endif |
272 | 282 |
|
273 | 283 | #if XNN_COMPILER_HAS_FEATURE(memory_sanitizer) |
274 | | -#define XNN_DISABLE_MSAN __attribute__((__no_sanitize__("memory"))) |
| 284 | +#define XNN_DISABLE_MSAN \ |
| 285 | + __attribute__((__no_sanitize__("memory"))) XNN_NO_INLINE_SANITIZER |
275 | 286 | #else |
276 | 287 | #define XNN_DISABLE_MSAN |
277 | 288 | #endif |
278 | 289 |
|
279 | 290 | #if XNN_COMPILER_HAS_FEATURE(hwaddress_sanitizer) |
280 | | -#define XNN_DISABLE_HWASAN __attribute__((__no_sanitize__("hwaddress"))) |
| 291 | +#define XNN_DISABLE_HWASAN \ |
| 292 | + __attribute__((__no_sanitize__("hwaddress"))) XNN_NO_INLINE_SANITIZER |
281 | 293 | #else |
282 | 294 | #define XNN_DISABLE_HWASAN |
283 | 295 | #endif |
284 | 296 |
|
285 | 297 | #if XNN_COMPILER_HAS_FEATURE(address_sanitizer) |
286 | | -#define XNN_DISABLE_ASAN __attribute__((__no_sanitize__("address"))) |
| 298 | +#define XNN_DISABLE_ASAN \ |
| 299 | + __attribute__((__no_sanitize__("address"))) XNN_NO_INLINE_SANITIZER |
287 | 300 | #else |
288 | 301 | #define XNN_DISABLE_ASAN |
289 | 302 | #endif |
290 | 303 |
|
291 | 304 | #if XNN_COMPILER_HAS_FEATURE(undefined_behavior_sanitizer) |
292 | | -#define XNN_DISABLE_UBSAN __attribute__((__no_sanitize__("undefined"))) |
| 305 | +#define XNN_DISABLE_UBSAN \ |
| 306 | + __attribute__((__no_sanitize__("undefined"))) XNN_NO_INLINE_SANITIZER |
293 | 307 | #else |
294 | 308 | #define XNN_DISABLE_UBSAN |
295 | 309 | #endif |
|
0 commit comments