Skip to content

Commit 7ae6c43

Browse files
authored
[Sema] Fix bug in builtin AS override (#138141)
Fix the logic in rewriteBuiltinFunctionDecl to work when the builtin has a pointer parameter with an address space and one without a fixed address space. A builtin fitting these criteria was recently added. Change the attribute string to perform type checking on it, so without the sema change compilation would fail with a wrong number of arguments error.
1 parent a925e90 commit 7ae6c43

File tree

2 files changed

+3
-5
lines changed

2 files changed

+3
-5
lines changed

clang/include/clang/Basic/BuiltinsAMDGPU.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ TARGET_BUILTIN(__builtin_amdgcn_flat_atomic_fadd_v2bf16, "V2sV2s*0V2s", "t", "at
257257
TARGET_BUILTIN(__builtin_amdgcn_global_atomic_fadd_v2bf16, "V2sV2s*1V2s", "t", "atomic-global-pk-add-bf16-inst")
258258
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2bf16, "V2sV2s*3V2s", "t", "atomic-ds-pk-add-16-insts")
259259
TARGET_BUILTIN(__builtin_amdgcn_ds_atomic_fadd_v2f16, "V2hV2h*3V2h", "t", "atomic-ds-pk-add-16-insts")
260-
TARGET_BUILTIN(__builtin_amdgcn_load_to_lds, "vv*v*3IUiIiIUi", "t", "vmem-to-lds-load-insts")
260+
TARGET_BUILTIN(__builtin_amdgcn_load_to_lds, "vv*v*3IUiIiIUi", "", "vmem-to-lds-load-insts")
261261
TARGET_BUILTIN(__builtin_amdgcn_global_load_lds, "vv*1v*3IUiIiIUi", "t", "vmem-to-lds-load-insts")
262262

263263
//===----------------------------------------------------------------------===//

clang/lib/Sema/SemaExpr.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6395,7 +6395,8 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
63956395
return nullptr;
63966396
Expr *Arg = ArgRes.get();
63976397
QualType ArgType = Arg->getType();
6398-
if (!ParamType->isPointerType() || ParamType.hasAddressSpace() ||
6398+
if (!ParamType->isPointerType() ||
6399+
ParamType->getPointeeType().hasAddressSpace() ||
63996400
!ArgType->isPointerType() ||
64006401
!ArgType->getPointeeType().hasAddressSpace() ||
64016402
isPtrSizeAddressSpace(ArgType->getPointeeType().getAddressSpace())) {
@@ -6404,9 +6405,6 @@ static FunctionDecl *rewriteBuiltinFunctionDecl(Sema *Sema, ASTContext &Context,
64046405
}
64056406

64066407
QualType PointeeType = ParamType->getPointeeType();
6407-
if (PointeeType.hasAddressSpace())
6408-
continue;
6409-
64106408
NeedsNewDecl = true;
64116409
LangAS AS = ArgType->getPointeeType().getAddressSpace();
64126410

0 commit comments

Comments
 (0)