This is an archive of the discontinued LLVM Phabricator instance.

ARM: add VLA extension for WoA Itanium ABI
ClosedPublic

Authored by abdulras on Jun 6 2014, 4:06 PM.

Details

Reviewers
t.p.northover
Summary

The armv7-windows-itanium environment is nearly identical to the MSVC ABI. It
has a few divergences, mostly revolving around the use of the Itanium ABI for
C++. VLA support is one of the extensions that are amongst the set of the
extensions.

This adds support for proper VLA emission for this environment. This is
somewhat similar to the handling for chkstk emission on X86 and the large
stack frame emission for ARM. The invocation style for
chkstk is still
controlled via the -mcmodel flag to clang.

Make an explicit note that this is an extension.

Diff Detail

Event Timeline

abdulras updated this revision to Diff 10196.Jun 6 2014, 4:06 PM
abdulras retitled this revision from to ARM: add VLA extension for WoA Itanium ABI.
abdulras updated this object.
abdulras edited the test plan for this revision. (Show Details)
abdulras added a reviewer: t.p.northover.
abdulras set the repository for this revision to rL LLVM.
abdulras added subscribers: compnerd, rnk.
abdulras set the repository for this revision to rL LLVM.Jun 9 2014, 9:23 AM
abdulras added a subscriber: Unknown Object (MLST).
t.p.northover edited edge metadata.Jun 9 2014, 9:40 AM

Hi Saleem,

A couple of minor comments, though it mostly looks reasonable.

Cheers.

Tim.

docs/Extensions.rst
206

I think the ABI for chkstk should be documented somewhere (possibly here and in code, possibly just in code). It looks like it takes and returns a value in r4, preserving all others (except for the inevitable lr).

lib/Target/ARM/ARMISelLowering.cpp
7137

I think an assert or two in this function might be a good idea. At the very least, "isThumb" (instructions that look fine but have the wrong encoding are *really* nasty to track down). Possibly isWindows as well.

7137–7140

I don't think this is tracking R4 properly. This call is effectively an instruction that should have "R4<imp-use,kill>, R4<imp-def>". Otherwise different phases may assume R4 is unchanged in the interval.

Take a look at any normal call to an "i32 @foo(i32)" for a similar example with R0.

lib/Target/ARM/ARMInstrInfo.td
5106

Similarly, this should probably be marked "Defs = [R4]".

t.p.northover added inline comments.Jun 9 2014, 9:54 AM
lib/Target/ARM/ARMInstrInfo.td
5106

Oh no, "Defs = [SP]" probably. Sorry.

abdulras added inline comments.Jun 9 2014, 10:18 AM
lib/Target/ARM/ARMISelLowering.cpp
7137

I like both ideas! Ive had to track down some cases code that looked right but had the wrong encoding - it is nasty to track down :-(.

7137–7140

For some reason, I thought I had this tracking R4 usage; guess not. Good catch!

lib/Target/ARM/ARMInstrInfo.td
5106

Yeah, making this: Uses = [R4], Defs = [R4, SP] seems more precise.

abdulras updated this revision to Diff 10240.Jun 9 2014, 10:19 AM
abdulras edited edge metadata.

Hi Saleem,

This looks better. I don't think the ABI documentation made it in though. And just one more don't-lie-to-LLVM bit during the lowering...

lib/Target/ARM/ARMISelLowering.cpp
7148–7150

This is better, but from what you were saying we should still expect IP to be clobbered (potentially), so you're probably going to need an addRegMask too (with appropriate CSR).

At that point, you'd just as well create an explicit MachineInstrBuilder to share the common code I suspect.

t.p.northover accepted this revision.Jun 9 2014, 10:59 AM
t.p.northover edited edge metadata.

We've discussed the usage of IP offline, and I'm happy this is OK now, provided it's documented.

This revision is now accepted and ready to land.Jun 9 2014, 10:59 AM
abdulras closed this revision.Jun 11 2014, 12:59 PM