mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Remove unnecessary "ret" in naked functions #2344.
This commit is contained in:
@@ -81,6 +81,7 @@
|
||||
- Fix issue where recursively creating a dir would be incorrectly marked as a failure the first time.
|
||||
- `@format` did not work correctly with macros #2341.
|
||||
- Crash when parsing recursive type declaration #2345.
|
||||
- Remove unnecessary "ret" in naked functions #2344.
|
||||
|
||||
### Stdlib changes
|
||||
- Improve contract for readline. #2280
|
||||
|
||||
@@ -516,7 +516,14 @@ void llvm_emit_body(GenContext *c, LLVMValueRef function, FunctionPrototype *pro
|
||||
// Insert a return (and defer) if needed.
|
||||
if (c->current_block && !LLVMGetBasicBlockTerminator(c->current_block))
|
||||
{
|
||||
llvm_emit_return_implicit(c);
|
||||
if (signature)
|
||||
{
|
||||
llvm_emit_return_implicit(c);
|
||||
}
|
||||
else
|
||||
{
|
||||
llvm_emit_unreachable(c);
|
||||
}
|
||||
}
|
||||
|
||||
LLVMBasicBlockRef last_block = LLVMGetLastBasicBlock(c->cur_func.ref);
|
||||
|
||||
@@ -3353,7 +3353,7 @@ bool sema_analyse_function_body(SemaContext *context, Decl *func)
|
||||
bool is_naked = func->func_decl.attr_naked;
|
||||
if (!is_naked) sema_append_contract_asserts(assert_first, body);
|
||||
Type *canonical_rtype = type_no_optional(prototype->rtype)->canonical;
|
||||
if (has_ensures && type_is_void(canonical_rtype))
|
||||
if (!is_naked && has_ensures && type_is_void(canonical_rtype))
|
||||
{
|
||||
AstId* append_pos = &body->compound_stmt.first_stmt;
|
||||
if (*append_pos)
|
||||
|
||||
@@ -14,6 +14,6 @@ fn void start() @export("_start") @naked @nostrip {
|
||||
define void @_start() #0 {
|
||||
entry:
|
||||
call void asm sideeffect alignstack "movq $$60, %rax\0Amovq $$42, %rdi\0Asyscall \0A", "~{cc},~{rax},~{rcx},~{r8},~{r11},~{flags},~{dirflag},~{fspr}"()
|
||||
ret void
|
||||
unreachable
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,6 @@ fn void start() @export("_start") @naked @nostrip {
|
||||
define void @_start() #0 {
|
||||
entry:
|
||||
call void asm sideeffect alignstack "syscall \0A", "~{cc},~{rax},~{rcx},~{r11},~{flags},~{dirflag},~{fspr}"()
|
||||
ret void
|
||||
unreachable
|
||||
}
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ fn void test(int i) @naked
|
||||
|
||||
define void @naked_function.test(i32 %0) #0 {
|
||||
entry:
|
||||
ret void
|
||||
unreachable
|
||||
}
|
||||
|
||||
attributes #0 = { naked nounwind uwtable "no-trapping-math"="true" "stack-protector-buffer-size"="8" }
|
||||
|
||||
Reference in New Issue
Block a user