forked from M-Labs/artiq
1
0
Fork 0

Merge branch 'master' of github.com:m-labs/artiq

This commit is contained in:
Sebastien Bourdeauducq 2016-03-30 01:45:16 +08:00
commit 010c68f0a1
3 changed files with 21 additions and 15 deletions

View File

@ -46,12 +46,14 @@ class RunTool:
def _dump(target, kind, suffix, content): def _dump(target, kind, suffix, content):
if target is not None: if target is not None:
print("====== {} DUMP ======".format(kind.upper()), file=sys.stderr) print("====== {} DUMP ======".format(kind.upper()), file=sys.stderr)
content_bytes = bytes(content(), 'utf-8') content_value = content()
if isinstance(content_value, str):
content_value = bytes(content_value, 'utf-8')
if target == "": if target == "":
file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False) file = tempfile.NamedTemporaryFile(suffix=suffix, delete=False)
else: else:
file = open(target + suffix, "wb") file = open(target + suffix, "wb")
file.write(content_bytes) file.write(content_value)
file.close() file.close()
print("{} dumped as {}".format(kind, file.name), file=sys.stderr) print("{} dumped as {}".format(kind, file.name), file=sys.stderr)

View File

@ -569,7 +569,6 @@ class LLVMIRGenerator:
if func.is_internal: if func.is_internal:
self.llfunction.linkage = 'private' self.llfunction.linkage = 'private'
if func.is_cold: if func.is_cold:
self.llfunction.calling_convention = 'coldcc'
self.llfunction.attributes.add('cold') self.llfunction.attributes.add('cold')
self.llfunction.attributes.add('noinline') self.llfunction.attributes.add('noinline')
@ -685,13 +684,17 @@ class LLVMIRGenerator:
inbounds=True) inbounds=True)
llouterenv = self.llbuilder.load(llptr) llouterenv = self.llbuilder.load(llptr)
llouterenv.metadata['invariant.load'] = self.empty_metadata llouterenv.metadata['invariant.load'] = self.empty_metadata
llouterenv.metadata['nonnull'] = self.empty_metadata
return self.llptr_to_var(llouterenv, env_ty.params["$outer"], var_name) return self.llptr_to_var(llouterenv, env_ty.params["$outer"], var_name)
def process_GetLocal(self, insn): def process_GetLocal(self, insn):
env = insn.environment() env = insn.environment()
llptr = self.llptr_to_var(self.map(env), env.type, insn.var_name) llptr = self.llptr_to_var(self.map(env), env.type, insn.var_name)
llptr.name = "ptr.{}.{}".format(env.name, insn.var_name) llptr.name = "ptr.{}.{}".format(env.name, insn.var_name)
return self.llbuilder.load(llptr, name="val.{}.{}".format(env.name, insn.var_name)) llvalue = self.llbuilder.load(llptr, name="val.{}.{}".format(env.name, insn.var_name))
if isinstance(llvalue.type, ll.PointerType):
llvalue.metadata['nonnull'] = self.empty_metadata
return llvalue
def process_SetLocal(self, insn): def process_SetLocal(self, insn):
env = insn.environment() env = insn.environment()
@ -810,9 +813,12 @@ class LLVMIRGenerator:
else: else:
llptr = self.llbuilder.gep(obj, [self.llindex(0), self.llindex(index)], llptr = self.llbuilder.gep(obj, [self.llindex(0), self.llindex(index)],
inbounds=True, name="ptr.{}".format(insn.name)) inbounds=True, name="ptr.{}".format(insn.name))
llval = self.llbuilder.load(llptr, name="val.{}".format(insn.name)) llvalue = self.llbuilder.load(llptr, name="val.{}".format(insn.name))
llval.metadata['invariant.load'] = self.empty_metadata if types.is_instance(typ) and attr in typ.constant_attributes:
return llval llvalue.metadata['invariant.load'] = self.empty_metadata
if isinstance(llvalue.type, ll.PointerType):
llvalue.metadata['nonnull'] = self.empty_metadata
return llvalue
def process_SetAttr(self, insn): def process_SetAttr(self, insn):
typ, attr = insn.object().type, insn.attr typ, attr = insn.object().type, insn.attr
@ -840,7 +846,10 @@ class LLVMIRGenerator:
llelts = self.llbuilder.extract_value(self.map(insn.list()), 1) llelts = self.llbuilder.extract_value(self.map(insn.list()), 1)
llelt = self.llbuilder.gep(llelts, [self.map(insn.index())], llelt = self.llbuilder.gep(llelts, [self.map(insn.index())],
inbounds=True) inbounds=True)
return self.llbuilder.load(llelt) llvalue = self.llbuilder.load(llelt)
if isinstance(llvalue.type, ll.PointerType):
llvalue.metadata['nonnull'] = self.empty_metadata
return llvalue
def process_SetElem(self, insn): def process_SetElem(self, insn):
llelts = self.llbuilder.extract_value(self.map(insn.list()), 1) llelts = self.llbuilder.extract_value(self.map(insn.list()), 1)
@ -1051,6 +1060,7 @@ class LLVMIRGenerator:
inbounds=True) inbounds=True)
llouterenv = self.llbuilder.load(llptr) llouterenv = self.llbuilder.load(llptr)
llouterenv.metadata['invariant.load'] = self.empty_metadata llouterenv.metadata['invariant.load'] = self.empty_metadata
llouterenv.metadata['nonnull'] = self.empty_metadata
return self.llptr_to_var(llouterenv, env_ty.params["$outer"], var_name) return self.llptr_to_var(llouterenv, env_ty.params["$outer"], var_name)
else: else:
return llenv return llenv
@ -1311,9 +1321,6 @@ class LLVMIRGenerator:
if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags: if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags:
llcall.metadata['tbaa'] = self.tbaa_nowrite_call llcall.metadata['tbaa'] = self.tbaa_nowrite_call
if insn.is_cold:
llcall.cconv = 'coldcc'
return llresult return llresult
def process_Invoke(self, insn): def process_Invoke(self, insn):
@ -1347,9 +1354,6 @@ class LLVMIRGenerator:
if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags: if types.is_c_function(functiontyp) and 'nowrite' in functiontyp.flags:
llcall.metadata['tbaa'] = self.tbaa_nowrite_call llcall.metadata['tbaa'] = self.tbaa_nowrite_call
if insn.is_cold:
llcall.cconv = 'coldcc'
return llcall return llcall
def _quote(self, value, typ, path): def _quote(self, value, typ, path):

View File

@ -4,7 +4,7 @@
from artiq.language.core import * from artiq.language.core import *
from artiq.language.types import * from artiq.language.types import *
# CHECK: call void @foo\(\), !dbg !\d+, !tbaa !\d+ # CHECK: call void @foo\(\)(, !dbg !\d+)?, !tbaa !\d+
# CHECK-L: ; Function Attrs: nounwind # CHECK-L: ; Function Attrs: nounwind
# CHECK-NEXT-L: declare void @foo() # CHECK-NEXT-L: declare void @foo()