This is an archive of the discontinued LLVM Phabricator instance.

LLDB JIT needs android vector passing rules.
ClosedPublic

Authored by srhines on Nov 13 2015, 2:00 AM.

Details

Summary

Looking into some recent issues with LLDBs expression parser highlighted that upstream clang passes vectors types differently to Android Open Source Project's clang for Arm Android targets.
This patch reflects the changes present in the AOSP and allows LLDB's JIT expression evaluation to work correctly for Arm Android targets when passing vectors.

This is submitted with consent of the original author Stephen Hines.

Diff Detail

Repository
rL LLVM

Event Timeline

ADodds updated this revision to Diff 40120.Nov 13 2015, 2:00 AM
ADodds retitled this revision from to LLDB JIT needs android vector passing rules..
ADodds updated this object.
ADodds added reviewers: asl, rsmith.
ADodds set the repository for this revision to rL LLVM.
ADodds added subscribers: pirama, cfe-commits.

Aidan did ask me about upstreaming this particular (reworked) patch from our Android repository, so I did consent to submitting it. I can try to put together a test case for our particular differences.

srhines commandeered this revision.Dec 1 2015, 1:51 PM
srhines added a reviewer: ADodds.

Commandeering, since I am going to upload a version with the updated tests.

srhines updated this revision to Diff 41560.Dec 1 2015, 1:53 PM

Update vector ABI for Android ARM targets.

Summary:
Looking into some recent issues with LLDB's expression parser highlighted that
upstream clang passes vector types differently than the Android Open Source
Project's clang for Arm targets. This patch reflects the changes present in
AOSP and allows LLDB's JIT expression evaluation to work correctly for Arm
Android targets when passing vectors.

This is submitted with consent of the original author Stephen Hines.

Reviewers: asl, rsmith

Subscribers: aemerson, tberghammer, danalbert, srhines, cfe-commits, pirama

Differential Revision: http://reviews.llvm.org/D14639

rnk added a subscriber: rnk.Dec 1 2015, 5:16 PM

Were these changes made to AOSP Clang to match upstream GCC, or some custom Android version of GCC? Where would one go to find ground truth on how these types should be passed?

In D14639#300077, @rnk wrote:

Were these changes made to AOSP Clang to match upstream GCC, or some custom Android version of GCC? Where would one go to find ground truth on how these types should be passed?

These changes are reverting to an existing behavior before it was changed in r166043. This has nothing to do with GCC, and is purely related to Clang/LLVM as used on Android starting with the Honeycomb release in 2011. Android had already shipped APIs that used ARM's original ext-vector calling conventions (which treated them more like homogeneous aggregates). Later on, the ARM ABI was amended to reflect what Apple shipped in this change:

commit 97f81573636068fb9536436188caadf030584e58
Author: Manman Ren <mren@apple.com>
Date:   Tue Oct 16 19:18:39 2012 +0000

    ARM ABI: passing illegal vector types as varargs.
    
    We expand varargs in clang and the call site is handled in the back end, it 
is
    hard to match exactly how illegal vectors are handled in the backend. Theref
ore,
    we legalize the illegal vector types in clang:
    if (Size <= 32), legalize to i32.
    if (Size == 64), legalize to v2i32.
    if (Size == 128), legalize to v4i32.
    if (Size > 128), use indirect.
    
    rdar://12439123
    
    
    git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@166043 91177308-0d34-0410-b5e6-96231b3b80d8

This basically removes the need for a local patch that Android's platform toolchain/NDK has (and will continue to have), while other upstream users of Clang continue to generate potentially broken ext-vector code if they try to build using their own compiler.

rnk accepted this revision.Dec 2 2015, 11:25 AM
rnk added a reviewer: rnk.

Ouch, that 2012 vector passing ABI break is a bummer. :(

lib/CodeGen/TargetInfo.cpp
5236 ↗(On Diff #41560)

I think it would be useful to document that Android effectively shipped APIs compiled with Clang 3.1, so that is the behavior we are trying to match here.

5240 ↗(On Diff #41560)

I'd appreciate the use of isPowerOf2_32() here.

5247 ↗(On Diff #41560)

ditto

This revision is now accepted and ready to land.Dec 2 2015, 11:25 AM
srhines updated this revision to Diff 41654.Dec 2 2015, 11:41 AM
srhines edited edge metadata.

Switched to isPowerOf2_32() and added more details about Android's ABI.

srhines marked 3 inline comments as done.Dec 2 2015, 11:47 AM

I uploaded a fixed version to use isPowerOf2_32() and more comments. Thanks for the reviews.

This revision was automatically updated to reflect the committed changes.