The ARM64 ABI does not require restoring the memory return register value (x8) on exit from a function, so lldb can't reliably fetch memory return values. We were still trying and that caused a bunch of tests in TestReturnValue to fail. I changed the ABI code to not try to fetch return values for memory returns. I also changed the tests to assert that for all the cases of memory returns we return no value on Darwin arm64, since we shouldn't be guessing...
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
Ach, that's unfortunate. So a caller can allocate space for the return object, pass that address to a callee in x8, but when callee returns, x8 has been overwritten. Agree that this is the only right way to behave.
I don't think this is a peculiarity of the darwin ABI. I'm pretty sure i've ran into this on the "sysv" ABI as well.
If we're going to disallow this, then I think we should do the same for ABISysV_arm64 as well -- it looks like an identical change to ABISysV_arm64 should suffice.
The ABI docs say "you aren't required to restore the value of x8 on function return"... Not all that surprising everybody took the speed over debuggability option.
At Pavel's request I extended this to the SysV_arm64 ABI. Since I don't want to have to guess which arch's are which ABI's, I exposed the ABI plugin's name and then used that in the test.
lldb/source/API/SBTarget.cpp | ||
---|---|---|
1596–1597 | I think ConstString has a ctor that takes a StringRef so you should be able to do ConstString abi_name(target_sp->GetABIName()) directly. |
Yeah, I'm actually pretty fine with this. I dread the day when they start routinely (I think it already happens in a limited fashion) start using ABI's made up on the spot for translation-unit-local functions.
Heh.. one of my reasons for requesting this was to avoid complex logic in the test -- I thought you'd just say that the functionality is not available on all arm64 architectures. Though I suppose having the plugin name around could be useful in general...
I think ConstString has a ctor that takes a StringRef so you should be able to do ConstString abi_name(target_sp->GetABIName()) directly.