Skip to content

Fix mono native warnings from wasm targets #64650

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

Merged
merged 4 commits into from
Feb 9, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/mono/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -732,7 +732,7 @@ else()
set(EGLIB_SEARCHSEP ":")
set(EGLIB_OS "UNIX")
set(EGLIB_PIDTYPE "int")
set(EGLIB_GSIZE_FORMAT "\"lu\"")
set(EGLIB_GSIZE_FORMAT "\"zu\"")
endif()

set(EGLIB_GSIZE "size_t")
Expand Down
7 changes: 5 additions & 2 deletions src/mono/mono/metadata/seq-points-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -409,9 +409,12 @@ mono_seq_point_data_read (SeqPointData *data, char *path)
fseek(f, 0, SEEK_SET);

buffer_orig = buffer = (guint8 *)g_malloc (fsize + 1);
size_t items = fread(buffer_orig, fsize, 1, f);
if (items != 1)
size_t len = fread(buffer_orig, fsize, 1, f);
if (ferror(f)) {
fclose(f);
return FALSE;
}
g_assert (len == fsize || (len < fsize && feof(f)));

fclose(f);

Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/metadata/sre.c
Original file line number Diff line number Diff line change
Expand Up @@ -2406,7 +2406,7 @@ mono_reflection_get_custom_attrs_blob_checked (MonoReflectionAssembly *assembly,
MonoObject *prop;

for (i = 0; i < mono_array_length_internal (properties); ++i) {
MonoType *ptype;
MonoType *ptype = NULL;
char *pname;

prop = (MonoObject *)mono_array_get_internal (properties, gpointer, i);
Expand All @@ -2430,7 +2430,7 @@ mono_reflection_get_custom_attrs_blob_checked (MonoReflectionAssembly *assembly,
MonoObject *field;

for (i = 0; i < mono_array_length_internal (fields); ++i) {
MonoType *ftype;
MonoType *ftype = NULL;
char *fname;

field = (MonoObject *)mono_array_get_internal (fields, gpointer, i);
Expand Down
2 changes: 2 additions & 0 deletions src/mono/mono/mini/aot-compiler.c
Original file line number Diff line number Diff line change
Expand Up @@ -8349,6 +8349,8 @@ parse_cpu_features (const gchar *attr)
#elif defined(TARGET_WASM)
if (!strcmp (attr + prefix, "simd"))
feature = MONO_CPU_WASM_SIMD;
#else
(void)prefix; // unused
#endif

if (enabled)
Expand Down
10 changes: 6 additions & 4 deletions src/mono/mono/mini/cfgdump.c
Original file line number Diff line number Diff line change
Expand Up @@ -70,21 +70,23 @@ create_socket (const char *hostname, const int port)
static void
write_byte (MonoCompile *cfg, unsigned char b)
{
write (cfg->gdump_ctx->fd, &b, 1);
int ret;
while ((ret = write (cfg->gdump_ctx->fd, &b, 1)) < 0 && errno == EINTR);
}

static void
write_short (MonoCompile *cfg, short s)
{
short swap = htons (s);
write (cfg->gdump_ctx->fd, &swap, 2);
int ret;
while ((ret = write (cfg->gdump_ctx->fd, &swap, 2)) < 0 && errno == EINTR);
}

static void
write_int (MonoCompile *cfg, int v)
{
int swap = htonl (v);
write (cfg->gdump_ctx->fd, &swap, 4);
int swap = htonl (v), ret;
while ((ret = write (cfg->gdump_ctx->fd, &swap, 4)) < 0 && errno == EINTR);
}

static void
Expand Down
18 changes: 3 additions & 15 deletions src/mono/mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -1461,12 +1461,10 @@ sig_to_llvm_sig_no_cinfo (EmitContext *ctx, MonoMethodSignature *sig)
LLVMTypeRef *param_types = NULL;
LLVMTypeRef res;
int i, pindex;
MonoType *rtype;

ret_type = type_to_llvm_type (ctx, sig->ret);
if (!ctx_ok (ctx))
return NULL;
rtype = mini_get_underlying_type (sig->ret);

param_types = g_new0 (LLVMTypeRef, (sig->param_count * 8) + 3);
pindex = 0;
Expand Down Expand Up @@ -2003,10 +2001,6 @@ get_aotconst (EmitContext *ctx, MonoJumpInfoType type, gconstpointer data, LLVMT

cfg = ctx->cfg;

MonoJumpInfo tmp_ji;
tmp_ji.type = type;
tmp_ji.data.target = data;

load = get_aotconst_module (ctx->module, ctx->builder, type, data, llvm_type, &got_offset, &ji);

ji->next = cfg->patch_info;
Expand Down Expand Up @@ -3806,13 +3800,11 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
*/
for (i = 0; i < cfg->num_varinfo; ++i) {
MonoInst *var = cfg->varinfo [i];
LLVMTypeRef vtype;

if ((var->opcode == OP_GSHAREDVT_LOCAL || var->opcode == OP_GSHAREDVT_ARG_REGOFFSET))
continue;

if (var->flags & (MONO_INST_VOLATILE|MONO_INST_INDIRECT) || (mini_type_is_vtype (var->inst_vtype) && !MONO_CLASS_IS_SIMD (ctx->cfg, var->klass))) {
vtype = type_to_llvm_type (ctx, var->inst_vtype);
if (!ctx_ok (ctx))
return;
/* Could be already created by an OP_VPHI */
Expand Down Expand Up @@ -4017,6 +4009,7 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
rgctx_alloc = ctx->addresses [cfg->rgctx_var->dreg];
/* This volatile store will keep the alloca alive */
store = mono_llvm_build_store (builder, convert (ctx, ctx->rgctx_arg, IntPtrType ()), rgctx_alloc, TRUE, LLVM_BARRIER_NONE);
(void)store; /* unused */

set_metadata_flag (rgctx_alloc, "mono.this");
}
Expand Down Expand Up @@ -4868,15 +4861,13 @@ static const char *default_personality_name = "__gxx_personality_v0";
static LLVMTypeRef
default_cpp_lpad_exc_signature (void)
{
static gboolean inited = FALSE;
static LLVMTypeRef sig;

if (!sig) {
LLVMTypeRef signature [2];
signature [0] = LLVMPointerType (LLVMInt8Type (), 0);
signature [1] = LLVMInt32Type ();
sig = LLVMStructType (signature, 2, FALSE);
inited = TRUE;
}

return sig;
Expand Down Expand Up @@ -5496,7 +5487,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
BBInfo *bblocks = ctx->bblocks;
MonoInst *ins;
LLVMBasicBlockRef cbb;
LLVMBuilderRef builder, starting_builder;
LLVMBuilderRef builder;
gboolean has_terminator;
LLVMValueRef v;
LLVMValueRef lhs, rhs, arg3;
Expand Down Expand Up @@ -5611,7 +5602,6 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
}

has_terminator = FALSE;
starting_builder = builder;
for (ins = bb->code; ins; ins = ins->next) {
const char *spec = LLVM_INS_INFO (ins->opcode);
char *dname = NULL;
Expand Down Expand Up @@ -12220,11 +12210,9 @@ mono_llvm_emit_call (MonoCompile *cfg, MonoCallInst *call)
{
MonoInst *in;
MonoMethodSignature *sig;
int i, n, stack_size;
int i, n;
LLVMArgInfo *ainfo;

stack_size = 0;

sig = call->signature;
n = sig->param_count + sig->hasthis;

Expand Down
4 changes: 2 additions & 2 deletions src/mono/mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -1909,15 +1909,15 @@ realloc_code (MonoCompile *cfg, int size)
const int EXTRA_CODE_SPACE = 16;
const int code_len = cfg->code_len;

if (G_UNLIKELY (code_len + size > (cfg->code_size - EXTRA_CODE_SPACE)))
if (G_UNLIKELY ((guint)(code_len + size) > (cfg->code_size - EXTRA_CODE_SPACE)))
return mini_realloc_code_slow (cfg, size);
return cfg->native_code + code_len;
}

static inline void
set_code_len (MonoCompile *cfg, int len)
{
g_assert (len <= cfg->code_size);
g_assert ((guint)len <= cfg->code_size);
cfg->code_len = len;
}

Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/mini/type-checking.c
Original file line number Diff line number Diff line change
Expand Up @@ -557,7 +557,7 @@ handle_isinst (MonoCompile *cfg, MonoClass *klass, MonoInst *src, int context_us

MONO_START_BB (cfg, pointer_check_bb);
// Check if the parent class of the element is non-null, else manually check the type
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, parent_reg, NULL);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, parent_reg, 0);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBNE_UN, is_null_bb);
MONO_EMIT_NEW_BIALU_IMM (cfg, OP_COMPARE_IMM, -1, class_kind_reg, MONO_CLASS_POINTER);
MONO_EMIT_NEW_BRANCH_BLOCK (cfg, OP_PBEQ, false_bb);
Expand Down
7 changes: 6 additions & 1 deletion src/mono/mono/sgen/sgen-protocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,12 @@ binary_protocol_open_file (gboolean assert_on_failure)
#endif
} else {
/* We have acquired the lock. Truncate the file */
ftruncate (binary_protocol_file, 0);
int ret;
while ((ret = ftruncate (binary_protocol_file, 0)) < 0 && errno == EINTR);
if (ret < 0) {
binary_protocol_file = -1;
break;
}
}
} while (binary_protocol_file == -1);
#else
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/tools/offsets-tool/offsets-tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ def run_clang(self):
clang_args += self.target_args
clang_args += ['-std=gnu99', '-DMONO_GENERATING_OFFSETS']
for include in self.sys_includes:
clang_args.append ("-I")
clang_args.append ("-isystem")
clang_args.append (include)
for include in mono_includes:
clang_args.append ("-I")
Expand Down
2 changes: 1 addition & 1 deletion src/mono/mono/utils/mono-dl.c
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ mono_dl_open_full (const char *name, int mono_flags, int native_flags, char **er
void *lib;
MonoDlFallbackHandler *dl_fallback = NULL;
int lflags = mono_dl_convert_flags (mono_flags, native_flags);
char *found_name;
char *found_name = NULL;

if (error_msg)
*error_msg = NULL;
Expand Down