3a6750f246eed4168351786074691e8eeee5b175 |
|
29-Mar-2017 |
David Gross <dgross@google.com> |
Fix for crashes and failures due to 32-bit x86 struct layout. Add explicit padding to structure types, including invokable function parameter structure types. The padding does not change field offset or structure size -- it makes explicit any padding that was implicit due to the ABI. This ensures that if the frontend compiles for an ABI with stricter alignment requirements than the backend compiles for, the frontend and backend will still agree on structure layout (field offset and structure size). This is important for 32-bit x86: The frontend compiles for 32-bit ARM ABI, in which 64-bit scalars are 64-bit aligned; but the 32-bit x86 ABI says that 64-bit scalars are only 32-bit aligned. (Ideally, we would pad only exported structure types; but the most convenient time to insert the padding is as soon as a structure type definition is complete, so that we don't have to modify the AST to update references to the structure's fields. Unfortunately, this is long before we can tell whether or not a structure type is exported.) We had partial fixes for the 32-bit x86 problem in the backend (bcc), but they were incomplete. They compute field offsets according to the ARM layout (thereby compatible with the frontend, including reflected code and Allocation cell size) rather than the x86 layout; but: - A stack-based local variable was allocated according to the (potentially smaller) x86 size rather than the ARM size, whereas field accesses occurred at ARM offsets, potentially spilling off the end of the local variable. - Despite the old fixes, certain analyses/transformations (for example, certain loop optimizations) look at structure sizes and field offsets according to x86 rules rather than ARM rules Also, for the benefit of libbcc change https://android-review.googlesource.com/#/c/358954/ make slang header files available as a module "slang_headers". Bug: http://b/29154200 Bug: http://b/28070272 Test: (aosp_x86_64-eng emulator, full_fugu-eng, aosp_angler-eng) x (RsTest 32-bit, RsTest 64-bit, cts -m RenderscriptTest) tests/slang_test.py lit-tests/run-lit-tests.sh RsTest includes forthcoming additional regression tests: https://android-review.googlesource.com/#/c/299370/ Tried (unmodified slang, modified bcc) and ( modified slang, unmodified bcc) and ( modified slang, modified bcc) By instrumenting modified bcc, confimed that: - Special x8632 layout transformations only run with unmodified slang, and only when test is compiled for x8632. "Modified bcc" is a forthcoming bcc change to turn off the "partial fixes" (x8632 layout transformations) mentioned above, and to verify that front end (Module) and back end (TargetMachine) agree on the layout of every exported struct type: https://android-review.googlesource.com/#/c/299531/ Change-Id: I25aac8e88812b5d3198e99f1929d4908ce663c46 (cherry picked from commit 37dbf5c324322fe2458e63e3fa869fbf903ec6fd)
/frameworks/compile/slang/lit-tests/rs-filecheck-wrapper.sh
|