@@ -131,10 +131,8 @@ static bool isDSAddress(const Constant *C) {
131
131
return AS == AMDGPUAS::LOCAL_ADDRESS || AS == AMDGPUAS::REGION_ADDRESS;
132
132
}
133
133
134
- // / Returns true if the function requires the implicit argument be passed
135
- // / regardless of the function contents.
136
- static bool funcRequiresHostcallPtr (const Function &F) {
137
- // Sanitizers require the hostcall buffer passed in the implicit arguments.
134
+ // / Returns true if sanitizer attributes are present on a function.
135
+ static bool hasSanitizerAttributes (const Function &F) {
138
136
return F.hasFnAttribute (Attribute::SanitizeAddress) ||
139
137
F.hasFnAttribute (Attribute::SanitizeThread) ||
140
138
F.hasFnAttribute (Attribute::SanitizeMemory) ||
@@ -469,15 +467,21 @@ struct AAAMDAttributesFunction : public AAAMDAttributes {
469
467
470
468
// If the function requires the implicit arg pointer due to sanitizers,
471
469
// assume it's needed even if explicitly marked as not requiring it.
472
- const bool NeedsHostcall = funcRequiresHostcallPtr (*F);
473
- if (NeedsHostcall) {
470
+ // Flat scratch initialization is needed because `asan_malloc_impl`
471
+ // calls introduced later in pipeline will have flat scratch accesses.
472
+ // FIXME: FLAT_SCRATCH_INIT will not be required here if device-libs
473
+ // implementation for `asan_malloc_impl` is updated.
474
+ const bool HasSanitizerAttrs = hasSanitizerAttributes (*F);
475
+ if (HasSanitizerAttrs) {
474
476
removeAssumedBits (IMPLICIT_ARG_PTR);
475
477
removeAssumedBits (HOSTCALL_PTR);
478
+ removeAssumedBits (FLAT_SCRATCH_INIT);
476
479
}
477
480
478
481
for (auto Attr : ImplicitAttrs) {
479
- if (NeedsHostcall &&
480
- (Attr.first == IMPLICIT_ARG_PTR || Attr.first == HOSTCALL_PTR))
482
+ if (HasSanitizerAttrs &&
483
+ (Attr.first == IMPLICIT_ARG_PTR || Attr.first == HOSTCALL_PTR ||
484
+ Attr.first == FLAT_SCRATCH_INIT))
481
485
continue ;
482
486
483
487
if (F->hasFnAttribute (Attr.second ))
0 commit comments