llvmorg-github-actions[bot] wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: llvmbot <details> <summary>Changes</summary> Backport 23a601dc9690 Requested by: @<!-- -->androm3da --- Full diff: https://github.com/llvm/llvm-project/pull/216583.diff 2 Files Affected: - (modified) clang/lib/CodeGen/BackendUtil.cpp (+2-1) - (added) clang/test/CodeGen/kcfi-hexagon.c (+14) ``````````diff diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp index 2b755fa916e55..e3ae446fbe81b 100644 --- a/clang/lib/CodeGen/BackendUtil.cpp +++ b/clang/lib/CodeGen/BackendUtil.cpp @@ -668,7 +668,8 @@ static void addKCFIPass(const Triple &TargetTriple, const LangOptions &LangOpts, // If the back-end supports KCFI operand bundle lowering, skip KCFIPass. if (TargetTriple.getArch() == llvm::Triple::x86_64 || TargetTriple.isAArch64(64) || TargetTriple.isRISCV() || - TargetTriple.isARM() || TargetTriple.isThumb()) + TargetTriple.isARM() || TargetTriple.isThumb() || + TargetTriple.getArch() == llvm::Triple::hexagon) return; // Ensure we lower KCFI operand bundles with -O0. diff --git a/clang/test/CodeGen/kcfi-hexagon.c b/clang/test/CodeGen/kcfi-hexagon.c new file mode 100644 index 0000000000000..b08758d4b81a4 --- /dev/null +++ b/clang/test/CodeGen/kcfi-hexagon.c @@ -0,0 +1,14 @@ +// Hexagon lowers KCFI operand bundles in the back end. Clang must leave the "kcfi" +// operand bundles in place for the back end instead of running the middle-end +// KCFIPass, which would rewrite them into a software llvm.debugtrap check. +// +// Verify the bundle survives the optimizer pipeline at both -O0 and -O2 and +// is not lowered to debugtrap. +// +// RUN: %clang_cc1 -triple hexagon-unknown-linux-musl -O0 -fsanitize=kcfi -emit-llvm -o - %s | FileCheck %s +// RUN: %clang_cc1 -triple hexagon-unknown-linux-musl -O2 -fsanitize=kcfi -emit-llvm -o - %s | FileCheck %s + +// CHECK-LABEL: define {{.*}}void @call( +// CHECK: call void %{{.*}}() {{.*}}[ "kcfi"(i32 {{-?[0-9]+}}) ] +// CHECK-NOT: @llvm.debugtrap +void call(void (*f)(void)) { f(); } `````````` </details> https://github.com/llvm/llvm-project/pull/216583 _______________________________________________ llvm-branch-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits
