[Lldb-commits] [lldb] r242972 - Fix TestReturnValue.py after 242903 changes that added vector register return value tests. These were failing on x86_64 and i386.

Greg Clayton gclayton at apple.com
Wed Jul 22 16:47:29 PDT 2015


Author: gclayton
Date: Wed Jul 22 18:47:29 2015
New Revision: 242972

URL: http://llvm.org/viewvc/llvm-project?rev=242972&view=rev
Log:
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.


Modified:
    lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
    lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp

Modified: lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp?rev=242972&r1=242971&r2=242972&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-i386/ABISysV_i386.cpp Wed Jul 22 18:47:29 2015
@@ -600,13 +600,9 @@ ABISysV_i386::GetReturnValueObjectSimple
         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)
             {
@@ -637,6 +633,45 @@ ABISysV_i386::GetReturnValueObjectSimple
                             }
                         }
                     }
+                }
+                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<DataBufferHeap> 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);
+                                }
+                            }
+                        }
+                    }
                 }
             }
         }

Modified: lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp?rev=242972&r1=242971&r2=242972&view=diff
==============================================================================
--- lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp (original)
+++ lldb/trunk/source/Plugins/ABI/SysV-x86_64/ABISysV_x86_64.cpp Wed Jul 22 18:47:29 2015
@@ -758,15 +758,10 @@ ABISysV_x86_64::GetReturnValueObjectSimp
         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)
@@ -796,6 +791,45 @@ ABISysV_x86_64::GetReturnValueObjectSimp
                             }
                         }
                     }
+                }
+                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<DataBufferHeap> 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);
+                                }
+                            }
+                        }
+                    }
                 }
             }
         }





More information about the lldb-commits mailing list