From a57aabb3ea70c913aa7121c688f202010c94dffe Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 2 Apr 2016 18:29:36 +0000 Subject: [PATCH] compiler: purge generated functions from backtraces. --- artiq/compiler/ir.py | 3 +++ artiq/compiler/transforms/artiq_ir_generator.py | 1 + artiq/compiler/transforms/llvm_ir_generator.py | 9 +++++---- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/artiq/compiler/ir.py b/artiq/compiler/ir.py index 7dab3e3c3..8414c45c9 100644 --- a/artiq/compiler/ir.py +++ b/artiq/compiler/ir.py @@ -425,6 +425,8 @@ class Function: the module it is contained in :ivar is_cold: (bool) if True, the function should be considered rarely called + :ivar is_generated: + (bool) if True, the function will not appear in backtraces :ivar flags: (set of str) Code generation flags. Flag ``fast-math`` is the equivalent of gcc's ``-ffast-math``. """ @@ -436,6 +438,7 @@ class Function: self.set_arguments(arguments) self.is_internal = False self.is_cold = False + self.is_generated = False self.flags = {} def _remove_name(self, name): diff --git a/artiq/compiler/transforms/artiq_ir_generator.py b/artiq/compiler/transforms/artiq_ir_generator.py index 5e5fd81b6..a42cbe213 100644 --- a/artiq/compiler/transforms/artiq_ir_generator.py +++ b/artiq/compiler/transforms/artiq_ir_generator.py @@ -944,6 +944,7 @@ class ARTIQIRGenerator(algorithm.Visitor): func = ir.Function(typ, ".".join(self.name + [name]), args, loc=loc) func.is_internal = True func.is_cold = True + func.is_generated = True self.functions.append(func) old_func, self.current_function = self.current_function, func diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index e338143a0..46e3f9b18 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -544,8 +544,9 @@ class LLVMIRGenerator: self.llbuilder = ll.IRBuilder() llblock_map = {} - disubprogram = self.debug_info_emitter.emit_subprogram(func, self.llfunction) - self.llfunction.set_metadata('dbg', disubprogram) + if not func.is_generated: + lldisubprogram = self.debug_info_emitter.emit_subprogram(func, self.llfunction) + self.llfunction.set_metadata('dbg', lldisubprogram) # First, map arguments. if self.has_sret(func.type): @@ -566,9 +567,9 @@ class LLVMIRGenerator: for block in func.basic_blocks: self.llbuilder.position_at_end(self.llmap[block]) for insn in block.instructions: - if insn.loc is not None: + if insn.loc is not None and not func.is_generated: self.llbuilder.debug_metadata = \ - self.debug_info_emitter.emit_loc(insn.loc, disubprogram) + self.debug_info_emitter.emit_loc(insn.loc, lldisubprogram) llinsn = getattr(self, "process_" + type(insn).__name__)(insn) assert llinsn is not None