forked from M-Labs/artiq
compiler: Fix "nowrite" miscompilation for sret functions
This affected e.g. rtio_input_timestamped_data().
This commit is contained in:
parent
35f30ddf05
commit
8a7af3f75c
|
@ -1409,7 +1409,10 @@ class LLVMIRGenerator:
|
|||
llfun.args[idx].add_attribute(attr)
|
||||
if 'nounwind' in insn.target_function().type.flags:
|
||||
llfun.attributes.add('nounwind')
|
||||
if 'nowrite' in insn.target_function().type.flags:
|
||||
if 'nowrite' in insn.target_function().type.flags and not is_sret:
|
||||
# Even if "nowrite" is correct from the user's perspective (doesn't
|
||||
# access any other memory observable to ARTIQ Python), this isn't
|
||||
# true on the LLVM IR level for sret return values.
|
||||
llfun.attributes.add('inaccessiblememonly')
|
||||
|
||||
return llfun, list(llargs), llarg_attrs, llcallstackptr
|
||||
|
|
|
@ -13,6 +13,14 @@ from artiq.language.types import *
|
|||
def foo() -> TNone:
|
||||
pass
|
||||
|
||||
# sret nowrite functions shouldn't be marked inaccessiblememonly.
|
||||
# CHECK-L: ; Function Attrs: nounwind
|
||||
# CHECK-NEXT-L: declare void @bar({ i32, i64 }* sret)
|
||||
@syscall(flags={"nounwind", "nowrite"})
|
||||
def bar() -> TTuple([TInt32, TInt64]):
|
||||
pass
|
||||
|
||||
@kernel
|
||||
def entrypoint():
|
||||
foo()
|
||||
bar()
|
||||
|
|
Loading…
Reference in New Issue