Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 895b25b

Browse files
author
whitequark
committedAug 13, 2016
Update for LLVM 3.9.
1 parent 5b8b6a9 commit 895b25b

File tree

3 files changed

+20
-26
lines changed

3 files changed

+20
-26
lines changed
 

Diff for: ‎artiq/compiler/targets.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,12 @@ def target_machine(self):
8686
llmachine = lltarget.create_target_machine(
8787
features=",".join(["+{}".format(f) for f in self.features]),
8888
reloc="pic", codemodel="default")
89-
llmachine.set_verbose(True)
89+
llmachine.set_asm_verbosity(True)
9090
return llmachine
9191

9292
def optimize(self, llmodule):
93-
llmachine = self.target_machine()
9493
llpassmgr = llvm.create_module_pass_manager()
95-
llmachine.target_data.add_pass(llpassmgr)
96-
llmachine.add_analysis_passes(llpassmgr)
94+
self.target_machine().add_analysis_passes(llpassmgr)
9795

9896
# Register our alias analysis passes.
9997
llpassmgr.add_basic_alias_analysis_pass()

Diff for: ‎artiq/compiler/transforms/llvm_ir_generator.py

+17-21
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,16 @@ def memoized(self, *args):
3636
class DebugInfoEmitter:
3737
def __init__(self, llmodule):
3838
self.llmodule = llmodule
39-
self.llsubprograms = []
39+
self.llcompileunit = None
4040
self.cache = {}
4141

42+
llident = self.llmodule.add_named_metadata('llvm.ident')
43+
llident.add(self.emit_metadata(["ARTIQ"]))
44+
45+
llflags = self.llmodule.add_named_metadata('llvm.module.flags')
46+
llflags.add(self.emit_metadata([2, "Debug Info Version", 3]))
47+
llflags.add(self.emit_metadata([2, "Dwarf Version", 4]))
48+
4249
def emit_metadata(self, operands):
4350
def map_operand(operand):
4451
if operand is None:
@@ -66,14 +73,13 @@ def emit_file(self, source_buffer):
6673
})
6774

6875
@memoize
69-
def emit_compile_unit(self, source_buffer, llsubprograms):
76+
def emit_compile_unit(self, source_buffer):
7077
return self.emit_debug_info("DICompileUnit", {
7178
"language": ll.DIToken("DW_LANG_Python"),
7279
"file": self.emit_file(source_buffer),
7380
"producer": "ARTIQ",
7481
"runtimeVersion": 0,
7582
"emissionKind": 2, # full=1, lines only=2
76-
"subprograms": self.emit_metadata(llsubprograms)
7783
}, is_distinct=True)
7884

7985
@memoize
@@ -85,21 +91,26 @@ def emit_subroutine_type(self, typ):
8591
@memoize
8692
def emit_subprogram(self, func, llfunc):
8793
source_buffer = func.loc.source_buffer
94+
95+
if self.llcompileunit is None:
96+
self.llcompileunit = self.emit_compile_unit(source_buffer)
97+
llcompileunits = self.llmodule.add_named_metadata('llvm.dbg.cu')
98+
llcompileunits.add(self.llcompileunit)
99+
88100
display_name = "{}{}".format(func.name, types.TypePrinter().name(func.type))
89-
llsubprogram = self.emit_debug_info("DISubprogram", {
101+
return self.emit_debug_info("DISubprogram", {
90102
"name": func.name,
91103
"linkageName": llfunc.name,
92104
"type": self.emit_subroutine_type(func.type),
93105
"file": self.emit_file(source_buffer),
94106
"line": func.loc.line(),
107+
"unit": self.llcompileunit,
95108
"scope": self.emit_file(source_buffer),
96109
"scopeLine": func.loc.line(),
97110
"isLocal": func.is_internal,
98111
"isDefinition": True,
99112
"variables": self.emit_metadata([])
100113
}, is_distinct=True)
101-
self.llsubprograms.append(llsubprogram)
102-
return llsubprogram
103114

104115
@memoize
105116
def emit_loc(self, loc, scope):
@@ -109,18 +120,6 @@ def emit_loc(self, loc, scope):
109120
"scope": scope
110121
})
111122

112-
def finalize(self, source_buffer):
113-
llident = self.llmodule.add_named_metadata('llvm.ident')
114-
llident.add(self.emit_metadata(["ARTIQ"]))
115-
116-
llflags = self.llmodule.add_named_metadata('llvm.module.flags')
117-
llflags.add(self.emit_metadata([2, "Debug Info Version", 3]))
118-
llflags.add(self.emit_metadata([2, "Dwarf Version", 4]))
119-
120-
llcompile_units = self.llmodule.add_named_metadata('llvm.dbg.cu')
121-
llcompile_units.add(self.emit_compile_unit(source_buffer, tuple(self.llsubprograms)))
122-
123-
124123
class LLVMIRGenerator:
125124
def __init__(self, engine, module_name, target, embedding_map):
126125
self.engine = engine
@@ -407,9 +406,6 @@ def process(self, functions, attribute_writeback):
407406
for func in functions:
408407
self.process_function(func)
409408

410-
if any(functions):
411-
self.debug_info_emitter.finalize(functions[0].loc.source_buffer)
412-
413409
if attribute_writeback and self.embedding_map is not None:
414410
self.emit_attribute_writeback()
415411

Diff for: ‎conda/artiq/meta.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ requirements:
1818
- binutils-or1k-linux
1919
run:
2020
- python >=3.5.2
21-
- llvmlite-artiq 0.10.0.dev py35_24
21+
- llvmlite-artiq 0.11.0.dev py35_25
2222
- lit
2323
- outputcheck
2424
- scipy

0 commit comments

Comments
 (0)
Please sign in to comment.