From 5f5975844a6af08639250d689d3f78bf213b8508 Mon Sep 17 00:00:00 2001 From: whitequark Date: Sat, 13 Aug 2016 04:43:19 +0000 Subject: [PATCH] Revert "Update for LLVM 3.9." This reverts commit 3aa7b99b8f372e08427275ed1f93e771b1b46bdb. --- artiq/compiler/targets.py | 5 ++- .../compiler/transforms/llvm_ir_generator.py | 38 ++++++++++--------- conda/artiq/meta.yaml | 2 +- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/artiq/compiler/targets.py b/artiq/compiler/targets.py index de3972fc9..a82449fd1 100644 --- a/artiq/compiler/targets.py +++ b/artiq/compiler/targets.py @@ -86,11 +86,14 @@ class Target: llmachine = lltarget.create_target_machine( features=",".join(["+{}".format(f) for f in self.features]), reloc="pic", codemodel="default") - llmachine.set_asm_verbosity(True) + llmachine.set_verbose(True) return llmachine def optimize(self, llmodule): + llmachine = self.target_machine() llpassmgr = llvm.create_module_pass_manager() + llmachine.target_data.add_pass(llpassmgr) + llmachine.add_analysis_passes(llpassmgr) # Register our alias analysis passes. llpassmgr.add_basic_alias_analysis_pass() diff --git a/artiq/compiler/transforms/llvm_ir_generator.py b/artiq/compiler/transforms/llvm_ir_generator.py index a5459a60b..826db2b4d 100644 --- a/artiq/compiler/transforms/llvm_ir_generator.py +++ b/artiq/compiler/transforms/llvm_ir_generator.py @@ -36,16 +36,9 @@ def memoize(generator): class DebugInfoEmitter: def __init__(self, llmodule): self.llmodule = llmodule - self.llcompileunit = None + self.llsubprograms = [] self.cache = {} - llident = self.llmodule.add_named_metadata('llvm.ident') - llident.add(self.emit_metadata(["ARTIQ"])) - - llflags = self.llmodule.add_named_metadata('llvm.module.flags') - llflags.add(self.emit_metadata([2, "Debug Info Version", 3])) - llflags.add(self.emit_metadata([2, "Dwarf Version", 4])) - def emit_metadata(self, operands): def map_operand(operand): if operand is None: @@ -73,13 +66,14 @@ class DebugInfoEmitter: }) @memoize - def emit_compile_unit(self, source_buffer): + def emit_compile_unit(self, source_buffer, llsubprograms): return self.emit_debug_info("DICompileUnit", { "language": ll.DIToken("DW_LANG_Python"), "file": self.emit_file(source_buffer), "producer": "ARTIQ", "runtimeVersion": 0, "emissionKind": 2, # full=1, lines only=2 + "subprograms": self.emit_metadata(llsubprograms) }, is_distinct=True) @memoize @@ -91,26 +85,21 @@ class DebugInfoEmitter: @memoize def emit_subprogram(self, func, llfunc): source_buffer = func.loc.source_buffer - - if self.llcompileunit is None: - self.llcompileunit = self.emit_compile_unit(source_buffer) - llcompileunits = self.llmodule.add_named_metadata('llvm.dbg.cu') - llcompileunits.add(self.llcompileunit) - display_name = "{}{}".format(func.name, types.TypePrinter().name(func.type)) - return self.emit_debug_info("DISubprogram", { + llsubprogram = self.emit_debug_info("DISubprogram", { "name": func.name, "linkageName": llfunc.name, "type": self.emit_subroutine_type(func.type), "file": self.emit_file(source_buffer), "line": func.loc.line(), - "unit": self.llcompileunit, "scope": self.emit_file(source_buffer), "scopeLine": func.loc.line(), "isLocal": func.is_internal, "isDefinition": True, "variables": self.emit_metadata([]) }, is_distinct=True) + self.llsubprograms.append(llsubprogram) + return llsubprogram @memoize def emit_loc(self, loc, scope): @@ -120,6 +109,18 @@ class DebugInfoEmitter: "scope": scope }) + def finalize(self, source_buffer): + llident = self.llmodule.add_named_metadata('llvm.ident') + llident.add(self.emit_metadata(["ARTIQ"])) + + llflags = self.llmodule.add_named_metadata('llvm.module.flags') + llflags.add(self.emit_metadata([2, "Debug Info Version", 3])) + llflags.add(self.emit_metadata([2, "Dwarf Version", 4])) + + llcompile_units = self.llmodule.add_named_metadata('llvm.dbg.cu') + llcompile_units.add(self.emit_compile_unit(source_buffer, tuple(self.llsubprograms))) + + class LLVMIRGenerator: def __init__(self, engine, module_name, target, embedding_map): self.engine = engine @@ -406,6 +407,9 @@ class LLVMIRGenerator: for func in functions: self.process_function(func) + if any(functions): + self.debug_info_emitter.finalize(functions[0].loc.source_buffer) + if attribute_writeback and self.embedding_map is not None: self.emit_attribute_writeback() diff --git a/conda/artiq/meta.yaml b/conda/artiq/meta.yaml index def6f3503..f94e1554e 100644 --- a/conda/artiq/meta.yaml +++ b/conda/artiq/meta.yaml @@ -18,7 +18,7 @@ requirements: - binutils-or1k-linux run: - python >=3.5.2 - - llvmlite-artiq 0.11.0.dev py35_25 + - llvmlite-artiq 0.10.0.dev py35_24 - lit - outputcheck - scipy