From a02f5c3e7a22494798aee6420a5a459a595619cc Mon Sep 17 00:00:00 2001 From: Ben Vanik Date: Tue, 14 Jan 2014 01:11:42 -0800 Subject: [PATCH] Fixing alloy analysis warnings. --- src/alloy/backend/ivm/ivm_intcode.cc | 4 ++-- src/alloy/frontend/ppc/ppc_emit_altivec.cc | 2 +- src/alloy/frontend/ppc/ppc_emit_alu.cc | 6 +++--- src/alloy/frontend/ppc/ppc_hir_builder.cc | 3 ++- src/alloy/hir/hir_builder.cc | 2 +- src/alloy/mutex_win.cc | 4 ++-- 6 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/alloy/backend/ivm/ivm_intcode.cc b/src/alloy/backend/ivm/ivm_intcode.cc index 910c32477..200b297b6 100644 --- a/src/alloy/backend/ivm/ivm_intcode.cc +++ b/src/alloy/backend/ivm/ivm_intcode.cc @@ -1242,7 +1242,7 @@ static uint8_t __lvsr_table[17][16] = { }; uint32_t IntCode_LOAD_VECTOR_SHL(IntCodeState& ics, const IntCode* i) { - int8_t sh = ics.rf[i->src1_reg].i8 & 0x1F; + int8_t sh = MIN(16, ics.rf[i->src1_reg].i8); vec128_t& dest = ics.rf[i->dest_reg].v128; for (int n = 0; n < 16; n++) { dest.b16[n] = __lvsl_table[sh][n]; @@ -1254,7 +1254,7 @@ int Translate_LOAD_VECTOR_SHL(TranslationContext& ctx, Instr* i) { } uint32_t IntCode_LOAD_VECTOR_SHR(IntCodeState& ics, const IntCode* i) { - int8_t sh = ics.rf[i->src1_reg].i8 & 0x1F; + int8_t sh = MIN(16, ics.rf[i->src1_reg].i8); vec128_t& dest = ics.rf[i->dest_reg].v128; for (int n = 0; n < 16; n++) { dest.b16[n] = __lvsr_table[sh][n]; diff --git a/src/alloy/frontend/ppc/ppc_emit_altivec.cc b/src/alloy/frontend/ppc/ppc_emit_altivec.cc index d31b5f9cf..2249deb94 100644 --- a/src/alloy/frontend/ppc/ppc_emit_altivec.cc +++ b/src/alloy/frontend/ppc/ppc_emit_altivec.cc @@ -631,7 +631,7 @@ int InstrEmit_vcmpxxfp_(PPCHIRBuilder& f, InstrData& i, vcmpxxfp_op cmpop, uint3 break; default: XEASSERTALWAYS(); - break; + return 1; } if (rc) { f.UpdateCR6(v); diff --git a/src/alloy/frontend/ppc/ppc_emit_alu.cc b/src/alloy/frontend/ppc/ppc_emit_alu.cc index 7c7378f6a..7144e7eb6 100644 --- a/src/alloy/frontend/ppc/ppc_emit_alu.cc +++ b/src/alloy/frontend/ppc/ppc_emit_alu.cc @@ -674,7 +674,7 @@ XEEMITTER(andisx, 0x74000000, D )(PPCHIRBuilder& f, InstrData& i) { // RA <- (RS) & (i32.0 || UI || i16.0) Value* ra = f.And( f.LoadGPR(i.D.RT), - f.LoadConstant((uint64_t)(i.D.DS << 16))); + f.LoadConstant((uint64_t(i.D.DS) << 16))); f.UpdateCR(0, ra); f.StoreGPR(i.D.RA, ra); return 0; @@ -839,7 +839,7 @@ XEEMITTER(oris, 0x64000000, D )(PPCHIRBuilder& f, InstrData& i) { // RA <- (RS) | (i32.0 || UI || i16.0) Value* ra = f.Or( f.LoadGPR(i.D.RT), - f.LoadConstant((uint64_t)(i.D.DS << 16))); + f.LoadConstant((uint64_t(i.D.DS) << 16))); f.StoreGPR(i.D.RA, ra); return 0; } @@ -869,7 +869,7 @@ XEEMITTER(xoris, 0x6C000000, D )(PPCHIRBuilder& f, InstrData& i) { // RA <- (RS) XOR (i32.0 || UI || i16.0) Value* ra = f.Xor( f.LoadGPR(i.D.RT), - f.LoadConstant((uint64_t)(i.D.DS << 16))); + f.LoadConstant((uint64_t(i.D.DS) << 16))); f.StoreGPR(i.D.RA, ra); return 0; } diff --git a/src/alloy/frontend/ppc/ppc_hir_builder.cc b/src/alloy/frontend/ppc/ppc_hir_builder.cc index 15fd487f7..9f269bb3f 100644 --- a/src/alloy/frontend/ppc/ppc_hir_builder.cc +++ b/src/alloy/frontend/ppc/ppc_hir_builder.cc @@ -149,7 +149,8 @@ int PPCHIRBuilder::Emit(FunctionInfo* symbol_info, bool with_debug_info) { void PPCHIRBuilder::AnnotateLabel(uint64_t address, Label* label) { char name_buffer[13]; - xesnprintfa(name_buffer, XECOUNT(name_buffer), "loc_%.8X", address); + xesnprintfa(name_buffer, XECOUNT(name_buffer), + "loc_%.8X", (uint32_t)address); label->name = (char*)arena_->Alloc(sizeof(name_buffer)); xe_copy_struct(label->name, name_buffer, sizeof(name_buffer)); } diff --git a/src/alloy/hir/hir_builder.cc b/src/alloy/hir/hir_builder.cc index 4893c6db7..1443fe00a 100644 --- a/src/alloy/hir/hir_builder.cc +++ b/src/alloy/hir/hir_builder.cc @@ -307,7 +307,7 @@ void HIRBuilder::InsertLabel(Label* label, Instr* prev_instr) { label->prev = label->next = NULL; Instr* prev_next = prev_instr->next; - Instr* old_prev_tail = prev_block->instr_tail; + Instr* old_prev_tail = prev_block ? prev_block->instr_tail : NULL; if (prev_instr->next) { Instr* prev_last = prev_instr->next->prev; prev_last->next = NULL; diff --git a/src/alloy/mutex_win.cc b/src/alloy/mutex_win.cc index d39a7235e..da37247cc 100644 --- a/src/alloy/mutex_win.cc +++ b/src/alloy/mutex_win.cc @@ -20,10 +20,10 @@ namespace alloy { Mutex* alloy::AllocMutex(uint32_t spin_count) { - Mutex* mutex = (Mutex*)calloc(1, sizeof(Mutex)); + Mutex* mutex = (Mutex*)xe_calloc(sizeof(Mutex)); if (spin_count) { - InitializeCriticalSectionAndSpinCount(&mutex->value, spin_count); + XEIGNORE(InitializeCriticalSectionAndSpinCount(&mutex->value, spin_count)); } else { InitializeCriticalSection(&mutex->value); }