@@ -6538,9 +6538,32 @@ def : Pat<(atomic_fence (timm), 0), (MEMBARRIER)>;
65386538//===----------------------------------------------------------------------===//
65396539// KCFI check pseudo-instruction.
65406540//===----------------------------------------------------------------------===//
6541- def KCFI_CHECK
6541+ // KCFI_CHECK pseudo-instruction for Kernel Control-Flow Integrity.
6542+ // Expands to a sequence that verifies the function pointer's type hash.
6543+ // Different sizes for different architectures due to different expansions.
6544+
6545+ def KCFI_CHECK_ARM
6546+ : PseudoInst<(outs), (ins GPR:$ptr, i32imm:$type), NoItinerary, []>,
6547+ Sched<[]>,
6548+ Requires<[IsARM]> {
6549+ let Size = 28; // 7 instructions (bic, ldr, 4x eor, beq, udf)
6550+ }
6551+
6552+ def KCFI_CHECK_Thumb2
65426553 : PseudoInst<(outs), (ins GPR:$ptr, i32imm:$type), NoItinerary, []>,
6543- Sched<[]>;
6554+ Sched<[]>,
6555+ Requires<[IsThumb2]> {
6556+ let Size =
6557+ 32; // worst-case 9 instructions (push, bic, ldr, 4x eor, pop, beq.w, udf)
6558+ }
6559+
6560+ def KCFI_CHECK_Thumb1
6561+ : PseudoInst<(outs), (ins GPR:$ptr, i32imm:$type), NoItinerary, []>,
6562+ Sched<[]>,
6563+ Requires<[IsThumb1Only]> {
6564+ let Size = 50; // worst-case 25 instructions (pushes, bic helper, type
6565+ // building, cmp, pops)
6566+ }
65446567
65456568//===----------------------------------------------------------------------===//
65466569// Instructions used for emitting unwind opcodes on Windows.
0 commit comments