[clang] [Clang][RISCV] Remove forced-sw-shadow-stack (PR #115355)

2024-11-07 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: LGTM https://github.com/llvm/llvm-project/pull/115355 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-28 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: LGTM. Thanks. https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-27 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-27 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,7 @@ +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s -fcf-protection=return | FileCheck %s +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s | FileCheck -check-prefix=NOSHADOWSTACK %

[clang] [llvm] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-25 Thread Ming-Yi Lai via cfe-commits
@@ -607,6 +607,9 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo { auto *Fn = cast(GV); Fn->addFnAttr("interrupt", Kind); + +if (CGM.getCodeGenOpts().CFProtectionReturn) mylai-mtk wrote: The early exit above may render this line unreach

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-24 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s -fcf-protection=return | FileCheck -check-prefix=NOTIGNORELISTED %s +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s | FileChec

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-24 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,9 @@ +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s -fcf-protection=return | FileCheck -check-prefix=NOTIGNORELISTED %s +// RUN: %clang_cc1 -triple riscv64-linux-unknown -target-feature +zimop -emit-llvm -o - %s | FileChec

[clang] [llvm] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-24 Thread Ming-Yi Lai via cfe-commits
@@ -607,6 +607,9 @@ class RISCVTargetCodeGenInfo : public TargetCodeGenInfo { auto *Fn = cast(GV); Fn->addFnAttr("interrupt", Kind); + +if (CGM.getCodeGenOpts().CFProtectionReturn) mylai-mtk wrote: After tracing the code, I believe the above lines

[clang] [llvm] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-24 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,30 @@ +; ModuleID = '/home/jhuang4/workspace/test.c' mylai-mtk wrote: I guess the inclusion of this file is a mistake? https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commit

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-23 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: LGTM, but please wait for others. I'm too junior to this community that I'm not sure if my words are enough 😂 https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-21 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-21 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/112477 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RISCV] Support -fcf-protection=return for RISC-V (PR #112477)

2024-10-21 Thread Ming-Yi Lai via cfe-commits
@@ -899,6 +899,10 @@ void CodeGenFunction::StartFunction(GlobalDecl GD, QualType RetTy, if (CodeGenOpts.PointerAuth.IndirectGotos) Fn->addFnAttr("ptrauth-indirect-gotos"); + // Add return control flow integrity attributes. + if (CodeGenOpts.CFProtectionReturn) +Fn

[clang] [llvm] [clang][RISCV] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/111661 >From 0cc12aa82111ead067485c0e846313563e516e6c Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Fri, 31 May 2024 17:03:04 +0800 Subject: [PATCH] [clang][RISCV] Emit RISCV function-signature-based CFI label in

[clang] [llvm] [clang][RISCV] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/111661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][RISCV] Emit RISCV function-signature-based CFI label in llvm::Function metadata (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/111661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][RISCV] Emit RISCV function-signature-based CFI label in llvm::Function (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited https://github.com/llvm/llvm-project/pull/111661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [llvm] [clang][RISCV] Introduce CodeGenModule::calcRISCVZicfilpFuncSigLabel() (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Update: * Rebase to `main` * Address comments: Expand the scope of this PR to allow testing * Address other comments https://github.com/llvm/llvm-project/pull/111661 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://list

[clang] [llvm] [clang][RISCV] Introduce CodeGenModule::calcRISCVZicfilpFuncSigLabel() (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
@@ -2829,6 +2829,56 @@ void CodeGenModule::CreateFunctionTypeMetadataForIcall(const FunctionDecl *FD, F->addTypeMetadata(0, llvm::ConstantAsMetadata::get(CrossDsoTypeId)); } +uint32_t +CodeGenModule::calcRISCVZicfilpFuncSigLabel(const FunctionType &FT, +

[clang] [llvm] [clang][RISCV] Introduce CodeGenModule::calcRISCVZicfilpFuncSigLabel() (PR #111661)

2024-10-11 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/111661 >From 9041af3df59b6f6f2f6c2ff335cc697dfd41ac73 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Fri, 31 May 2024 17:03:04 +0800 Subject: [PATCH] [clang][RISCV] Emit RISCV function-signature-based CFI label in

[clang] [clang][RISCV] Introduce CodeGenModule::calcRISCVZicfilpFuncSigLabel() (PR #111661)

2024-10-09 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk created https://github.com/llvm/llvm-project/pull/111661 This method calculates a CFI label used in the RISC-V Zicfilp func-sig CFI scheme for a given function type/declaration. The scheme, according to psABI, encodes the label based on function signature, and the

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-10-03 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Hello, is there anything more that I should amend about this PR? 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

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 35532cf0a9cc855fe5f0a4eefd4c343687a595dc Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Fri, 10 May 2024 14:16:59 +0800 Subject: [PATCH] [clang][RISCV] Add Zicfilp CFI scheme preprocessor macros These

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk closed https://github.com/llvm/llvm-project/pull/109784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Thanks :D https://github.com/llvm/llvm-project/pull/109784 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
@@ -198,6 +198,21 @@ TargetInfo::checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const { return false; } +CFBranchLabelSchemeKind TargetInfo::getDefaultCFBranchLabelScheme() const { + // if this hook is called, the target should override it to return a + // non

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109784 >From baa87159eb5b6966841bac0a8a089f4ce63d66e2 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH] [clang][RISCV] Introduce command line options for Zicfilp-backed

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
@@ -198,6 +198,21 @@ TargetInfo::checkCFProtectionBranchSupported(DiagnosticsEngine &Diags) const { return false; } +CFBranchLabelSchemeKind TargetInfo::getDefaultCFBranchLabelScheme() const { + // if this hook is called, the target should override it to return a + // non

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: > Could you update this PR? > https://github.com/llvm/llvm-project/commit/4579272e057e6ec77a2a660384080e1f57a17cf0 > is generally LGTM, but I assume this should process within this PR :) Sure, I'm just a few minutes behind you XD https://github.com/llvm/llvm-project/pull/1097

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109784 >From 7aaeaef35f63665bc943efca7ef1b603137522eb Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH] [clang][RISCV] Introduce command line options for Zicfilp-backed

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,90 @@ +// Default cf-branch-label-scheme is func-sig +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch -E -dM %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-ZICFILP-FUNC-SIG %s +// RUN: %

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 1a0aed20421b58114332975ad7d7fff90a21014a Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/2] [clang][RISCV] Introduce command line options for Zicfilp-ba

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Update: Always support `-fcf-protection=branch` for RISC-V targets 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

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
@@ -224,6 +225,34 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, else Builder.defineMacro("__riscv_32e"); } + + if (Opts.CFProtectionBranch) { +if (checkCFProtectionBranchSupported()) { + auto Scheme = Opts.getCFBranchLabelScheme(); +

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
@@ -134,6 +134,25 @@ class RISCVTargetInfo : public TargetInfo { bool validateGlobalRegisterVariable(StringRef RegName, unsigned RegSize, bool &HasSizeMismatch) const override; + + bool checkCFProtectionBranchSupported() const override

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-26 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 4579272e057e6ec77a2a660384080e1f57a17cf0 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/2] [clang][RISCV] Introduce command line options for Zicfilp-ba

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-25 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: > It is useful to protect a binary with an -mcpu that doesn't support Zicfilp. Generally I would agree that it's a good idea to protect a binary with an `-mcpu` that doesn't support Zicfilp, but to lift the check of Zicfilp would be misleading to naive compiler/RISC-V users w

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-25 Thread Ming-Yi Lai via cfe-commits
@@ -224,6 +225,34 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, else Builder.defineMacro("__riscv_32e"); } + + if (Opts.CFProtectionBranch) { +if (checkCFProtectionBranchSupported()) { + auto Scheme = Opts.getCFBranchLabelScheme(); +

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-25 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,90 @@ +// Default cf-branch-label-scheme is func-sig +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch -E -dM %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-ZICFILP-FUNC-SIG %s +// RUN: %

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-25 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 2eda754ee96aa416063ff65bddfc5e856b626454 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/4] [clang][RISCV] Introduce command line options for Zicfilp-ba

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk edited 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

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 0068ec08f28e2197a4982f876052f577988acd61 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/2] [clang][RISCV] Introduce command line options for Zicfilp-ba

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109784 >From 0068ec08f28e2197a4982f876052f577988acd61 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH] [clang][RISCV] Introduce command line options for Zicfilp-backed

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Update: Address comments Update: Split the CLI flag introduction to #109784 as per the suggestion from kito https://github.com/llvm/llvm-project/pull/109600 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.or

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
@@ -224,6 +224,26 @@ void RISCVTargetInfo::getTargetDefines(const LangOptions &Opts, else Builder.defineMacro("__riscv_32e"); } + + if (ISAInfo->hasExtension("zicfilp") && Opts.CFProtectionBranch) { +auto Scheme = Opts.getCFBranchLabelScheme(); +if (Scheme

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,90 @@ +// Default cf-branch-label-scheme is func-sig +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch -E -dM %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-ZICFILP-FUNC-SIG %s +// RUN: %

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
@@ -0,0 +1,90 @@ +// Default cf-branch-label-scheme is func-sig +// RUN: %clang --target=riscv32 -menable-experimental-extensions \ +// RUN: -march=rv32i_zicfilp1p0 -fcf-protection=branch -E -dM %s -o - \ +// RUN: | FileCheck --check-prefix=CHECK-ZICFILP-FUNC-SIG %s +// RUN: %

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From acd2093abeca6f52c0f01527333b38cf4321e74e Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/2] [clang][RISCV] Introduce command line options for Zicfilp-ba

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
@@ -2022,6 +2035,20 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; } + if (const Arg *A = Args.getLastArg(OPT_mcf_branch_label_scheme_EQ)) { ---

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
@@ -2022,6 +2035,20 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; } + if (const Arg *A = Args.getLastArg(OPT_mcf_branch_label_scheme_EQ)) { +if (Opts.C

[clang] [clang][RISCV] Introduce command line options for RISC-V Zicfilp CFI (PR #109784)

2024-09-24 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk created https://github.com/llvm/llvm-project/pull/109784 This patch introduces the CLI flag specified in riscv-non-isa/riscv-toolchain-conventions#54 for RISC-V Zicfilp-backed forward-edge control flow integrity conditioning. The first user of these CLI flags is e

[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: @MaskRay Sure, I also agree that `!cfi_type` is a too general name and covers too little possibility for its name. I picked this approach instead of adding RISC-V-specific metadata nodes just to avoid adding RISC-V specifics to the conceptually backend-neutral LLVM IR. However

[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk closed https://github.com/llvm/llvm-project/pull/109080 ___ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Update: Address comments 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

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
@@ -2841,6 +2841,10 @@ def fcf_protection : Flag<["-"], "fcf-protection">, Group, Visibility<[ClangOption, CLOption, CC1Option]>, Alias, AliasArgs<["full"]>, HelpText<"Enable cf-protection in 'full' mode">; +def fcf_branch_label_scheme_EQ : Joined<["-"], "fcf-branch-labe

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
@@ -3952,6 +3981,16 @@ bool CompilerInvocation::ParseLangArgs(LangOptions &Opts, ArgList &Args, } } + if (const Arg *const A = Args.getLastArg(OPT_fcf_branch_label_scheme_EQ)) { mylai-mtk wrote: Fixed https://github.com/llvm/llvm-project/pull/109600

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
@@ -2022,6 +2035,22 @@ bool CompilerInvocation::ParseCodeGenArgs(CodeGenOptions &Opts, ArgList &Args, Diags.Report(diag::err_drv_invalid_value) << A->getAsString(Args) << Name; } + if (const Arg *const A = Args.getLastArg(OPT_fcf_branch_label_scheme_EQ)) { -

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-23 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/109600 >From 3cae49e7cbff687c1303f8204f70c9c1105a9560 Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 4 Sep 2024 18:40:48 +0800 Subject: [PATCH 1/3] [clang][RISCV] Accept -fcf-protection=branch when Zicfilp ex

[clang] [Clang][RISCV] Add preprocessor macros for Zicfilp CFI scheme (PR #109600)

2024-09-22 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk created https://github.com/llvm/llvm-project/pull/109600 This patch adds preprocessor macros when Zicfilp CFI is enabled. The macros are proposed in riscv-non-isa/riscv-c-api-doc#76 , and the CLI flags are from riscv-non-isa/riscv-toolchain-conventions#54. >From

[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-22 Thread Ming-Yi Lai via cfe-commits
mylai-mtk wrote: Excuse me, @MaskRay . I don't understand your stance: > I understand the intention to generalize naming, but I feel that there is > significance chance that the over-generalization may not work with the > alternative CFI schemes, and this change could turn out to be needed w

[clang] [llvm] [KCFI][NFC] Rename the !kcfi_type Function metadata to !cfi_type (PR #109080)

2024-09-17 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk created https://github.com/llvm/llvm-project/pull/109080 According to the comments in , which introduces the KCFI sanitizer, the data structures of KCFI should avoid embedding the term "kcfi" in their names so that later/new CFI me

[clang] [clang] Fix FnInfoOpts::operator&= and FnInfoOpts::operator|= not updating assigned operands (PR #107050)

2024-09-04 Thread Ming-Yi Lai via cfe-commits
https://github.com/mylai-mtk updated https://github.com/llvm/llvm-project/pull/107050 >From e542003d82acfad40e1a3174ca23edf6e08a753f Mon Sep 17 00:00:00 2001 From: Ming-Yi Lai Date: Wed, 19 Jun 2024 11:28:52 +0800 Subject: [PATCH] [clang] Fix bug of FnInfoOpts::operator&= and FnInfoOpts::opera