Skip to content

Commit 41e2a5c

Browse files
committed
libclc: remove __attribute__((assume)) for clspv targets
Instead add a proper attribute in clang, and add convert it to function metadata to keep the information in the IR. The goal is to remove the dependency on __attribute__((assume)) that should have not be there in the first place. Ref #84934
1 parent 041baf2 commit 41e2a5c

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

clang/include/clang/Basic/Attr.td

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4561,3 +4561,9 @@ def CodeAlign: StmtAttr {
45614561
static constexpr int MaximumAlignment = 4096;
45624562
}];
45634563
}
4564+
4565+
def ClspvLibclcBuiltin: DeclOrStmtAttr {
4566+
let Spellings = [Clang<"clspv_libclc_builtin">];
4567+
let Documentation = [Undocumented];
4568+
let SimpleHandler = 1;
4569+
}

clang/lib/CodeGen/CodeGenFunction.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -979,6 +979,11 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy,
979979
EmitKernelMetadata(FD, Fn);
980980
}
981981

982+
if (FD && FD->hasAttr<ClspvLibclcBuiltinAttr>()) {
983+
Fn->setMetadata("clspv_libclc_builtin",
984+
llvm::MDNode::get(getLLVMContext(), {}));
985+
}
986+
982987
// If we are checking function types, emit a function type signature as
983988
// prologue data.
984989
if (FD && SanOpts.has(SanitizerKind::Function)) {

libclc/generic/include/clc/clcfunc.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,7 @@
77
#if defined(CLC_SPIRV) || defined(CLC_SPIRV64)
88
#define _CLC_DEF
99
#elif defined(CLC_CLSPV) || defined(CLC_CLSPV64)
10-
#define _CLC_DEF \
11-
__attribute__((noinline)) __attribute__((assume("clspv_libclc_builtin")))
10+
#define _CLC_DEF __attribute__((noinline)) __attribute__((clspv_libclc_builtin))
1211
#else
1312
#define _CLC_DEF __attribute__((always_inline))
1413
#endif

0 commit comments

Comments
 (0)