From fb947c365e95298a4619b8db2c0d40b9d69172f2 Mon Sep 17 00:00:00 2001 From: Andrew Kelley Date: Wed, 13 May 2020 22:20:31 -0400 Subject: [PATCH] work around stage1 compiler bug breaking from inside the block with defers in scope triggered broken LLVM module found: Terminator found in the middle of a basic block! --- src-self-hosted/ir.zig | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) diff --git a/src-self-hosted/ir.zig b/src-self-hosted/ir.zig index d7a2228f74..6efc3cdbc3 100644 --- a/src-self-hosted/ir.zig +++ b/src-self-hosted/ir.zig @@ -697,16 +697,9 @@ pub const Module = struct { }; } - fn analyzeRoot(self: *Module, root_scope: *Scope.ZIRModule) !void { - // TODO use the cache to identify, from the modified source files, the decls which have - // changed based on the span of memory that represents the decl in the re-parsed source file. - // Use the cached dependency graph to recursively determine the set of decls which need - // regeneration. - // Here we simulate adding a source file which was previously not part of the compilation, - // which means scanning the decls looking for exports. - // TODO also identify decls that need to be deleted. - const src_module = switch (root_scope.status) { - .unloaded => blk: { + fn getTextModule(self: *Module, root_scope: *Scope.ZIRModule) !*text.Module { + switch (root_scope.status) { + .unloaded => { try self.failed_files.ensureCapacity(self.failed_files.size + 1); var keep_source = false; @@ -743,12 +736,23 @@ pub const Module = struct { root_scope.contents = .{ .module = zir_module }; keep_zir_module = true; - break :blk zir_module; + return zir_module; }, .unloaded_parse_failure, .loaded_parse_failure => return error.AnalysisFail, - .loaded_success => root_scope.contents.module, - }; + .loaded_success => return root_scope.contents.module, + } + } + + fn analyzeRoot(self: *Module, root_scope: *Scope.ZIRModule) !void { + // TODO use the cache to identify, from the modified source files, the decls which have + // changed based on the span of memory that represents the decl in the re-parsed source file. + // Use the cached dependency graph to recursively determine the set of decls which need + // regeneration. + // Here we simulate adding a source file which was previously not part of the compilation, + // which means scanning the decls looking for exports. + // TODO also identify decls that need to be deleted. + const src_module = try self.getTextModule(root_scope); // Here we ensure enough queue capacity to store all the decls, so that later we can use // appendAssumeCapacity.