================ @@ -224,6 +225,34 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, else Builder.defineMacro("__riscv_32e"); } + + if (Opts.CFProtectionBranch) { + if (checkCFProtectionBranchSupported()) { + auto Scheme = Opts.getCFBranchLabelScheme(); + if (checkCFBranchLabelSchemeSupported(Scheme)) { + if (Scheme == CFBranchLabelSchemeKind::Default) + Scheme = getDefaultCFBranchLabelScheme(); + + Builder.defineMacro("__riscv_landing_pad", "1"); + switch (Scheme) { + case CFBranchLabelSchemeKind::Unlabeled: + Builder.defineMacro("__riscv_landing_pad_unlabeled", "1"); + break; + case CFBranchLabelSchemeKind::FuncSig: + Builder.defineMacro("__riscv_landing_pad_func_sig", "1"); + break; + case CFBranchLabelSchemeKind::Default: + llvm_unreachable("default cf-branch-label scheme should already be " + "transformed to other scheme"); + } + } else + Diags.Report(diag::err_opt_not_valid_on_target) + << (Twine("-mcf-branch-label-scheme=") + + getCFBranchLabelSchemeFlagVal(Scheme)) + .str(); + } else + Diags.Report(diag::err_opt_not_valid_on_target) << "cf-protection=branch"; ---------------- topperc wrote:
Won't this get diagnosed later in CodeGenModule anyway? https://github.com/llvm/llvm-project/pull/109600 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits