@@ -21,11 +21,18 @@ using namespace llvm;
21
21
void llvm::getSYCLDeviceRequirements (
22
22
const module_split::ModuleDesc &MD,
23
23
std::map<StringRef, util::PropertyValue> &Requirements) {
24
- auto ExtractIntegerFromMDNodeOperand = [=](const MDNode *N,
25
- unsigned OpNo) -> int32_t {
24
+ auto ExtractSignedIntegerFromMDNodeOperand = [=](const MDNode *N,
25
+ unsigned OpNo) -> int64_t {
26
26
Constant *C =
27
27
cast<ConstantAsMetadata>(N->getOperand (OpNo).get ())->getValue ();
28
- return static_cast <int32_t >(C->getUniqueInteger ().getSExtValue ());
28
+ return C->getUniqueInteger ().getSExtValue ();
29
+ };
30
+
31
+ auto ExtractUnsignedIntegerFromMDNodeOperand =
32
+ [=](const MDNode *N, unsigned OpNo) -> uint64_t {
33
+ Constant *C =
34
+ cast<ConstantAsMetadata>(N->getOperand (OpNo).get ())->getValue ();
35
+ return C->getUniqueInteger ().getZExtValue ();
29
36
};
30
37
31
38
// { LLVM-IR metadata name , [SYCL/Device requirements] property name }, see:
@@ -42,11 +49,15 @@ void llvm::getSYCLDeviceRequirements(
42
49
for (const Function &F : MD.getModule ()) {
43
50
if (const MDNode *MDN = F.getMetadata (MDName)) {
44
51
for (size_t I = 0 , E = MDN->getNumOperands (); I < E; ++I) {
45
- // Don't put internal aspects (with negative integer value) into the
46
- // requirements, they are used only for device image splitting.
47
- auto Val = ExtractIntegerFromMDNodeOperand (MDN, I);
48
- if (Val >= 0 )
49
- Values.insert (Val);
52
+ if (std::string (MDName) == " sycl_used_aspects" ) {
53
+ // Don't put internal aspects (with negative integer value) into the
54
+ // requirements, they are used only for device image splitting.
55
+ auto Val = ExtractSignedIntegerFromMDNodeOperand (MDN, I);
56
+ if (Val >= 0 )
57
+ Values.insert (Val);
58
+ } else {
59
+ Values.insert (ExtractUnsignedIntegerFromMDNodeOperand (MDN, I));
60
+ }
50
61
}
51
62
}
52
63
}
@@ -69,8 +80,7 @@ void llvm::getSYCLDeviceRequirements(
69
80
for (const Function *F : MD.entries ()) {
70
81
if (auto *MDN = F->getMetadata (" intel_reqd_sub_group_size" )) {
71
82
assert (MDN->getNumOperands () == 1 );
72
- auto MDValue = ExtractIntegerFromMDNodeOperand (MDN, 0 );
73
- assert (MDValue >= 0 );
83
+ auto MDValue = ExtractUnsignedIntegerFromMDNodeOperand (MDN, 0 );
74
84
if (!SubGroupSize)
75
85
SubGroupSize = MDValue;
76
86
else
0 commit comments