================
@@ -2810,10 +2813,88 @@ void Verifier::verifyFunctionMetadata(
"expected a constant integer operand for !kcfi_type", MD);
Check(cast<ConstantInt>(C)->getBitWidth() == 32,
"expected a 32-bit integer constant operand for !kcfi_type", MD);
+ } else if (Pair.first == Context.getMDKindID("reqd_work_group_size")) {
+ MDNode *MD = Pair.second;
+ Check(MD->getNumOperands() == 3,
+ "reqd_work_group_size must have exactly three operands", MD);
+ if (MD->getNumOperands() != 3)
+ continue;
+
+ uint64_t Product = 1;
+ for (unsigned I = 0; I != 3; ++I) {
+ ConstantInt *C = mdconst::dyn_extract<ConstantInt>(MD->getOperand(I));
+ Check(C, "reqd_work_group_size operands must be integer constants",
MD);
+ if (!C)
+ break;
+
+ const APInt &Value = C->getValue();
+ Check(Value.getActiveBits() <= 64,
+ "reqd_work_group_size operands must fit in 64 bits", MD);
+ if (Value.getActiveBits() > 64)
+ break;
+
+ uint64_t Dim = Value.getZExtValue();
+ Check(Dim == 0 || Product <= std::numeric_limits<uint64_t>::max() /
Dim,
+ "reqd_work_group_size product must fit in 64 bits", MD);
+ if (Dim != 0 && Product > std::numeric_limits<uint64_t>::max() / Dim)
+ break;
+ Product *= Dim;
+ }
}
}
}
+void Verifier::verifyAMDGPUReqdWorkGroupSize(const Function &F) {
+ if (!TT.isAMDGPU())
----------------
shiltian wrote:
This check is guarded by triple, because `amdgpu-flat-work-group-size` means
nothing if the target triple is not AMDGPU.
https://github.com/llvm/llvm-project/pull/200989
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits