Run LLVM verify pass on IR in assert builds.

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 <9erthalion6@gmail.com>
Discussion: https://postgr.es/m/CAFj8pRACpVFr7LMdVYENUkScG5FCYMZDDdSGNU-tch%2Bw98OxYg%40mail.gmail.com
This commit is contained in:
Thomas Munro 2024-07-15 16:20:09 +12:00
parent 91651347ba
commit 8583b1f993
2 changed files with 6 additions and 1 deletions

View 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);

View 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)