Add IR fixups for RenderScript ABI mismatch between ARMV7 frontend and x86 backend
authorLuke Drummond <luke.drummond@codeplay.com>
Thu, 28 Jul 2016 14:21:07 +0000 (14:21 +0000)
committerLuke Drummond <luke.drummond@codeplay.com>
Thu, 28 Jul 2016 14:21:07 +0000 (14:21 +0000)
commit19459580afe9ca86af24e71470e7fd413b0852e2
treefb78bf8f9ad3c7b7cb07b5fd7308a62d4cbb0160
parentb1d31ea6bbe3c5e39b54cc69f2fbab43ac52c03a
Add IR fixups for RenderScript ABI mismatch between ARMV7 frontend and x86 backend

Expression evaluation for function calls to certain public RenderScript
API functions in libRSCPURef can segfault.

`slang`,
the compiler frontend for RenderScript embeds an ARM specific triple in
IR that is shipped in the app, after generating IR that has some
assumptions that an ARM device is the target.
As the IR is then compiled on a device of unknown (at time the IR was
generated at least) architecture, when calling RenderScript API function
as part of debugger expressions, we have to perform a fixup pass that
removes those assumptions right before the module is sent to be
generated by the llvm backend.

This issue is caused by multiple problems with the ARMv7-specific
assumptions encoded in the LLVM IR. x86 large value returns use a hidden
first argument (mapping to llvm::Attribute::StructRet), which can't be
picked up by the JIT due to the mismatch between IR generated by the
slang frontend and llvm backend. This means that code generated by bcc
did not necessarily match the default SysV Linux/Android ABI used by the
LLDB JIT

- Original Authors: Luke Drummond (@ldrumm), Function declarations fixed by Aidan Dodds (@ADodds)

Subscribers: lldb-commits

Differential Revision: https://reviews.llvm.org/D18059

llvm-svn: 276976
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/CMakeLists.txt
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.cpp [new file with mode: 0644]
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptExpressionOpts.h [new file with mode: 0644]
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.cpp
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptRuntime.h
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.cpp [new file with mode: 0644]
lldb/source/Plugins/LanguageRuntime/RenderScript/RenderScriptRuntime/RenderScriptx86ABIFixups.h [new file with mode: 0644]