@@ -6538,9 +6538,27 @@ 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<[]>, Requires<[IsARM]> {
6548+ let Size = 28; // 7 instructions (bic, ldr, 4x eor, beq, udf)
6549+ }
6550+
6551+ def KCFI_CHECK_Thumb2
65426552 : PseudoInst<(outs), (ins GPR:$ptr, i32imm:$type), NoItinerary, []>,
6543- Sched<[]>;
6553+ Sched<[]>, Requires<[IsThumb2]> {
6554+ let Size = 32; // worst-case 9 instructions (push, bic, ldr, 4x eor, pop, beq.w, udf)
6555+ }
6556+
6557+ def KCFI_CHECK_Thumb1
6558+ : PseudoInst<(outs), (ins GPR:$ptr, i32imm:$type), NoItinerary, []>,
6559+ Sched<[]>, Requires<[IsThumb1Only]> {
6560+ let Size = 50; // worst-case 25 instructions (pushes, bic helper, type building, cmp, pops)
6561+ }
65446562
65456563//===----------------------------------------------------------------------===//
65466564// Instructions used for emitting unwind opcodes on Windows.
0 commit comments