File tree Expand file tree Collapse file tree 2 files changed +34
-2
lines changed
test/extensions/KHR/SPV_KHR_non_semantic_info Expand file tree Collapse file tree 2 files changed +34
-2
lines changed Original file line number Diff line number Diff line change @@ -4525,15 +4525,21 @@ void SPIRVToLLVM::transAuxDataInst(SPIRVExtInst *BC) {
4525
4525
case NonSemanticAuxData::FunctionAttribute: {
4526
4526
assert (Args.size () < 4 && " Unexpected FunctionAttribute Args" );
4527
4527
// If this attr was specially handled and added elsewhere, skip it.
4528
- if (F->hasFnAttribute (AttrOrMDName))
4528
+ Attribute::AttrKind AsKind = Attribute::getAttrKindFromName (AttrOrMDName);
4529
+ if (AsKind != Attribute::None && F->hasFnAttribute (AsKind))
4530
+ return ;
4531
+ if (AsKind == Attribute::None && F->hasFnAttribute (AttrOrMDName))
4529
4532
return ;
4530
4533
// For attributes, arg 2 is the attribute value as a string, which may not
4531
4534
// exist.
4532
4535
if (Args.size () == 3 ) {
4533
4536
auto AttrValue = BC->getModule ()->get <SPIRVString>(Args[2 ])->getStr ();
4534
4537
F->addFnAttr (AttrOrMDName, AttrValue);
4535
4538
} else {
4536
- F->addFnAttr (AttrOrMDName);
4539
+ if (AsKind != Attribute::None)
4540
+ F->addFnAttr (AsKind);
4541
+ else
4542
+ F->addFnAttr (AttrOrMDName);
4537
4543
}
4538
4544
break ;
4539
4545
}
Original file line number Diff line number Diff line change
1
+ ; RUN: llvm-as < %s -o %t.bc
2
+ ; RUN: llvm-spirv %t.bc -spirv-text --spirv-preserve-auxdata -o - | FileCheck %s --check-prefix=CHECK-SPIRV
3
+ ; RUN: llvm-spirv %t.bc -o %t.spv --spirv-preserve-auxdata
4
+ ; RUN: llvm-spirv -r -emit-opaque-pointers --spirv-preserve-auxdata %t.spv -o %t.rev.bc
5
+ ; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM
6
+
7
+ ; CHECK-SPIRV: Extension "SPV_KHR_non_semantic_info"
8
+ ; CHECK-SPIRV: ExtInstImport [[#Import:]] "NonSemantic.AuxData"
9
+
10
+ ; CHECK-SPIRV: String [[#Attr0:]] "nounwind"
11
+
12
+ ; CHECK-SPIRV: Name [[#Fcn0:]] "foo"
13
+
14
+ ; CHECK-SPIRV: TypeVoid [[#VoidT:]]
15
+
16
+ ; CHECK-SPIRV: ExtInst [[#VoidT]] [[#Attr0Inst:]] [[#Import]] NonSemanticAuxDataFunctionAttribute [[#Fcn0]] [[#Attr0]] {{$}}
17
+
18
+ target triple = "spir64-unknown-unknown"
19
+
20
+ ; CHECK-LLVM: define spir_func void @foo() #[[#Fcn0IRAttr:]]
21
+ define spir_func void @foo () #0 {
22
+ entry:
23
+ ret void
24
+ }
25
+ ; CHECK-LLVM: attributes #[[#Fcn0IRAttr]] = { nounwind }
26
+ attributes #0 = { nounwind }
You can’t perform that action at this time.
0 commit comments