Merge pull request #84622 from gottesmm/pr-7065a633780e3a54b56563650e321ec0801bcb45

[sil-llvm-gen] Run Sema before we attempt to emit IR.
This commit is contained in:
Michael Gottesman
2025-10-07 00:57:05 -07:00
committed by GitHub

View File

@@ -469,6 +469,15 @@ int sil_llvm_gen_main(ArrayRef<const char *> argv, void *MainAddr) {
desc.out = &outFile->getOS();
if (options.OutputKind == IRGenOutputKind::LLVMAssemblyBeforeOptimization) {
// We need to perform Sema here since IRGenRequest itself does not perform
// Sema (unlike OptimizedIRRequest).
CI.performSema();
// If Sema produced an error, exit early.
bool HadError = CI.getASTContext().hadError();
if (HadError)
exit(-1);
auto generatedMod = evaluateOrFatal(eval, IRGenRequest{desc});
if (!generatedMod)
return 1;