Mesa (main): gallivm: add new wrapper around Module::setOverrideStackAlignment()

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Thu Jul 22 17:48:18 UTC 2021


Module: Mesa
Branch: main
Commit: c1b4c64a28d9fc093229eab91a3a7fc4cb4fe29a
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=c1b4c64a28d9fc093229eab91a3a7fc4cb4fe29a

Author: Kai Wasserbäch <kai at dev.carbon-project.org>
Date:   Thu Jul 22 07:34:09 2021 +0200

gallivm: add new wrapper around Module::setOverrideStackAlignment()

We need it in the next commit to replace setting the stack alignment on
i386 with LLVM >= 13 through the TargetOption::StackAlignmentOverride,
which was removed in the upstream commit
<https://github.com/llvm/llvm-project/commit/3787ee457173c3612aac4c9b1a2b6d6ab0202616>.

Unfortunately Module::setOverrideStackAlignment() is not available
through the C API and we need to wrap it ourselves.

Signed-off-by: Kai Wasserbäch <kai at dev.carbon-project.org>
Reference: mesa/mesa#4906
Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11940>

---

 src/gallium/auxiliary/gallivm/lp_bld_misc.cpp | 9 +++++++++
 src/gallium/auxiliary/gallivm/lp_bld_misc.h   | 3 +++
 2 files changed, 12 insertions(+)

diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
index 44d07fe69c6..5f52ed08fae 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.cpp
@@ -615,3 +615,12 @@ lp_is_function(LLVMValueRef v)
 {
 	return LLVMGetValueKind(v) == LLVMFunctionValueKind;
 }
+
+extern "C" void
+lp_set_module_stack_alignment_override(LLVMModuleRef MRef, unsigned align)
+{
+#if LLVM_VERSION_MAJOR >= 13
+   llvm::Module *M = llvm::unwrap(MRef);
+   M->setOverrideStackAlignment(align);
+#endif
+}
diff --git a/src/gallium/auxiliary/gallivm/lp_bld_misc.h b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
index f2a15f19e47..fa0ce90162e 100644
--- a/src/gallium/auxiliary/gallivm/lp_bld_misc.h
+++ b/src/gallium/auxiliary/gallivm/lp_bld_misc.h
@@ -91,6 +91,9 @@ lp_is_function(LLVMValueRef v);
 
 void
 lp_free_objcache(void *objcache);
+
+void
+lp_set_module_stack_alignment_override(LLVMModuleRef M, unsigned align);
 #ifdef __cplusplus
 }
 #endif



More information about the mesa-commit mailing list