https://github.com/jaidTw created https://github.com/llvm/llvm-project/pull/223297
The work on "func-sig" label scheme is discontinued, so it's better to switch the default to unlabeled at this time. >From 775ba9725800a649c0d174a7ec737cb9b9c7b5d4 Mon Sep 17 00:00:00 2001 From: Jesse Huang <[email protected]> Date: Fri, 21 Aug 2026 00:38:04 -0700 Subject: [PATCH] [Clang] Make Unlabeled the default branch label scheme The work on "func-sig" label scheme is discontinued, so it's better to switch the default to unlabeled at this time. --- clang/lib/Basic/Targets/RISCV.cpp | 7 +------ clang/lib/Basic/Targets/RISCV.h | 2 +- clang/test/CodeGen/RISCV/riscv-cf-protection.c | 10 ---------- 3 files changed, 2 insertions(+), 17 deletions(-) diff --git a/clang/lib/Basic/Targets/RISCV.cpp b/clang/lib/Basic/Targets/RISCV.cpp index 6afef3e2c7c482..df99a0def1d4cc 100644 --- a/clang/lib/Basic/Targets/RISCV.cpp +++ b/clang/lib/Basic/Targets/RISCV.cpp @@ -651,12 +651,7 @@ bool RISCVTargetInfo::checkCFBranchLabelSchemeSupported( // implements it switch (Scheme) { case CFBranchLabelSchemeKind::Default: - Diags.Report(diag::err_opt_not_valid_without_opt) - << "-fcf-protection=branch" - << (Twine("-mcf-branch-label-scheme=") + - getCFBranchLabelSchemeFlagVal(CFBranchLabelSchemeKind::Unlabeled)) - .str(); - return false; + return true; case CFBranchLabelSchemeKind::Unlabeled: return true; case CFBranchLabelSchemeKind::FuncSig: diff --git a/clang/lib/Basic/Targets/RISCV.h b/clang/lib/Basic/Targets/RISCV.h index edaac3e74f9d32..4a6dd398571574 100644 --- a/clang/lib/Basic/Targets/RISCV.h +++ b/clang/lib/Basic/Targets/RISCV.h @@ -154,7 +154,7 @@ class RISCVTargetInfo : public TargetInfo { } CFBranchLabelSchemeKind getDefaultCFBranchLabelScheme() const override { - return CFBranchLabelSchemeKind::FuncSig; + return CFBranchLabelSchemeKind::Unlabeled; } bool diff --git a/clang/test/CodeGen/RISCV/riscv-cf-protection.c b/clang/test/CodeGen/RISCV/riscv-cf-protection.c index 91545661032762..f957890cd9f6f4 100644 --- a/clang/test/CodeGen/RISCV/riscv-cf-protection.c +++ b/clang/test/CodeGen/RISCV/riscv-cf-protection.c @@ -70,22 +70,12 @@ // RUN: -emit-llvm %s -o - 2>&1 | FileCheck \ // RUN: --check-prefixes=NO-FLAG,FUNC-SIG-SCHEME-UNUSED %s -// Default -mcf-branch-label-scheme is func-sig -// RUN: not %clang --target=riscv32 -fcf-protection=branch -S -emit-llvm %s \ -// RUN: -o - 2>&1 | FileCheck --check-prefixes=FORCE-UNLABELED %s - -// Default -mcf-branch-label-scheme is func-sig -// RUN: not %clang --target=riscv64 -fcf-protection=branch -S -emit-llvm %s \ -// RUN: -o - 2>&1 | FileCheck --check-prefixes=FORCE-UNLABELED %s - // UNLABELED-SCHEME-UNUSED: warning: argument unused during compilation: // UNLABELED-SCHEME-UNUSED-SAME: '-mcf-branch-label-scheme=unlabeled' // FUNC-SIG-SCHEME-UNUSED: warning: argument unused during compilation: // FUNC-SIG-SCHEME-UNUSED-SAME: '-mcf-branch-label-scheme=func-sig' // FUNC-SIG-NOSUPPORT: error: option '-mcf-branch-label-scheme=func-sig' is // FUNC-SIG-NOSUPPORT-SAME: unsupported; consider using '-mcf-branch-label-scheme=unlabeled' -// FORCE-UNLABELED: error: option '-fcf-protection=branch' cannot be specified -// FORCE-UNLABELED-SAME: without '-mcf-branch-label-scheme=unlabeled' // BRANCH-PROT-FLAG-DAG: [[P_FLAG:![0-9]+]] = !{i32 8, !"cf-protection-branch", i32 1} // UNLABELED-FLAG-DAG: [[S_FLAG:![0-9]+]] = !{i32 1, !"cf-branch-label-scheme", !"unlabeled"} _______________________________________________ cfe-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
