sga-sc wrote:

Consider compiling this code for RISC-V 64 bit:
```
struct five_int
{
  int one_field;hat software shouldn't assume
  int two_field;
  int three_field;
  int four_field;
  int five_field;
};

struct five_int
return_five_int (struct five_int value)
{
  return value;
}

int main()
{
        struct five_int arg = {10, 20, 30, 40, 50};
        return_five_int(arg);
        return 0;
}
```

The byte size of `struct five_int`'s  is greater than 2*xlen (20 > 16). 
According to the RISC-V calling convention, tells us that in this case return 
value is passed by reference. Caller (`main`) allocates memory on the stack and 
passes the address as an implicit first parameter. Consider that we are LLDB 
and we try to find out what the callee (`return_five_int`) returned after 
stepping out from it. The return value address was stored in a0 at the start of 
callee function. However after the callee's prologue, we can't assume that a0 
holds the same value. There is also a 
[note](https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/104b7dc3fd4bc8900d571905c1902dbb5e3d8a17/riscv-cc.adoc?plain=1#L241)
 in RISC-V ABI about it. 

@lenary @DavidSpickett What should we do in this case? How can we get an access 
to the address of return value?

At this moment I read a1 value and the test passes just by accident.

https://github.com/llvm/llvm-project/pull/163931
_______________________________________________
lldb-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits

Reply via email to