From 38e874e4877067c28266b11b910333e395123b39 Mon Sep 17 00:00:00 2001 From: Greg Clayton Date: Wed, 22 Jul 2015 23:47:29 +0000 Subject: [PATCH] Fix TestReturnValue.py after 242903 changes that added vector register return value tests. These were failing on x86_64 and i386. It also pointed out an error in our return values where the ABI only relies on xmm registers, not ymm registers for vector return types. llvm-svn: 242972 --- lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp | 47 +++++++++++++++++--- .../Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp | 50 ++++++++++++++++++---- 2 files changed, 83 insertions(+), 14 deletions(-) diff --git a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp index 26da9ae..e8348a8 100644 --- a/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp +++ b/lldb/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp @@ -600,13 +600,9 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread, const size_t byte_size = return_clang_type.GetByteSize(nullptr); if (byte_size > 0) { - const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("ymm0", 0); + const RegisterInfo *vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); if (vec_reg == nullptr) - { - vec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); - if (vec_reg == nullptr) - vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); - } + vec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); if (vec_reg) { @@ -638,6 +634,45 @@ ABISysV_i386::GetReturnValueObjectSimple (Thread &thread, } } } + else if (byte_size <= vec_reg->byte_size*2) + { + const RegisterInfo *vec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0); + if (vec_reg2) + { + ProcessSP process_sp (thread.GetProcess()); + if (process_sp) + { + std::unique_ptr heap_data_ap (new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + RegisterValue reg_value2; + if (reg_ctx->ReadRegister(vec_reg, reg_value) && reg_ctx->ReadRegister(vec_reg2, reg_value2)) + { + + Error error; + if (reg_value.GetAsMemoryData (vec_reg, + heap_data_ap->GetBytes(), + vec_reg->byte_size, + byte_order, + error) && + reg_value2.GetAsMemoryData (vec_reg2, + heap_data_ap->GetBytes() + vec_reg->byte_size, + heap_data_ap->GetByteSize() - vec_reg->byte_size, + byte_order, + error)) + { + DataExtractor data (DataBufferSP (heap_data_ap.release()), + byte_order, + process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create (&thread, + return_clang_type, + ConstString(""), + data); + } + } + } + } + } } } } diff --git a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp index 1d63628..687a08d6 100644 --- a/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp +++ b/lldb/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp @@ -758,15 +758,10 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread, const size_t byte_size = return_clang_type.GetByteSize(nullptr); if (byte_size > 0) { + const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); + if (altivec_reg == nullptr) + altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); - const RegisterInfo *altivec_reg = reg_ctx->GetRegisterInfoByName("ymm0", 0); - if (altivec_reg == NULL) - { - altivec_reg = reg_ctx->GetRegisterInfoByName("xmm0", 0); - if (altivec_reg == NULL) - altivec_reg = reg_ctx->GetRegisterInfoByName("mm0", 0); - } - if (altivec_reg) { if (byte_size <= altivec_reg->byte_size) @@ -797,6 +792,45 @@ ABISysV_x86_64::GetReturnValueObjectSimple (Thread &thread, } } } + else if (byte_size <= altivec_reg->byte_size*2) + { + const RegisterInfo *altivec_reg2 = reg_ctx->GetRegisterInfoByName("xmm1", 0); + if (altivec_reg2) + { + ProcessSP process_sp (thread.GetProcess()); + if (process_sp) + { + std::unique_ptr heap_data_ap (new DataBufferHeap(byte_size, 0)); + const ByteOrder byte_order = process_sp->GetByteOrder(); + RegisterValue reg_value; + RegisterValue reg_value2; + if (reg_ctx->ReadRegister(altivec_reg, reg_value) && reg_ctx->ReadRegister(altivec_reg2, reg_value2)) + { + + Error error; + if (reg_value.GetAsMemoryData (altivec_reg, + heap_data_ap->GetBytes(), + altivec_reg->byte_size, + byte_order, + error) && + reg_value2.GetAsMemoryData (altivec_reg2, + heap_data_ap->GetBytes() + altivec_reg->byte_size, + heap_data_ap->GetByteSize() - altivec_reg->byte_size, + byte_order, + error)) + { + DataExtractor data (DataBufferSP (heap_data_ap.release()), + byte_order, + process_sp->GetTarget().GetArchitecture().GetAddressByteSize()); + return_valobj_sp = ValueObjectConstResult::Create (&thread, + return_clang_type, + ConstString(""), + data); + } + } + } + } + } } } } -- 2.7.4