summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMark Kettenis <kettenis@cvs.openbsd.org>2024-03-18 00:15:11 +0000
committerMark Kettenis <kettenis@cvs.openbsd.org>2024-03-18 00:15:11 +0000
commitef558f091c505ddc9ccc98e1f578db6a041f0db2 (patch)
tree2be7a1627a43b873f3971c8fa4c5761feb8b37b3
parent14dfaaa659da9e7fbf5118bef1154bfc2797d167 (diff)
Tell LLVM to generate code with BTI instructions.
"looks ok" jsg@, ok deraadt@
-rw-r--r--lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c4
-rw-r--r--lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp7
-rw-r--r--lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h4
3 files changed, 15 insertions, 0 deletions
diff --git a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c
index 24d082398..a5b6b0eba 100644
--- a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c
+++ b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_init.c
@@ -360,6 +360,10 @@ init_gallivm_state(struct gallivm_state *gallivm, const char *name,
lp_set_module_stack_alignment_override(gallivm->module, 4);
#endif
+#if DETECT_ARCH_AARCH64
+ lp_set_module_branch_target_enforcement(gallivm->module);
+#endif
+
gallivm->builder = LLVMCreateBuilderInContext(gallivm->context);
if (!gallivm->builder)
goto fail;
diff --git a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 5e7a30a6c..ead5b91ea 100644
--- a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -619,3 +619,10 @@ lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align)
M->setOverrideStackAlignment(align);
#endif
}
+
+extern "C" void
+lp_set_module_branch_target_enforcement(LLVMModuleRef MRef)
+{
+ llvm::Module *M = llvm::unwrap(MRef);
+ M->addModuleFlag(llvm::Module::Override, "branch-target-enforcement", 1);
+}
diff --git a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h
index fa0ce9016..2447bffef 100644
--- a/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h
+++ b/lib/mesa/src/gallium/auxiliary/gallivm/lp_bld_misc.h
@@ -94,6 +94,10 @@ lp_free_objcache(void *objcache);
void
lp_set_module_stack_alignment_override(LLVMModuleRef M, unsigned align);
+
+void
+lp_set_module_branch_target_enforcement(LLVMModuleRef M);
+
#ifdef __cplusplus
}
#endif