Skip to content

Commit 782ec4c

Browse files
author
git apple-llvm automerger
committed
Merge commit '39483797b898' from llvm.org/main into next
2 parents a141704 + 3948379 commit 782ec4c

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

llvm/lib/Target/SPIRV/SPIRVEmitIntrinsics.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ static bool requireAssignType(Instruction *I) {
149149
return true;
150150
}
151151

152+
static inline void reportFatalOnTokenType(const Instruction *I) {
153+
if (I->getType()->isTokenTy())
154+
report_fatal_error("A token is encountered but SPIR-V without extensions "
155+
"does not support token type",
156+
false);
157+
}
158+
152159
void SPIRVEmitIntrinsics::replaceMemInstrUses(Instruction *Old,
153160
Instruction *New) {
154161
while (!Old->user_empty()) {
@@ -544,6 +551,7 @@ void SPIRVEmitIntrinsics::processGlobalValue(GlobalVariable &GV) {
544551
}
545552

546553
void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) {
554+
reportFatalOnTokenType(I);
547555
if (I->getType()->isVoidTy() || !requireAssignPtrType(I))
548556
return;
549557

@@ -566,6 +574,7 @@ void SPIRVEmitIntrinsics::insertAssignPtrTypeIntrs(Instruction *I) {
566574
}
567575

568576
void SPIRVEmitIntrinsics::insertAssignTypeIntrs(Instruction *I) {
577+
reportFatalOnTokenType(I);
569578
Type *Ty = I->getType();
570579
if (!Ty->isVoidTy() && requireAssignType(I) && !requireAssignPtrType(I)) {
571580
setInsertPointSkippingPhis(*IRB, I->getNextNode());
@@ -625,6 +634,7 @@ void SPIRVEmitIntrinsics::processInstrAfterVisit(Instruction *I) {
625634
}
626635
}
627636
if (I->hasName()) {
637+
reportFatalOnTokenType(I);
628638
setInsertPointSkippingPhis(*IRB, I->getNextNode());
629639
std::vector<Value *> Args = {I};
630640
addStringImm(I->getName(), *IRB, Args);
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
; Example of token usage is from https://llvm.org/docs/LangRef.html (Preallocated Operand Bundles)
2+
3+
; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s
4+
5+
; CHECK: A token is encountered but SPIR-V without extensions does not support token type
6+
7+
%foo = type { i64, i32 }
8+
9+
define dso_local spir_func void @test() {
10+
entry:
11+
%tok = call token @llvm.call.preallocated.setup(i32 1)
12+
%a = call ptr @llvm.call.preallocated.arg(token %tok, i32 0) preallocated(%foo)
13+
ret void
14+
}
15+
16+
declare token @llvm.call.preallocated.setup(i32 %num_args)
17+
declare ptr @llvm.call.preallocated.arg(token %setup_token, i32 %arg_index)
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: not llc -O0 -mtriple=spirv64-unknown-unknown %s -o - 2>&1 | FileCheck %s
2+
3+
; CHECK: A token is encountered but SPIR-V without extensions does not support token type
4+
5+
declare token @llvm.myfun()
6+
7+
define dso_local spir_func void @func() {
8+
entry:
9+
%tok = call token @llvm.myfun()
10+
ret void
11+
}

0 commit comments

Comments
 (0)