pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
pgsql: jit: Support opaque pointers in LLVM 16.
8+ messages / 3 participants
[nested] [flat]

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:33 Thomas Munro <tmunro@postgresql.org>
  2023-10-20 14:45 ` Re: pgsql: jit: Support opaque pointers in LLVM 16. Tom Lane <tgl@sss.pgh.pa.us>
  2023-11-06 18:11 ` Re: pgsql: jit: Support opaque pointers in LLVM 16. Alvaro Herrera <alvherre@alvh.no-ip.org>
  0 siblings, 2 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/37d5babb5cfa4c6795b3cb6de964ba019d3d60ab

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        |  59 ++---
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++-----
src/backend/jit/llvm/llvmjit_expr.c   | 401 ++++++++++++++++++++--------------
src/backend/jit/llvm/llvmjit_types.c  |  39 +++-
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/backend/jit/llvm/meson.build      |   2 +-
src/include/jit/llvmjit.h             |   7 +
src/include/jit/llvmjit_emit.h        | 106 ++++++---
8 files changed, 481 insertions(+), 264 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: jit: Support opaque pointers in LLVM 16.
  2023-10-18 10:33 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
@ 2023-10-20 14:45 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 8+ messages in thread

From: Tom Lane @ 2023-10-20 14:45 UTC (permalink / raw)
  To: Thomas Munro <tmunro@postgresql.org>; +Cc: pgsql-committers@lists.postgresql.org

Thomas Munro <tmunro@postgresql.org> writes:
> jit: Support opaque pointers in LLVM 16.

I chanced to notice that the configure script (and meson too) is
still doing

  PGAC_PROG_VARCC_VARFLAGS_OPT(CLANG, BITCODE_CFLAGS, [-Xclang -no-opaque-pointers])
  PGAC_PROG_VARCXX_VARFLAGS_OPT(CLANGXX, BITCODE_CXXFLAGS, [-Xclang -no-opaque-pointers])

Shouldn't we remove that now?

			regards, tom lane





^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* Re: pgsql: jit: Support opaque pointers in LLVM 16.
  2023-10-18 10:33 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
@ 2023-11-06 18:11 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
  1 sibling, 0 replies; 8+ messages in thread

From: Alvaro Herrera @ 2023-11-06 18:11 UTC (permalink / raw)
  To: Thomas Munro <tmunro@postgresql.org>; +Cc: pgsql-hackers@lists.postgresql.org

On 2023-Oct-18, Thomas Munro wrote:

> jit: Support opaque pointers in LLVM 16.
> 
> Remove use of LLVMGetElementType() and provide the type of all pointers
> to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
> versions[1].
> 
>  * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.

I have LLVM 14 (whatever Debian ships[*]), and running headerscheck results
in a bunch of warnings from this:

In file included from /tmp/headerscheck.s89Gdv/test.c:2:
/pgsql/source/master/src/include/jit/llvmjit_emit.h: In function ‘l_call’:
/pgsql/source/master/src/include/jit/llvmjit_emit.h:141:9: warning: ‘LLVMBuildCall’ is deprecated [-Wdeprecated-declarations]
  141 |         return LLVMBuildCall(b, fn, args, nargs, name);
      |         ^~~~~~
In file included from /usr/include/llvm-c/Core.h:18,
                 from /pgsql/source/master/src/include/jit/llvmjit_emit.h:18:
/usr/include/llvm-c/Core.h:3991:1: note: declared here
 3991 | LLVM_ATTRIBUTE_C_DEPRECATED(
      | ^~~~~~~~~~~~~~~~~~~~~~~~~~~


These warnings go away if I change the conditional from
LLVM_VERSION_MAJOR < 16 to 14.

Let's ... do that?  As in the attached patch.

In 13, there's a comment about it being deprecated, but no macro to make
the compiler whine:
https://github.com/hdoc/llvm-project/blob/release/13.x/llvm/include/llvm-c/Core.h#L3953

This changed in 14:
https://github.com/hdoc/llvm-project/blob/release/14.x/llvm/include/llvm-c/Core.h#L3898


[*] apt policy llvm:
llvm:
  Installed: 1:14.0-55.7~deb12u1
  Candidate: 1:14.0-55.7~deb12u1
  Version table:
 *** 1:14.0-55.7~deb12u1 500
        500 http://ftp.de.debian.org/debian bookworm/main amd64 Packages
        100 /var/lib/dpkg/status

-- 
Álvaro Herrera        Breisgau, Deutschland  —  https://www.EnterpriseDB.com/

Attachments:

  0001-use-non-deprecated-LLVM-functions-starting-with-its-.patch (text/x-diff, 0B) download

^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:33 Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
REL_16_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/74d19ec096dfbda5782e62892de7e86a104f8265

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        |  57 ++---
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++-----
src/backend/jit/llvm/llvmjit_expr.c   | 401 ++++++++++++++++++++--------------
src/backend/jit/llvm/llvmjit_types.c  |  39 +++-
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/backend/jit/llvm/meson.build      |   2 +-
src/include/jit/llvmjit.h             |   7 +
src/include/jit/llvmjit_emit.h        | 106 ++++++---
8 files changed, 479 insertions(+), 264 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:33 Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:33 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
REL_15_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/eed1feb3fee1a558b67b04cbd709f31142f071d5

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        |  57 ++---
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++-----
src/backend/jit/llvm/llvmjit_expr.c   | 397 ++++++++++++++++++++--------------
src/backend/jit/llvm/llvmjit_types.c  |  39 +++-
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/include/jit/llvmjit.h             |   7 +
src/include/jit/llvmjit_emit.h        | 106 ++++++---
7 files changed, 476 insertions(+), 261 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:34 Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:34 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
REL_14_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/82d9a782a29633a7d2c8c0785e4162a46f93d23b

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        |  57 ++---
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++-----
src/backend/jit/llvm/llvmjit_expr.c   | 397 ++++++++++++++++++++--------------
src/backend/jit/llvm/llvmjit_types.c  |  39 +++-
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/include/jit/llvmjit.h             |   6 +
src/include/jit/llvmjit_emit.h        | 106 ++++++---
7 files changed, 475 insertions(+), 261 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:34 Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:34 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
REL_13_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/f28956b239f19858e7c429d3065678ce79c5104b

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        | 130 ++++++-----
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++-----
src/backend/jit/llvm/llvmjit_expr.c   | 400 ++++++++++++++++++++--------------
src/backend/jit/llvm/llvmjit_types.c  |  25 +++
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/include/jit/llvmjit.h             |   7 +
src/include/jit/llvmjit_emit.h        | 106 ++++++---
7 files changed, 502 insertions(+), 297 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread

* pgsql: jit: Support opaque pointers in LLVM 16.
@ 2023-10-18 10:34 Thomas Munro <tmunro@postgresql.org>
  0 siblings, 0 replies; 8+ messages in thread

From: Thomas Munro @ 2023-10-18 10:34 UTC (permalink / raw)
  To: pgsql-committers@lists.postgresql.org

jit: Support opaque pointers in LLVM 16.

Remove use of LLVMGetElementType() and provide the type of all pointers
to LLVMBuildXXX() functions when emitting IR, as required by modern LLVM
versions[1].

 * For LLVM <= 14, we'll still use the old LLVMBuildXXX() functions.
 * For LLVM == 15, we'll continue to do the same, explicitly opting
   out of opaque pointer mode.
 * For LLVM >= 16, we'll use the new LLVMBuildXXX2() functions that take
   the extra type argument.

The difference is hidden behind some new IR emitting wrapper functions
l_load(), l_gep(), l_call() etc.  The change is mostly mechanical,
except that at each site the correct type had to be provided.

In some places we needed to do some extra work to get functions types,
including some new wrappers for C++ APIs that are not yet exposed by in
LLVM's C API, and some new "example" functions in llvmjit_types.c
because it's no longer possible to start from the function pointer type
and ask for the function type.

Back-patch to 12, because it's a little tricker in 11 and we agreed not
to put the latest LLVM support into the upcoming final release of 11.

[1] https://llvm.org/docs/OpaquePointers.html

Reviewed-by: Dmitry Dolgov <9erthalion6@gmail.com>
Reviewed-by: Ronan Dunklau <ronan.dunklau@aiven.io>
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://postgr.es/m/CA%2BhUKGKNX_%3Df%2B1C4r06WETKTq0G4Z_7q4L4Fxn5WWpMycDj9Fw%40mail.gmail.com

Branch
------
REL_12_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/15ddc9725eb73d97a16652c7c90d993302773544

Modified Files
--------------
src/backend/jit/llvm/llvmjit.c        | 193 +++++++-------
src/backend/jit/llvm/llvmjit_deform.c | 119 +++++----
src/backend/jit/llvm/llvmjit_expr.c   | 471 +++++++++++++++++++---------------
src/backend/jit/llvm/llvmjit_types.c  |  27 +-
src/backend/jit/llvm/llvmjit_wrap.cpp |  12 +
src/include/jit/llvmjit.h             |  20 +-
src/include/jit/llvmjit_emit.h        | 106 ++++++--
7 files changed, 565 insertions(+), 383 deletions(-)



^ permalink  raw  reply  [nested|flat] 8+ messages in thread


end of thread, other threads:[~2023-11-06 18:11 UTC | newest]

Thread overview: 8+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2023-10-18 10:33 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
2023-10-20 14:45 ` Tom Lane <tgl@sss.pgh.pa.us>
2023-11-06 18:11 ` Alvaro Herrera <alvherre@alvh.no-ip.org>
2023-10-18 10:33 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
2023-10-18 10:33 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
2023-10-18 10:34 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
2023-10-18 10:34 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>
2023-10-18 10:34 pgsql: jit: Support opaque pointers in LLVM 16. Thomas Munro <tmunro@postgresql.org>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox