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

Daniel Paoliello via cfe-commits cfe-commits at lists.llvm.org
Fri Jan 23 09:00:42 PST 2026


================
@@ -797,6 +798,21 @@ bool AArch64Arm64ECCallLowering::runOnModule(Module &Mod) {
   // Check if this module has the cfguard flag and read its value.
   CFGuardModuleFlag = M->getControlFlowGuardMode();
 
+  // Warn if the module flag requests an unsupported CFGuard mechanism.
+  if (CFGuardModuleFlag == ControlFlowGuardMode::Enabled) {
+    if (auto *CI = mdconst::dyn_extract_or_null<ConstantInt>(
+            Mod.getModuleFlag("cfguard-mechanism"))) {
----------------
dpaoliello wrote:

I think this deserves a post in the discourse: personally, I'd be worried about bloating LangRef (which is already massive with all the intrinsics) with the module flags. Maybe we should consider putting the module flags in a separate doc that LagRef links to and, while doing that, split out the intrinsics as well.

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


More information about the cfe-commits mailing list