Skip to content

Commit c334fb8

Browse files
committed
do not assume tco unless musttail attribute is available
although i'm not entirely happy with this, i can't think of a better way right now. note: the xtensa version of llvm has broken musttail. espressif/llvm-project#73
1 parent 6983447 commit c334fb8

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

lib/insn.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ read_memarg_nocheck(const uint8_t **pp, struct memarg *arg)
541541
#define SAVE_STACK_PTR ctx->stack.lsize = stack - ctx->stack.p
542542
#define LOAD_STACK_PTR stack = &VEC_NEXTELEM(ctx->stack)
543543
#define ORIG_PC p0
544-
#if defined(TOYWASM_USE_TAILCALL)
544+
#if defined(TOYWASM_USE_TAILCALL) && defined(__HAVE_TAILCALL)
545545
#define INSN_SUCCESS __musttail return fetch_exec_next_insn(p, stack, ctx)
546546
#else
547547
#define INSN_SUCCESS INSN_SUCCESS_RETURN

lib/platform.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44

55
#if defined(__clang__) && defined(__has_attribute) && __has_attribute(musttail)
66
#define __musttail __attribute__((musttail))
7+
#define __HAVE_TAILCALL
78
#else
89
#define __musttail
10+
#undef __HAVE_TAILCALL
911
#endif
1012

1113
#if !defined(__predict_true)

0 commit comments

Comments
 (0)