From 6fbca1acfd5ee7da782f93995cff99dd09cfe48d Mon Sep 17 00:00:00 2001 From: oltolm Date: Wed, 5 Apr 2023 13:35:06 +0200 Subject: [PATCH] remove unnecessary pointer bitcasts --- rpcs3/Emu/Cell/PPUTranslator.cpp | 28 ++++++------- rpcs3/Emu/Cell/PPUTranslator.h | 8 ++-- rpcs3/Emu/Cell/SPURecompiler.cpp | 67 ++++++++++++++------------------ 3 files changed, 48 insertions(+), 55 deletions(-) diff --git a/rpcs3/Emu/Cell/PPUTranslator.cpp b/rpcs3/Emu/Cell/PPUTranslator.cpp index bba48ba2c4..d75a4b0a61 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.cpp +++ b/rpcs3/Emu/Cell/PPUTranslator.cpp @@ -385,7 +385,7 @@ void PPUTranslator::CallFunction(u64 target, Value* indirect) const auto pos = m_ir->CreateShl(indirect, 1); const auto ptr = dyn_cast(m_ir->CreateGEP(get_type(), m_exec, pos)); - const auto val = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(ptr, get_type())); + const auto val = m_ir->CreateLoad(get_type(), ptr); callee = FunctionCallee(type, m_ir->CreateIntToPtr(m_ir->CreateAnd(val, 0xffff'ffff'ffff), type->getPointerTo())); // Load new segment address @@ -456,7 +456,7 @@ void PPUTranslator::FlushRegisters() m_ir->SetInsertPoint(block); } - m_ir->CreateStore(local, bitcast(m_globals[index], local->getType()->getPointerTo())); + m_ir->CreateStore(local, m_globals[index]); m_globals[index] = nullptr; } } @@ -591,9 +591,9 @@ void PPUTranslator::UseCondition(MDNode* hint, Value* cond) } } -llvm::Value* PPUTranslator::GetMemory(llvm::Value* addr, llvm::Type* type) +llvm::Value* PPUTranslator::GetMemory(llvm::Value* addr) { - return bitcast(m_ir->CreateGEP(get_type(), m_base, addr), type->getPointerTo()); + return m_ir->CreateGEP(get_type(), m_base, addr); } Value* PPUTranslator::ReadMemory(Value* addr, Type* type, bool is_be, u32 align) @@ -604,12 +604,12 @@ Value* PPUTranslator::ReadMemory(Value* addr, Type* type, bool is_be, u32 align) { // Read, byteswap, bitcast const auto int_type = m_ir->getIntNTy(size); - const auto value = m_ir->CreateAlignedLoad(int_type, GetMemory(addr, int_type), llvm::MaybeAlign{align}); + const auto value = m_ir->CreateAlignedLoad(int_type, GetMemory(addr), llvm::MaybeAlign{align}); return bitcast(Call(int_type, fmt::format("llvm.bswap.i%u", size), value), type); } // Read normally - return m_ir->CreateAlignedLoad(type, GetMemory(addr, type), llvm::MaybeAlign{align}); + return m_ir->CreateAlignedLoad(type, GetMemory(addr), llvm::MaybeAlign{align}); } void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align) @@ -625,7 +625,7 @@ void PPUTranslator::WriteMemory(Value* addr, Value* value, bool is_be, u32 align } // Write - m_ir->CreateAlignedStore(value, GetMemory(addr, value->getType()), llvm::MaybeAlign{align}); + m_ir->CreateAlignedStore(value, GetMemory(addr), llvm::MaybeAlign{align}); } void PPUTranslator::CompilationError(const std::string& error) @@ -2788,8 +2788,8 @@ void PPUTranslator::MTOCRF(ppu_opcode_t op) std::fill_n(m_g_cr + i * 4, 4, nullptr); const auto index = m_ir->CreateAnd(m_ir->CreateLShr(value, 28 - i * 4), 15); - const auto src = m_ir->CreateGEP(dyn_cast(m_mtocr_table)->getValueType(), m_mtocr_table, {m_ir->getInt32(0), m_ir->CreateShl(index, 2)}); - const auto dst = bitcast(m_ir->CreateStructGEP(m_thread_type, m_thread, static_cast(m_cr - m_locals) + i * 4), GetType()); + const auto src = m_ir->CreateGEP(m_mtocr_table->getValueType(), m_mtocr_table, {m_ir->getInt32(0), m_ir->CreateShl(index, 2)}); + const auto dst = m_ir->CreateStructGEP(m_thread_type, m_thread, static_cast(m_cr - m_locals) + i * 4); Call(GetType(), "llvm.memcpy.p0.p0.i32", dst, src, m_ir->getInt32(4), m_ir->getFalse()); } } @@ -3311,7 +3311,7 @@ void PPUTranslator::STVLX(ppu_opcode_t op) const auto addr = op.ra ? m_ir->CreateAdd(GetGpr(op.ra), GetGpr(op.rb)) : GetGpr(op.rb); const auto data = pshufb(get_vr(op.vs), build(127, 126, 125, 124, 123, 122, 121, 120, 119, 118, 117, 116, 115, 114, 113, 112) + vsplat(trunc(value(addr) & 0xf))); const auto mask = bitcast(splat(0xffff) << trunc(value(addr) & 0xf)); - const auto ptr = value(GetMemory(m_ir->CreateAnd(addr, ~0xfull), GetType())); + const auto ptr = value(GetMemory(m_ir->CreateAnd(addr, ~0xfull))); const auto align = splat(16); eval(llvm_calli{"llvm.masked.store.v16i8.p0", {data, ptr, align, mask}}); } @@ -3341,7 +3341,7 @@ void PPUTranslator::STVRX(ppu_opcode_t op) const auto addr = op.ra ? m_ir->CreateAdd(GetGpr(op.ra), GetGpr(op.rb)) : GetGpr(op.rb); const auto data = pshufb(get_vr(op.vs), build(255, 254, 253, 252, 251, 250, 249, 248, 247, 246, 245, 244, 243, 242, 241, 240) + vsplat(trunc(value(addr) & 0xf))); const auto mask = bitcast(trunc(splat(0xffff) << (value(addr) & 0xf) >> 16)); - const auto ptr = value(GetMemory(m_ir->CreateAnd(addr, ~0xfull), GetType())); + const auto ptr = value(GetMemory(m_ir->CreateAnd(addr, ~0xfull))); const auto align = splat(16); eval(llvm_calli{"llvm.masked.store.v16i8.p0", {data, ptr, align, mask}}); } @@ -3524,7 +3524,7 @@ void PPUTranslator::DCBZ(ppu_opcode_t op) } else { - Call(GetType(), "llvm.memset.p0.i32", GetMemory(addr, GetType()), m_ir->getInt8(0), m_ir->getInt32(128), m_ir->getFalse()); + Call(GetType(), "llvm.memset.p0.i32", GetMemory(addr), m_ir->getInt8(0), m_ir->getInt32(128), m_ir->getFalse()); } } @@ -4009,7 +4009,7 @@ void PPUTranslator::FRES(ppu_opcode_t op) const auto n = m_ir->CreateFCmpUNO(a, a); // test for NaN const auto e = m_ir->CreateAnd(m_ir->CreateLShr(b, 52), 0x7ff); // double exp const auto i = m_ir->CreateAnd(m_ir->CreateLShr(b, 45), 0x7f); // mantissa LUT index - const auto ptr = dyn_cast(m_ir->CreateGEP(dyn_cast(m_fres_table)->getValueType(), m_fres_table, {m_ir->getInt64(0), i})); + const auto ptr = dyn_cast(m_ir->CreateGEP(m_fres_table->getValueType(), m_fres_table, {m_ir->getInt64(0), i})); assert(ptr->getResultElementType() == get_type()); const auto m = m_ir->CreateShl(ZExt(m_ir->CreateLoad(ptr->getResultElementType(), ptr)), 29); const auto c = m_ir->CreateICmpUGE(e, m_ir->getInt64(0x3ff + 0x80)); // test for INF @@ -4382,7 +4382,7 @@ void PPUTranslator::FRSQRTE(ppu_opcode_t op) } const auto b = m_ir->CreateBitCast(GetFpr(op.frb), GetType()); - const auto ptr = dyn_cast(m_ir->CreateGEP(dyn_cast(m_frsqrte_table)->getValueType(), m_frsqrte_table, {m_ir->getInt64(0), m_ir->CreateLShr(b, 49)})); + const auto ptr = dyn_cast(m_ir->CreateGEP(m_frsqrte_table->getValueType(), m_frsqrte_table, {m_ir->getInt64(0), m_ir->CreateLShr(b, 49)})); assert(ptr->getResultElementType() == get_type()); const auto v = m_ir->CreateLoad(ptr->getResultElementType(), ptr); const auto result = m_ir->CreateBitCast(m_ir->CreateShl(ZExt(v), 32), GetType()); diff --git a/rpcs3/Emu/Cell/PPUTranslator.h b/rpcs3/Emu/Cell/PPUTranslator.h index 84732d6c0c..947d818a1c 100644 --- a/rpcs3/Emu/Cell/PPUTranslator.h +++ b/rpcs3/Emu/Cell/PPUTranslator.h @@ -54,9 +54,9 @@ class PPUTranslator final : public cpu_translator // Thread context struct llvm::StructType* m_thread_type; - llvm::Value* m_mtocr_table{}; - llvm::Value* m_frsqrte_table{}; - llvm::Value* m_fres_table{}; + llvm::GlobalVariable* m_mtocr_table{}; + llvm::GlobalVariable* m_frsqrte_table{}; + llvm::GlobalVariable* m_fres_table{}; llvm::Value* m_globals[175]; llvm::Value** const m_g_cr = m_globals + 99; @@ -294,7 +294,7 @@ public: void UseCondition(llvm::MDNode* hint, llvm::Value* = nullptr); // Get memory pointer - llvm::Value* GetMemory(llvm::Value* addr, llvm::Type* type); + llvm::Value* GetMemory(llvm::Value* addr); // Read from memory llvm::Value* ReadMemory(llvm::Value* addr, llvm::Type* type, bool is_be = true, u32 align = 1); diff --git a/rpcs3/Emu/Cell/SPURecompiler.cpp b/rpcs3/Emu/Cell/SPURecompiler.cpp index 975ed2e8da..ca8819215a 100644 --- a/rpcs3/Emu/Cell/SPURecompiler.cpp +++ b/rpcs3/Emu/Cell/SPURecompiler.cpp @@ -4134,7 +4134,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator if (m_finfo->chunk->getReturnType() != get_type()) { - m_ir->CreateRet(m_ir->CreateBitCast(ppfunc, get_type())); + m_ir->CreateRet(ppfunc); return; } @@ -4370,9 +4370,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator template llvm::Value* _ptr(llvm::Value* base, u32 offset) { - const auto off = m_ir->CreateGEP(get_type(), base, m_ir->getInt64(offset)); - const auto ptr = m_ir->CreateBitCast(off, get_type()); - return ptr; + return m_ir->CreateGEP(get_type(), base, m_ir->getInt64(offset)); } template @@ -4385,8 +4383,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator llvm::Value* spu_ptr(value_t add, Args... offset_args) { const auto off = m_ir->CreateGEP(get_type(), m_thread, m_ir->getInt64(::offset32(offset_args...))); - const auto ptr = m_ir->CreateBitCast(m_ir->CreateAdd(off, add.value), get_type()); - return ptr; + return m_ir->CreateAdd(off, add.value); } // Return default register type @@ -4433,7 +4430,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator { if (!m_block) { - return m_ir->CreateBitCast(_ptr(m_thread, get_reg_offset(index)), get_reg_type(index)->getPointerTo()); + return _ptr(m_thread, get_reg_offset(index)); } auto& ptr = ::at32(m_reg_addr, index); @@ -4446,7 +4443,6 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator // Emit register pointer at the beginning of the function chunk m_ir->SetInsertPoint(m_function->getEntryBlock().getTerminator()); ptr = _ptr(m_thread, get_reg_offset(index)); - ptr = m_ir->CreateBitCast(ptr, get_reg_type(index)->getPointerTo()); m_ir->SetInsertPoint(block_cur); } @@ -4469,7 +4465,7 @@ class spu_llvm_recompiler : public spu_recompiler_base, public cpu_translator const auto idx = m_ir->CreateAnd(I > 4 ? isr : isl, m_interp_7f0); // Pointer to the register - return m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_interp_regs, m_ir->CreateZExt(idx, get_type())), get_type()); + return m_ir->CreateGEP(get_type(), m_interp_regs, m_ir->CreateZExt(idx, get_type())); } llvm::Value* double_as_uint64(llvm::Value* val) @@ -5056,13 +5052,13 @@ public: } else if (func.data.size() == 1) { - const auto pu32 = m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, m_base_pc), get_type()); + const auto pu32 = m_ir->CreateGEP(get_type(), m_lsptr, m_base_pc); const auto cond = m_ir->CreateICmpNE(m_ir->CreateLoad(get_type(), pu32), m_ir->getInt32(func.data[0])); m_ir->CreateCondBr(cond, label_diff, label_body, m_md_unlikely); } else if (func.data.size() == 2) { - const auto pu64 = m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, m_base_pc), get_type()); + const auto pu64 = m_ir->CreateGEP(get_type(), m_lsptr, m_base_pc); const auto cond = m_ir->CreateICmpNE(m_ir->CreateLoad(get_type(), pu64), m_ir->getInt64(static_cast(func.data[1]) << 32 | func.data[0])); m_ir->CreateCondBr(cond, label_diff, label_body, m_md_unlikely); } @@ -5219,8 +5215,7 @@ public: // Proceed to the next code if (entry_chunk->chunk->getReturnType() != get_type()) { - const auto f_ptr = m_ir->CreateBitCast(entry_call, main_func->getType()); - const auto next_call = m_ir->CreateCall({main_func->getFunctionType(), f_ptr}, {m_thread, m_lsptr, m_ir->getInt64(0)}); + const auto next_call = m_ir->CreateCall(main_func->getFunctionType(), entry_call, {m_thread, m_lsptr, m_ir->getInt64(0)}); next_call->setCallingConv(main_func->getCallingConv()); next_call->setTailCall(); } @@ -5258,15 +5253,14 @@ public: if (entry_chunk->chunk->getReturnType() == get_type()) { - const auto f_ptr = m_ir->CreateBitCast(dispatcher, main_func->getType()); - const auto next_call = m_ir->CreateCall({main_func->getFunctionType(), f_ptr}, {m_thread, m_lsptr, m_ir->getInt64(0)}); + const auto next_call = m_ir->CreateCall(main_func->getFunctionType(), dispatcher, {m_thread, m_lsptr, m_ir->getInt64(0)}); next_call->setCallingConv(main_func->getCallingConv()); next_call->setTailCall(); m_ir->CreateRetVoid(); } else { - m_ir->CreateRet(m_ir->CreateBitCast(dispatcher, get_type())); + m_ir->CreateRet(dispatcher); } // Function that executes check_state and escapes if necessary @@ -5701,7 +5695,6 @@ public: // Create interpreter table const auto if_type = get_ftype(); - const auto if_pptr = if_type->getPointerTo()->getPointerTo(); m_function_table = new GlobalVariable(*m_module, ArrayType::get(if_type->getPointerTo(), 1ull << m_interp_magn), true, GlobalValue::InternalLinkage, nullptr); // Add return function @@ -5722,11 +5715,11 @@ public: // Load pc and opcode m_interp_pc = m_ir->CreateLoad(get_type(), spu_ptr(&spu_thread::pc)); - m_interp_op = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, m_ir->CreateZExt(m_interp_pc, get_type())), get_type())); + m_interp_op = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_lsptr, m_ir->CreateZExt(m_interp_pc, get_type()))); m_interp_op = m_ir->CreateCall(get_intrinsic(Intrinsic::bswap), {m_interp_op}); // Pinned constant, address of interpreter table - m_interp_table = m_ir->CreateBitCast(m_ir->CreateGEP(m_function_table->getValueType(), m_function_table, {m_ir->getInt64(0), m_ir->getInt64(0)}), get_type()); + m_interp_table = m_ir->CreateGEP(m_function_table->getValueType(), m_function_table, {m_ir->getInt64(0), m_ir->getInt64(0)}); // Pinned constant, mask for shifted register index m_interp_7f0 = m_ir->getInt32(0x7f0); @@ -5744,8 +5737,8 @@ public: m_ir->CreateStore(m_ir->CreateCall(get_intrinsic(Intrinsic::read_register), {rsp_name}), native_sp); // Decode (shift) and load function pointer - const auto first = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_ir->CreateBitCast(m_interp_table, if_pptr), m_ir->CreateLShr(m_interp_op, 32u - m_interp_magn))); - const auto call0 = m_ir->CreateCall({if_type, first}, {m_lsptr, m_thread, m_interp_pc, m_interp_op, m_interp_table, m_interp_7f0, m_interp_regs}); + const auto first = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_interp_table, m_ir->CreateLShr(m_interp_op, 32u - m_interp_magn))); + const auto call0 = m_ir->CreateCall(if_type, first, {m_lsptr, m_thread, m_interp_pc, m_interp_op, m_interp_table, m_interp_7f0, m_interp_regs}); call0->setCallingConv(CallingConv::GHC); m_ir->CreateRetVoid(); @@ -5886,9 +5879,9 @@ public: // Decode next instruction. const auto next_pc = itype & spu_itype::branch ? m_interp_pc : m_interp_pc_next; - const auto be32_op = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, m_ir->CreateZExt(next_pc, get_type())), get_type())); + const auto be32_op = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_lsptr, m_ir->CreateZExt(next_pc, get_type()))); const auto next_op = m_ir->CreateCall(get_intrinsic(Intrinsic::bswap), {be32_op}); - const auto next_if = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_ir->CreateBitCast(m_interp_table, if_pptr), m_ir->CreateLShr(next_op, 32u - m_interp_magn))); + const auto next_if = m_ir->CreateLoad(if_type->getPointerTo(), m_ir->CreateGEP(if_type->getPointerTo(), m_interp_table, m_ir->CreateLShr(next_op, 32u - m_interp_magn))); llvm::cast(next_if)->setVolatile(true); if (!(itype & spu_itype::branch)) @@ -5933,7 +5926,7 @@ public: m_ir->SetInsertPoint(_next); } - llvm::Value* fret = m_ir->CreateBitCast(m_interp_table, if_type->getPointerTo()); + llvm::Value* fret = m_interp_table; if (itype == spu_itype::WRCH || itype == spu_itype::RDCH || @@ -5963,7 +5956,7 @@ public: } const auto arg3 = UndefValue::get(get_type()); - const auto _ret = m_ir->CreateCall({if_type, fret}, {m_lsptr, m_thread, m_interp_pc, arg3, m_interp_table, m_interp_7f0, m_interp_regs}); + const auto _ret = m_ir->CreateCall(if_type, fret, {m_lsptr, m_thread, m_interp_pc, arg3, m_interp_table, m_interp_7f0, m_interp_regs}); _ret->setCallingConv(CallingConv::GHC); _ret->setTailCall(); m_ir->CreateRetVoid(); @@ -5987,7 +5980,7 @@ public: m_interp_regs = _ptr(m_thread, get_reg_offset(0)); } - const auto ncall = m_ir->CreateCall({if_type, next_if}, {m_lsptr, m_thread, m_interp_pc, next_op, m_interp_table, m_interp_7f0, m_interp_regs}); + const auto ncall = m_ir->CreateCall(if_type, next_if, {m_lsptr, m_thread, m_interp_pc, next_op, m_interp_table, m_interp_7f0, m_interp_regs}); ncall->setCallingConv(CallingConv::GHC); ncall->setTailCall(); m_ir->CreateRetVoid(); @@ -6826,7 +6819,7 @@ public: if (csize > 0 && csize <= 16) { // Generate single copy operation - m_ir->CreateStore(m_ir->CreateLoad(vtype, m_ir->CreateBitCast(src, vtype->getPointerTo())), m_ir->CreateBitCast(dst, vtype->getPointerTo())); + m_ir->CreateStore(m_ir->CreateLoad(vtype, src), dst); } else if (csize <= stride * 16 && !(csize % 32)) { @@ -6837,11 +6830,11 @@ public: const auto _dst = m_ir->CreateGEP(get_type(), dst, m_ir->getInt32(i)); if (csize - i < stride) { - m_ir->CreateStore(m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(_src, get_type())), m_ir->CreateBitCast(_dst, get_type())); + m_ir->CreateStore(m_ir->CreateLoad(get_type(), _src), _dst); } else { - m_ir->CreateAlignedStore(m_ir->CreateAlignedLoad(vtype, m_ir->CreateBitCast(_src, vtype->getPointerTo()), llvm::MaybeAlign{16}), m_ir->CreateBitCast(_dst, vtype->getPointerTo()), llvm::MaybeAlign{16}); + m_ir->CreateAlignedStore(m_ir->CreateAlignedLoad(vtype, _src, llvm::MaybeAlign{16}), _dst, llvm::MaybeAlign{16}); } } } @@ -9694,13 +9687,13 @@ public: void make_store_ls(value_t addr, value_t data) { const auto bswapped = byteswap(data); - m_ir->CreateStore(bswapped.eval(m_ir), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, addr.value), get_type())); + m_ir->CreateStore(bswapped.eval(m_ir), m_ir->CreateGEP(get_type(), m_lsptr, addr.value)); } auto make_load_ls(value_t addr) { value_t data; - data.value = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, addr.value), get_type())); + data.value = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_lsptr, addr.value)); return byteswap(data); } @@ -9983,19 +9976,19 @@ public: // Compare address stored in stack mirror with addr const auto stack0 = eval(zext(sp) + ::offset32(&spu_thread::stack_mirror)); const auto stack1 = eval(stack0 + 8); - const auto _ret = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_thread, stack0.value), get_type())); - const auto link = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_thread, stack1.value), get_type())); + const auto _ret = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_thread, stack0.value)); + const auto link = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_thread, stack1.value)); const auto fail = llvm::BasicBlock::Create(m_context, "", m_function); const auto done = llvm::BasicBlock::Create(m_context, "", m_function); const auto next = llvm::BasicBlock::Create(m_context, "", m_function); m_ir->CreateCondBr(m_ir->CreateICmpEQ(addr.value, m_ir->CreateTrunc(link, get_type())), next, fail, m_md_likely); m_ir->SetInsertPoint(next); - const auto cmp2 = m_ir->CreateLoad(get_type(), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_lsptr, addr.value), get_type())); + const auto cmp2 = m_ir->CreateLoad(get_type(), m_ir->CreateGEP(get_type(), m_lsptr, addr.value)); m_ir->CreateCondBr(m_ir->CreateICmpEQ(cmp2, m_ir->CreateTrunc(_ret, get_type())), done, fail, m_md_likely); m_ir->SetInsertPoint(done); // Clear stack mirror and return by tail call to the provided return address - m_ir->CreateStore(splat(-1).eval(m_ir), m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_thread, stack0.value), get_type())); + m_ir->CreateStore(splat(-1).eval(m_ir), m_ir->CreateGEP(get_type(), m_thread, stack0.value)); const auto targ = m_ir->CreateAdd(m_ir->CreateLShr(_ret, 32), get_segment_base()); const auto type = m_finfo->chunk->getFunctionType(); const auto fval = m_ir->CreateIntToPtr(targ, type->getPointerTo()); @@ -10670,8 +10663,8 @@ public: const auto rel_ptr = m_ir->CreateSub(m_ir->CreatePtrToInt(pfunc->chunk, get_type()), get_segment_base()); const auto ptr_plus_op = m_ir->CreateOr(m_ir->CreateShl(rel_ptr, 32), m_ir->getInt64(m_next_op)); const auto base_plus_pc = m_ir->CreateOr(m_ir->CreateShl(m_ir->CreateZExt(m_base_pc, get_type()), 32), m_ir->getInt64(m_pos + 4)); - m_ir->CreateStore(ptr_plus_op, m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_thread, stack0.value), get_type())); - m_ir->CreateStore(base_plus_pc, m_ir->CreateBitCast(m_ir->CreateGEP(get_type(), m_thread, stack1.value), get_type())); + m_ir->CreateStore(ptr_plus_op, m_ir->CreateGEP(get_type(), m_thread, stack0.value)); + m_ir->CreateStore(base_plus_pc, m_ir->CreateGEP(get_type(), m_thread, stack1.value)); } }