-
Notifications
You must be signed in to change notification settings - Fork 100
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refine tail call conditions for tail
and musttail
markers
#1094
Refine tail call conditions for tail
and musttail
markers
#1094
Conversation
fead176
to
05d48bc
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why delete this test? it's correct
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moved it to musttail-memcpy.srctgt.ll
and replace tail w/ musttail (since with tail only marker it shouldn't be UB, we're verifying only isMustTailCall now).
%call2 = alloca i64 | ||
%call3 = alloca i64 | ||
store i64 %arg, ptr %call2, align 8 | ||
musttail call tailcc void @llvm.memcpy.p0.p0.i64(ptr byval(ptr) %call3, ptr byval(ptr) %call2, i64 8, i1 false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this not a good test because it's mixing several conditions at once
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Separated it in multiple functions.
I think we miss checking the following:
(Not completely sure if this refers to musttail too though) |
From a quick read, this doesn't seem to be what we want at all. We need both tail & musttail, as both have constraints. |
78c3527
to
69bb131
Compare
Added a new type |
musttail
tail
and musttail
markers
@@ -0,0 +1,11 @@ | |||
define tailcc i64 @src(i64 noundef %arg) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this test doesn't seem very useful; doesn't check for anything.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Dropped it.
store i64 %arg, ptr %call2, align 8 | ||
tail call void @llvm.memcpy.p0.p0.i64(ptr %call3, ptr %call2, i64 8, i1 false) | ||
ret i64 poison | ||
ret i64 undef |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use poison instead pls. we want to get rid of undef
llvm_util/utils.cpp
Outdated
@@ -521,4 +525,67 @@ llvm::Function *findFunction(llvm::Module &M, const string &FName) { | |||
return F && !F->isDeclaration() ? F : nullptr; | |||
} | |||
|
|||
TailCallInfo parse_tail_call_info(const llvm::CallInst &i) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we don't encode semantics like this. The semantics must be in the ir folder.
We support other IRs -> Alive2 IR, hence we do as little as possible in the translation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I left parse_tail_call_info
in utils.cpp so that it may be used from known_functions too (originally was in llvm2alive). I think we still need it there as we're parsing data from LLVM (like parse_fn_attrs
). Do you mean that the semantics in are_tailcall_preconditions_met
is to be moved in ir inside check_tailcall
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also made it more coherent (parse_tail_call_info
-> parse_fn_tailcall
).
llvm_util/known_fns.cpp
Outdated
switch (libfn) { | ||
case llvm::LibFunc_memset: // void* memset(void *ptr, int val, size_t bytes) | ||
BB.addInstr(make_unique<Memset>(*args[0], *args[1], *args[2], 1, is_tailcall)); | ||
BB.addInstr(make_unique<Memset>(*args[0], *args[1], *args[2], 1, | ||
std::move(tci))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move is a bit overkill
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be changed after the change above.
5847a38
to
0c8b3cf
Compare
Updated, moved semantics in checkTailCall. |
0c8b3cf
to
34d311f
Compare
musttail has stronger requirements than tail, so ensure this is taken into account.