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

Nicholas Mosier via llvm-commits llvm-commits at lists.llvm.org
Sat Jan 13 09:40:36 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());
----------------
nmosier wrote:

Thanks for the catch! I addressed that in the latest commit.

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


More information about the llvm-commits mailing list