forked from M-Labs/artiq
Take alignment into account during attribute writeback (fixes #293).
This commit is contained in:
parent
914bc9f360
commit
a1dd909bc4
@ -443,7 +443,7 @@ class LLVMIRGenerator:
|
|||||||
lldatalayout = llvm.create_target_data(self.llmodule.data_layout)
|
lldatalayout = llvm.create_target_data(self.llmodule.data_layout)
|
||||||
|
|
||||||
llrpcattrty = self.llcontext.get_identified_type("attr_desc")
|
llrpcattrty = self.llcontext.get_identified_type("attr_desc")
|
||||||
llrpcattrty.elements = [lli32, llptr, llptr]
|
llrpcattrty.elements = [lli32, lli32, llptr, llptr]
|
||||||
|
|
||||||
lldescty = self.llcontext.get_identified_type("type_desc")
|
lldescty = self.llcontext.get_identified_type("type_desc")
|
||||||
lldescty.elements = [llrpcattrty.as_pointer().as_pointer(), llptr.as_pointer()]
|
lldescty.elements = [llrpcattrty.as_pointer().as_pointer(), llptr.as_pointer()]
|
||||||
@ -459,7 +459,10 @@ class LLVMIRGenerator:
|
|||||||
type_name = "instance.{}".format(typ.name)
|
type_name = "instance.{}".format(typ.name)
|
||||||
|
|
||||||
def llrpcattr_of_attr(name, typ):
|
def llrpcattr_of_attr(name, typ):
|
||||||
size = self.llty_of_type(typ).get_abi_size(lldatalayout, context=self.llcontext)
|
size = self.llty_of_type(typ). \
|
||||||
|
get_abi_size(lldatalayout, context=self.llcontext)
|
||||||
|
alignment = self.llty_of_type(typ). \
|
||||||
|
get_abi_alignment(lldatalayout, context=self.llcontext)
|
||||||
|
|
||||||
def rpc_tag_error(typ):
|
def rpc_tag_error(typ):
|
||||||
print(typ)
|
print(typ)
|
||||||
@ -476,6 +479,7 @@ class LLVMIRGenerator:
|
|||||||
name="attr.{}.{}".format(type_name, name))
|
name="attr.{}.{}".format(type_name, name))
|
||||||
llrpcattr.initializer = ll.Constant(llrpcattrty, [
|
llrpcattr.initializer = ll.Constant(llrpcattrty, [
|
||||||
ll.Constant(lli32, size),
|
ll.Constant(lli32, size),
|
||||||
|
ll.Constant(lli32, alignment),
|
||||||
llrpctag,
|
llrpctag,
|
||||||
self.llstr_of_str(name)
|
self.llstr_of_str(name)
|
||||||
])
|
])
|
||||||
|
@ -407,6 +407,7 @@ int recv_rpc(void *slot) {
|
|||||||
|
|
||||||
struct attr_desc {
|
struct attr_desc {
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
|
uint32_t alignment;
|
||||||
const char *tag;
|
const char *tag;
|
||||||
const char *name;
|
const char *name;
|
||||||
};
|
};
|
||||||
@ -434,6 +435,9 @@ void attribute_writeback(void *utypes) {
|
|||||||
while(*attrs) {
|
while(*attrs) {
|
||||||
struct attr_desc *attr = *attrs++;
|
struct attr_desc *attr = *attrs++;
|
||||||
|
|
||||||
|
if(offset % attr->alignment != 0)
|
||||||
|
offset += attr->alignment - (offset % attr->alignment);
|
||||||
|
|
||||||
if(attr->tag) {
|
if(attr->tag) {
|
||||||
uintptr_t value = (uintptr_t)object + offset;
|
uintptr_t value = (uintptr_t)object + offset;
|
||||||
send_rpc(0, attr->tag, &object, &attr->name, value);
|
send_rpc(0, attr->tag, &object, &attr->name, value);
|
||||||
|
Loading…
Reference in New Issue
Block a user