diff --git a/Utilities/Thread.h b/Utilities/Thread.h index 5ce49c5fb3..c6919ba6d2 100644 --- a/Utilities/Thread.h +++ b/Utilities/Thread.h @@ -372,8 +372,6 @@ public: // Try to abort by assigning thread_state::aborting (UB if assigning different state) named_thread& operator=(thread_state s) { - ASSUME(s == thread_state::aborting); - if (s == thread_state::aborting && thread::m_sync.fetch_op([](u64& v){ return !(v & 3) && (v |= 1); }).second) { if (s == thread_state::aborting) diff --git a/Utilities/typemap.h b/Utilities/typemap.h index 082ed633d8..997b737609 100644 --- a/Utilities/typemap.h +++ b/Utilities/typemap.h @@ -372,7 +372,6 @@ namespace utils template > auto get() const noexcept { - ASSUME(m_block->m_type != 0); return m_block->get_ptr(); } diff --git a/Utilities/types.h b/Utilities/types.h index 671c6a629a..76a1b975f8 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -29,28 +29,13 @@ #endif #ifdef _MSC_VER - -#define ASSUME(...) ((__VA_ARGS__) ? void() : __assume(0)) // MSVC __assume ignores side-effects #define SAFE_BUFFERS __declspec(safebuffers) #define NEVER_INLINE __declspec(noinline) #define FORCE_INLINE __forceinline - #else // not _MSC_VER - -#ifdef __clang__ -#if defined(__has_builtin) && __has_builtin(__builtin_assume) -#define ASSUME(...) ((__VA_ARGS__) ? void() : __builtin_assume(0)) // __builtin_assume (supported by modern clang) ignores side-effects -#endif -#endif - -#ifndef ASSUME // gcc and old clang -#define ASSUME(...) ((__VA_ARGS__) ? void() : __builtin_unreachable()) // note: the compiler will generate code to evaluate "cond" if the expression is opaque -#endif - #define SAFE_BUFFERS __attribute__((no_stack_protector)) #define NEVER_INLINE __attribute__((noinline)) inline #define FORCE_INLINE __attribute__((always_inline)) inline - #endif // _MSC_VER #define CHECK_SIZE(type, size) static_assert(sizeof(type) == size, "Invalid " #type " type size") diff --git a/rpcs3/Emu/CPU/CPUDisAsm.h b/rpcs3/Emu/CPU/CPUDisAsm.h index fc94e00618..eaf3971bef 100644 --- a/rpcs3/Emu/CPU/CPUDisAsm.h +++ b/rpcs3/Emu/CPU/CPUDisAsm.h @@ -18,7 +18,7 @@ protected: virtual void Write(const std::string& value) { - switch(m_mode) + switch (m_mode) { case CPUDisAsm_DumpMode: { @@ -50,7 +50,7 @@ protected: last_opcode = value; break; } - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } diff --git a/rpcs3/Emu/Cell/Modules/cellGame.cpp b/rpcs3/Emu/Cell/Modules/cellGame.cpp index 0d1f0b3293..9b240cb1b6 100644 --- a/rpcs3/Emu/Cell/Modules/cellGame.cpp +++ b/rpcs3/Emu/Cell/Modules/cellGame.cpp @@ -594,7 +594,7 @@ error_code cellGameDataCheck(u32 type, vm::cptr dirName, vm::ptr dirNam return 4; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -426,7 +426,7 @@ static s32 savedata_check_args(u32 operation, u32 version, vm::cptr dirNam return 17; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -776,7 +776,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v break; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } selected_list.emplace(listSet->fixedList[i].dirName); @@ -826,7 +826,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v break; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -858,7 +858,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v break; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } const std::string dirStr = listSet->focusDirName.get_ptr(); @@ -1114,7 +1114,7 @@ static NEVER_INLINE error_code savedata_op(ppu_thread& ppu, u32 operation, u32 v return {CELL_SAVEDATA_ERROR_PARAM, "28"}; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } const std::string dirStr = fixedSet->dirName.get_ptr(); @@ -1973,7 +1973,7 @@ static NEVER_INLINE error_code savedata_get_list_item(vm::cptr dirName, vm return {CELL_SAVEDATA_ERROR_PARAM, "109"}; } case 0: break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } const std::string base_dir = fmt::format("/dev_hdd0/home/%08u/savedata/", userId); diff --git a/rpcs3/Emu/Cell/PPUDisAsm.cpp b/rpcs3/Emu/Cell/PPUDisAsm.cpp index 9837a9b214..e13ee3e3bc 100644 --- a/rpcs3/Emu/Cell/PPUDisAsm.cpp +++ b/rpcs3/Emu/Cell/PPUDisAsm.cpp @@ -69,7 +69,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "ble"; break; case 0x2: info.first = "bne"; break; case 0x3: info.first = "bns"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } @@ -82,7 +82,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "ble"; break; case 0x2: info.first = "bne"; break; case 0x3: info.first = "bns"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } @@ -95,7 +95,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "ble"; break; case 0x2: info.first = "bne"; break; case 0x3: info.first = "bns"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } @@ -107,7 +107,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "bgt"; break; case 0x2: info.first = "beq"; break; case 0x3: info.first = "bso"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } @@ -120,7 +120,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "bgt"; break; case 0x2: info.first = "beq"; break; case 0x3: info.first = "bso"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } @@ -133,7 +133,7 @@ constexpr std::pair get_BC_info(u32 bo, u32 bi) case 0x1: info.first = "bgt"; break; case 0x2: info.first = "beq"; break; case 0x3: info.first = "bso"; break; - default: ASSUME(0); break; + default: fmt::throw_exception("Unreachable"); } break; } diff --git a/rpcs3/Emu/Cell/PPUDisAsm.h b/rpcs3/Emu/Cell/PPUDisAsm.h index 049915df42..f9b25c439c 100644 --- a/rpcs3/Emu/Cell/PPUDisAsm.h +++ b/rpcs3/Emu/Cell/PPUDisAsm.h @@ -24,7 +24,7 @@ private: case 0x1: return "gt"; case 0x2: return "eq"; case 0x3: return "so"; - default: ASSUME(0); return {}; + default: fmt::throw_exception("Unreachable"); } } @@ -284,7 +284,7 @@ private: { Write(fmt::format("%s cr%d[%s],0x%x ", FixOp(op), bi / 4, get_partial_BI_field(bi), pc)); } - + public: u32 disasm(u32 pc) override; diff --git a/rpcs3/Emu/Cell/SPUDisAsm.cpp b/rpcs3/Emu/Cell/SPUDisAsm.cpp index b478ed38c6..ffce4726d8 100644 --- a/rpcs3/Emu/Cell/SPUDisAsm.cpp +++ b/rpcs3/Emu/Cell/SPUDisAsm.cpp @@ -88,7 +88,7 @@ std::pair SPUDisAsm::try_get_const_value(u32 reg, u32 pc) const case spu_itype::CHD: size = 2; break; case spu_itype::CWD: size = 4; break; case spu_itype::CDD: size = 8; break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } const u32 index = (~op0.i7 & 0xf) / size; @@ -100,7 +100,7 @@ std::pair SPUDisAsm::try_get_const_value(u32 reg, u32 pc) const case 2: res._u16[index] = 0x0203; break; case 4: res._u32[index] = 0x00010203; break; case 8: res._u64[index] = 0x0001020304050607ull; break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } return {true, res}; diff --git a/rpcs3/Emu/Cell/SPUThread.cpp b/rpcs3/Emu/Cell/SPUThread.cpp index 3fd439a3c7..a441dd55f1 100644 --- a/rpcs3/Emu/Cell/SPUThread.cpp +++ b/rpcs3/Emu/Cell/SPUThread.cpp @@ -3516,8 +3516,6 @@ retry: void spu_thread::set_events(u32 bits) { - ASSUME(!(bits & ~0xffff)); - if (ch_events.atomic_op([&](ch_events_t& events) { events.events |= bits; diff --git a/rpcs3/Emu/Cell/lv2/sys_spu.cpp b/rpcs3/Emu/Cell/lv2/sys_spu.cpp index 4bb3b77fd9..54b0f81cc2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_spu.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_spu.cpp @@ -1271,7 +1271,7 @@ error_code sys_spu_thread_write_ls(ppu_thread& ppu, u32 id, u32 lsa, u64 value, case 2: thread->_ref(lsa) = static_cast(value); break; case 4: thread->_ref(lsa) = static_cast(value); break; case 8: thread->_ref(lsa) = value; break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } return CELL_OK; @@ -1314,7 +1314,7 @@ error_code sys_spu_thread_read_ls(ppu_thread& ppu, u32 id, u32 lsa, vm::ptr case 2: *value = thread->_ref(lsa); break; case 4: *value = thread->_ref(lsa); break; case 8: *value = thread->_ref(lsa); break; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } return CELL_OK; diff --git a/rpcs3/Emu/Memory/vm.cpp b/rpcs3/Emu/Memory/vm.cpp index 1b239fe408..da47d6d2df 100644 --- a/rpcs3/Emu/Memory/vm.cpp +++ b/rpcs3/Emu/Memory/vm.cpp @@ -310,8 +310,6 @@ namespace vm { to_clear = for_all_range_locks(to_clear, [&](u32 addr2, u32 size2) { - ASSUME(size2); - if (range.overlaps(utils::address_range::start_length(addr2, size2))) [[unlikely]] { return 1; diff --git a/rpcs3/Emu/RSX/Common/TextureUtils.cpp b/rpcs3/Emu/RSX/Common/TextureUtils.cpp index c227871b53..e12372db9a 100644 --- a/rpcs3/Emu/RSX/Common/TextureUtils.cpp +++ b/rpcs3/Emu/RSX/Common/TextureUtils.cpp @@ -862,8 +862,7 @@ namespace rsx case rsx::surface_antialiasing::square_rotated_4_samples: return 4; default: - ASSUME(0); - return 0; + fmt::throw_exception("Unreachable"); } } @@ -1083,7 +1082,7 @@ namespace rsx case rsx::surface_depth_format2::z24s8_float: return{ CELL_GCM_TEXTURE_DEPTH24_D8_FLOAT, true }; default: - ASSUME(0); + fmt::throw_exception("Unreachable"); } } diff --git a/rpcs3/Emu/RSX/Common/texture_cache_checker.h b/rpcs3/Emu/RSX/Common/texture_cache_checker.h index 2ec5aa2afd..3b8ae6dc90 100644 --- a/rpcs3/Emu/RSX/Common/texture_cache_checker.h +++ b/rpcs3/Emu/RSX/Common/texture_cache_checker.h @@ -40,7 +40,7 @@ namespace rsx { case utils::protection::no: return no > 0; case utils::protection::ro: return no == 0 && ro > 0; case utils::protection::rw: return no == 0 && ro == 0; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -50,7 +50,7 @@ namespace rsx { { case utils::protection::no: if (no++ == UINT8_MAX) fmt::throw_exception("add(protection::no) overflow with NO==%d", UINT8_MAX); return; case utils::protection::ro: if (ro++ == UINT8_MAX) fmt::throw_exception("add(protection::ro) overflow with RO==%d", UINT8_MAX); return; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -60,7 +60,7 @@ namespace rsx { { case utils::protection::no: if (no-- == 0) fmt::throw_exception("remove(protection::no) overflow with NO==0"); return; case utils::protection::ro: if (ro-- == 0) fmt::throw_exception("remove(protection::ro) overflow with RO==0"); return; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } }; diff --git a/rpcs3/Emu/RSX/GL/GLTexture.cpp b/rpcs3/Emu/RSX/GL/GLTexture.cpp index 073d5b8b09..aa044bb487 100644 --- a/rpcs3/Emu/RSX/GL/GLTexture.cpp +++ b/rpcs3/Emu/RSX/GL/GLTexture.cpp @@ -694,7 +694,6 @@ namespace gl } default: { - ASSUME(0); fmt::throw_exception("Unreachable"); } } diff --git a/rpcs3/Emu/RSX/RSXOffload.cpp b/rpcs3/Emu/RSX/RSXOffload.cpp index 0b658d254e..49a7e92638 100644 --- a/rpcs3/Emu/RSX/RSXOffload.cpp +++ b/rpcs3/Emu/RSX/RSXOffload.cpp @@ -61,7 +61,7 @@ namespace rsx rsx::get_current_renderer()->renderctl(job.aux_param0, job.src); break; } - default: ASSUME(0); fmt::throw_exception("Unreachable"); + default: fmt::throw_exception("Unreachable"); } m_processed_count.release(m_processed_count + 1); @@ -224,7 +224,6 @@ namespace rsx range = get_index_count(static_cast(m_current_job->aux_param0), m_current_job->length); break; default: - ASSUME(0); fmt::throw_exception("Unreachable"); } diff --git a/rpcs3/Emu/RSX/RSXTexture.cpp b/rpcs3/Emu/RSX/RSXTexture.cpp index 81e66caeca..eebe92fcab 100644 --- a/rpcs3/Emu/RSX/RSXTexture.cpp +++ b/rpcs3/Emu/RSX/RSXTexture.cpp @@ -39,7 +39,7 @@ namespace rsx case rsx::texture_dimension::dimension3d: return rsx::texture_dimension_extended::texture_dimension_3d; case rsx::texture_dimension::dimension2d: return cubemap() ? rsx::texture_dimension_extended::texture_dimension_cubemap : rsx::texture_dimension_extended::texture_dimension_2d; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } @@ -351,7 +351,7 @@ namespace rsx case rsx::texture_dimension::dimension3d: return rsx::texture_dimension_extended::texture_dimension_3d; case rsx::texture_dimension::dimension2d: return cubemap() ? rsx::texture_dimension_extended::texture_dimension_cubemap : rsx::texture_dimension_extended::texture_dimension_2d; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); } } diff --git a/rpcs3/Emu/RSX/VK/VKDraw.cpp b/rpcs3/Emu/RSX/VK/VKDraw.cpp index 98b915f342..3d2c172e72 100644 --- a/rpcs3/Emu/RSX/VK/VKDraw.cpp +++ b/rpcs3/Emu/RSX/VK/VKDraw.cpp @@ -16,7 +16,7 @@ namespace vk return VK_IMAGE_VIEW_TYPE_CUBE; case rsx::texture_dimension_extended::texture_dimension_3d: return VK_IMAGE_VIEW_TYPE_3D; - default: ASSUME(0); + default: fmt::throw_exception("Unreachable"); }; } diff --git a/rpcs3/Emu/RSX/VK/VKFormats.cpp b/rpcs3/Emu/RSX/VK/VKFormats.cpp index e46c55f2c1..aff474f62e 100644 --- a/rpcs3/Emu/RSX/VK/VKFormats.cpp +++ b/rpcs3/Emu/RSX/VK/VKFormats.cpp @@ -79,9 +79,9 @@ namespace vk case rsx::texture_minify_filter::linear_linear: return { VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_LINEAR, true }; case rsx::texture_minify_filter::convolution_min: return { VK_FILTER_LINEAR, VK_SAMPLER_MIPMAP_MODE_NEAREST, false }; default: - ASSUME(0); break; } + fmt::throw_exception("Invalid min filter"); } @@ -93,9 +93,9 @@ namespace vk case rsx::texture_magnify_filter::linear: return VK_FILTER_LINEAR; case rsx::texture_magnify_filter::convolution_mag: return VK_FILTER_LINEAR; default: - ASSUME(0); break; } + fmt::throw_exception("Invalid mag filter (0x%x)", static_cast(mag_filter)); } @@ -147,10 +147,10 @@ namespace vk case rsx::texture_wrap_mode::mirror_once_border: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; case rsx::texture_wrap_mode::mirror_once_clamp: return VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE; default: - ASSUME(0); break; } - fmt::throw_exception("unhandled texture clamp mode"); + + fmt::throw_exception("Unhandled texture clamp mode"); } float max_aniso(rsx::texture_max_anisotropy gcm_aniso) @@ -166,7 +166,6 @@ namespace vk case rsx::texture_max_anisotropy::x12: return 12.0f; case rsx::texture_max_anisotropy::x16: return 16.0f; default: - ASSUME(0); break; } diff --git a/rpcs3/Emu/RSX/VK/VKHelpers.h b/rpcs3/Emu/RSX/VK/VKHelpers.h index a8a8fac50b..dbbc22cb5b 100644 --- a/rpcs3/Emu/RSX/VK/VKHelpers.h +++ b/rpcs3/Emu/RSX/VK/VKHelpers.h @@ -1662,8 +1662,7 @@ private: info.viewType = VK_IMAGE_VIEW_TYPE_3D; break; default: - ASSUME(0); - break; + fmt::throw_exception("Unreachable"); } info.subresourceRange.layerCount = resource->info.arrayLayers; diff --git a/rpcs3/Emu/RSX/VK/VKTextureCache.h b/rpcs3/Emu/RSX/VK/VKTextureCache.h index 5dab6f1537..cd7c694c4e 100644 --- a/rpcs3/Emu/RSX/VK/VKTextureCache.h +++ b/rpcs3/Emu/RSX/VK/VKTextureCache.h @@ -1146,8 +1146,7 @@ namespace vk layer = 1; break; default: - ASSUME(0); - break; + fmt::throw_exception("Unreachable"); } auto *image = new vk::viewable_image(*m_device, m_memory_types.device_local, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT, diff --git a/rpcs3/Emu/RSX/gcm_enums.h b/rpcs3/Emu/RSX/gcm_enums.h index 4797624566..b70fa44bdc 100644 --- a/rpcs3/Emu/RSX/gcm_enums.h +++ b/rpcs3/Emu/RSX/gcm_enums.h @@ -76,8 +76,8 @@ namespace rsx return (rhs == surface_depth_format2::z16_uint || rhs == surface_depth_format2::z16_float); case surface_depth_format::z24s8: return (rhs == surface_depth_format2::z24s8_uint || rhs == surface_depth_format2::z24s8_float); - default: - ASSUME(0); + [[unlikely]] default: + return false; } } diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index 1f787fbfde..a03f2f68a5 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -213,7 +213,7 @@ namespace rsx case section_bounds::confirmed_range: return confirmed_range.valid() ? confirmed_range : cpu_range; default: - ASSUME(0); + fmt::throw_exception("Unreachable"); } }