[llvm] [X86] Add support for indirect branch tracking in jump tables (PR #77679)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 13 02:20:16 PST 2024


================
@@ -186,5 +197,15 @@ bool X86IndirectBranchTrackingPass::runOnMachineFunction(MachineFunction &MF) {
       }
     }
   }
+
+  // If strong CF protections are enabled (Level > 1), then add ENDBRs to all
+  // jump table BBs, since jump table branches will not have the 'notrack'
+  // prefix.
+  if (CFProtectionLevel > 1)
+    if (const MachineJumpTableInfo *JTI = MF.getJumpTableInfo())
+      for (const MachineJumpTableEntry &JTE : JTI->getJumpTables())
+        for (MachineBasicBlock *MBB : JTE.MBBs)
+          addENDBR(*MBB, MBB->begin());
----------------
phoebewang wrote:

`Changed |= addENDBR(*MBB, MBB->begin());`

https://github.com/llvm/llvm-project/pull/77679


More information about the llvm-commits mailing list