[clang] [llvm] [win] Add a flag to control the Control Flow Guard mechanism on Windows (PR #176276)

Matt Arsenault via cfe-commits cfe-commits at lists.llvm.org
Thu Jan 22 13:46:33 PST 2026


================
@@ -1132,6 +1132,13 @@ void CodeGenModule::Release() {
         llvm::Module::Warning, "cfguard",
         static_cast<unsigned>(llvm::ControlFlowGuardMode::TableOnly));
   }
+  if (CodeGenOpts.getWinControlFlowGuardMechanism() !=
+      llvm::ControlFlowGuardMechanism::Automatic) {
+    // Specify the Control Flow Guard mechanism to use on Windows.
+    getModule().addModuleFlag(
+        llvm::Module::Warning, "cfguard-mechanism",
----------------
arsenm wrote:

Add test for the warning link behavior? 

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


More information about the cfe-commits mailing list