diff --git a/artiq/compiler/module.py b/artiq/compiler/module.py index 6d1976615..afeb21a69 100644 --- a/artiq/compiler/module.py +++ b/artiq/compiler/module.py @@ -72,9 +72,9 @@ class Module: self.artiq_ir = artiq_ir_generator.visit(src.typedtree) artiq_ir_generator.annotate_calls(devirtualization) cfg_simplifier.process(self.artiq_ir) - local_access_validator.process(self.artiq_ir) dead_code_eliminator.process(self.artiq_ir) interleaver.process(self.artiq_ir) + local_access_validator.process(self.artiq_ir) def build_llvm_ir(self, target): """Compile the module to LLVM IR for the specified target.""" diff --git a/artiq/compiler/transforms/dead_code_eliminator.py b/artiq/compiler/transforms/dead_code_eliminator.py index 0868032ba..23eaf57bb 100644 --- a/artiq/compiler/transforms/dead_code_eliminator.py +++ b/artiq/compiler/transforms/dead_code_eliminator.py @@ -27,7 +27,12 @@ class DeadCodeEliminator: while modified: modified = False for insn in func.instructions(): - if isinstance(insn, (ir.Phi, ir.Alloc, ir.GetLocal, ir.GetConstructor, + # Note that GetLocal is treated as an impure operation: + # the local access validator has to observe it to emit + # a diagnostic for reads of uninitialized locals, and + # it also has to run after the interleaver, but interleaver + # doesn't like to work with IR before DCE. + if isinstance(insn, (ir.Phi, ir.Alloc, ir.GetConstructor, ir.GetAttr, ir.GetElem, ir.Coerce, ir.Arith, ir.Compare, ir.Closure, ir.Select, ir.Quote)) \ and not any(insn.uses):