Skip to content

Commit 4393ce6

Browse files
Fix for Test error with latest XED
1 parent fbd8b65 commit 4393ce6

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

lib/Arch/X86/Arch.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -835,23 +835,25 @@ static bool IsAVX512(xed_isa_set_enum_t isa_set, xed_category_enum_t category) {
835835
case XED_ISA_SET_AVX512BW_128N:
836836
case XED_ISA_SET_AVX512BW_256:
837837
case XED_ISA_SET_AVX512BW_512:
838-
case XED_ISA_SET_AVX512BW_KOP:
838+
case XED_ISA_SET_AVX512BW_KOPD:
839+
case XED_ISA_SET_AVX512BW_KOPQ:
839840
case XED_ISA_SET_AVX512CD_128:
840841
case XED_ISA_SET_AVX512CD_256:
841842
case XED_ISA_SET_AVX512CD_512:
842843
case XED_ISA_SET_AVX512DQ_128:
843844
case XED_ISA_SET_AVX512DQ_128N:
844845
case XED_ISA_SET_AVX512DQ_256:
845846
case XED_ISA_SET_AVX512DQ_512:
846-
case XED_ISA_SET_AVX512DQ_KOP:
847+
case XED_ISA_SET_AVX512DQ_KOPB:
848+
case XED_ISA_SET_AVX512DQ_KOPW:
847849
case XED_ISA_SET_AVX512DQ_SCALAR:
848850
case XED_ISA_SET_AVX512ER_512:
849851
case XED_ISA_SET_AVX512ER_SCALAR:
850852
case XED_ISA_SET_AVX512F_128:
851853
case XED_ISA_SET_AVX512F_128N:
852854
case XED_ISA_SET_AVX512F_256:
853855
case XED_ISA_SET_AVX512F_512:
854-
case XED_ISA_SET_AVX512F_KOP:
856+
case XED_ISA_SET_AVX512F_KOPW:
855857
case XED_ISA_SET_AVX512F_SCALAR:
856858
case XED_ISA_SET_AVX512PF_512:
857859
case XED_ISA_SET_AVX512_4FMAPS_512:

lib/BC/InstructionLifter.cpp

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,25 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
593593
auto arg_size = data_layout.getTypeAllocSizeInBits(arg_type);
594594

595595
if (val_size < arg_size) {
596+
// Because of using the latest version of Intex XED we support (which is currently v2025.06.08),
597+
// it reports XMM/YMM registers as vectors instead of integers. When remills tries to extend/truncate
598+
// these values we'll bitcast those vectors into integers
596599
if (arg_type->isIntegerTy()) {
600+
if (val_type->isVectorTy()) {
601+
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
602+
val = new llvm::BitCastInst(val, int_type, llvm::Twine::createNull(), block);
603+
604+
val_type = int_type;
605+
} else if (val_type->isArrayTy()) {
606+
// Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load.
607+
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
608+
auto temp_alloca = new llvm::AllocaInst(val_type, 0, llvm::Twine::createNull(), block);
609+
new llvm::StoreInst(val, temp_alloca, block);
610+
auto int_ptr = new llvm::BitCastInst(temp_alloca, llvm::PointerType::get(int_type, 0),
611+
llvm::Twine::createNull(), block);
612+
val = new llvm::LoadInst(int_type, int_ptr, llvm::Twine::createNull(), block);
613+
val_type = int_type;
614+
}
597615
CHECK(val_type->isIntegerTy())
598616
<< "Expected " << arch_reg.name << " to be an integral type ("
599617
<< "val_type: " << LLVMThingToString(val_type) << ", "
@@ -616,6 +634,22 @@ llvm::Value *InstructionLifter::LiftRegisterOperand(Instruction &inst,
616634

617635
} else if (val_size > arg_size) {
618636
if (arg_type->isIntegerTy()) {
637+
if (val_type->isVectorTy()) {
638+
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
639+
val = new llvm::BitCastInst(val, int_type, llvm::Twine::createNull(), block);
640+
641+
val_type = int_type;
642+
} else if (val_type->isArrayTy()) {
643+
// Arrays cannot be bitcast directly. Store to memory, bitcast pointer, then load.
644+
auto int_type = llvm::Type::getIntNTy(module->getContext(), val_size);
645+
auto temp_alloca = new llvm::AllocaInst(val_type, 0, llvm::Twine::createNull(), block);
646+
new llvm::StoreInst(val, temp_alloca, block);
647+
auto int_ptr = new llvm::BitCastInst(temp_alloca, llvm::PointerType::get(int_type, 0),
648+
llvm::Twine::createNull(), block);
649+
val = new llvm::LoadInst(int_type, int_ptr, llvm::Twine::createNull(), block);
650+
val_type = int_type;
651+
}
652+
619653
CHECK(val_type->isIntegerTy())
620654
<< "Expected " << arch_reg.name << " to be an integral type ("
621655
<< "val_type: " << LLVMThingToString(val_type) << ", "

0 commit comments

Comments
 (0)