Run LLVM verify pass on IR in assert builds.
authorThomas Munro <[email protected]>
Mon, 15 Jul 2024 04:20:09 +0000 (16:20 +1200)
committerThomas Munro <[email protected]>
Mon, 15 Jul 2024 09:48:48 +0000 (21:48 +1200)
The problem fixed by commit 53c8d6c9 would have been noticed if we'd
been running LLVM's verify pass on generated IR.  Doing so also reveals
a complaint about incorrect name mangling, fixed here.  Only enabled for
LLVM 17+ because it uses the new pass manager API.

Suggested-by: Dmitry Dolgov <[email protected]>
Discussion: https://postgr.es/m/CAFj8pRACpVFr7LMdVYENUkScG5FCYMZDDdSGNU-tch%2Bw98OxYg%40mail.gmail.com

src/backend/jit/llvm/llvmjit.c
src/backend/jit/llvm/llvmjit_expr.c

index 1d439f2455455dfee2c26ca9ee8e5c6c07bda23b..0bafe309bb6c7217aab66950bfa894f7d8181df0 100644 (file)
@@ -714,6 +714,11 @@ llvm_optimize_module(LLVMJitContext *context, LLVMModuleRef module)
    LLVMPassBuilderOptionsSetDebugLogging(options, 1);
 #endif
 
+   /* In assertion builds, run the LLVM verify pass. */
+#ifdef USE_ASSERT_CHECKING
+   LLVMPassBuilderOptionsSetVerifyEach(options, true);
+#endif
+
    LLVMPassBuilderOptionsSetInlinerThreshold(options, 512);
 
    err = LLVMRunPasses(module, passes, NULL, options);
index 306aea82d3b7b3942174196dc427221101c0efa9..cbd9ed7cc4b65829bae9320dabb2b8973f0825f7 100644 (file)
@@ -2765,7 +2765,7 @@ create_LifetimeEnd(LLVMModuleRef mod)
    LLVMContextRef lc;
 
    /* variadic pointer argument */
-   const char *nm = "llvm.lifetime.end.p0i8";
+   const char *nm = "llvm.lifetime.end.p0";
 
    fn = LLVMGetNamedFunction(mod, nm);
    if (fn)