aboutsummaryrefslogtreecommitdiff
path: root/src/backend/jit/llvm/llvmjit_inline.cpp
diff options
context:
space:
mode:
authorThomas Munro <tmunro@postgresql.org>2021-07-22 14:11:17 +1200
committerThomas Munro <tmunro@postgresql.org>2021-07-22 15:02:18 +1200
commit0207d5fbebed7eb698a7e5f3adf30fafe95bc4b9 (patch)
tree94ddb5c5a100ba91a451f03ed644d2566330c6ae /src/backend/jit/llvm/llvmjit_inline.cpp
parent91e9e89dccdfdf4216953d3d8f5515dcdef177fb (diff)
downloadpostgresql-0207d5fbebed7eb698a7e5f3adf30fafe95bc4b9.tar.gz
postgresql-0207d5fbebed7eb698a7e5f3adf30fafe95bc4b9.zip
jit: Don't inline functions that access thread-locals.
Code inlined by LLVM can crash or fail with "Relocation type not implemented yet!" if it tries to access thread local variables. Don't inline such code. Back-patch to 11, where LLVM arrived. Bug #16696. Author: Dmitry Marakasov <amdmi3@amdmi3.ru> Reviewed-by: Andres Freund <andres@anarazel.de> Discussion: https://postgr.es/m/16696-29d944a33801fbfe@postgresql.org
Diffstat (limited to 'src/backend/jit/llvm/llvmjit_inline.cpp')
-rw-r--r--src/backend/jit/llvm/llvmjit_inline.cpp11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/backend/jit/llvm/llvmjit_inline.cpp b/src/backend/jit/llvm/llvmjit_inline.cpp
index ea90fd5b24f..6f03595db5a 100644
--- a/src/backend/jit/llvm/llvmjit_inline.cpp
+++ b/src/backend/jit/llvm/llvmjit_inline.cpp
@@ -609,6 +609,17 @@ function_inlinable(llvm::Function &F,
elog(FATAL, "failed to materialize metadata");
/*
+ * Don't inline functions that access thread local variables. That
+ * doesn't work on current LLVM releases (but might in future).
+ */
+ if (rv->isThreadLocal())
+ {
+ ilog(DEBUG1, "cannot inline %s due to thread-local variable %s",
+ F.getName().data(), rv->getName().data());
+ return false;
+ }
+
+ /*
* Never want to inline externally visible vars, cheap enough to
* reference.
*/