This is an archive of the discontinued LLVM Phabricator instance.

Add a target environment for CoreCLR.
ClosedPublic

Authored by pgavlin on Jul 7 2015, 2:45 PM.

Details

Summary

Although targeting CoreCLR is very similar to targeting MSVC, we expect there to be certain important differences that the backend must be aware of. At the moment, we're only aware of one--stack probes must be emitted differently when targeting CoreCLR--but there are likely to be others.

I'll submit the changes necessary to emit stack probes for CoreCLR in a separate review.

Diff Detail

Repository
rL LLVM

Event Timeline

pgavlin updated this revision to Diff 29212.Jul 7 2015, 2:45 PM
pgavlin retitled this revision from to Add a target environment for CoreCLR..
pgavlin updated this object.
pgavlin added reviewers: rengolin, AndyAyers.
pgavlin set the repository for this revision to rL LLVM.
pgavlin added a subscriber: llvm-commits.
rengolin edited reviewers, added: rnk, nikola, yaron.keren; removed: rengolin.Jul 14 2015, 3:36 AM
nikola accepted this revision.Jul 14 2015, 4:24 AM
nikola edited edge metadata.

I'm a small potato but LGTM.

This revision is now accepted and ready to land.Jul 14 2015, 4:24 AM
rnk edited edge metadata.Jul 14 2015, 8:45 AM

Can you elaborate on the chkstk difference? Various other people like the rust folks have use cases for controlling that, so if that's the only codegen difference, I'd rather not have a new environment. At this point, we have a function attribute "stack-probe-size" that essentially controls the guard page size, and we can easily add another attribute to control the stack check symbol to call. Lots of high level languages want to catch stack overflow and they usually want it to call into their runtime.

AFAIK, the stack probe itself is different on the CLR (additional parameters need to be setup). I do agree with @rnk that it seems a bit excessive to have an entire environment for the minor divergences. Could we get away with squirreling away information in either the DL or as metadata? Unless of course, there are serious divergences that we are overlooking (which would be nice to have called out when we add this new environment).

Currently in LLILC's main branch there's just one use: the CoreCLR has to expand the stack checks inline (both for prolog and in-body cases); there is no library helper available to call.

We also plan to use this environment to provide custom lowering of LLVM operators to special helper methods provided by the CoreCLR (memcpy, int-float conversion, frem, etc). Right now we're lowering to calls early and so missing out on potential optimizations.

We also are using this for some aspects of the EH work we're bringing up.

rnk added a comment.Jul 22 2015, 10:27 AM

Currently in LLILC's main branch there's just one use: the CoreCLR has to expand the stack checks inline (both for prolog and in-body cases); there is no library helper available to call.

We also plan to use this environment to provide custom lowering of LLVM operators to special helper methods provided by the CoreCLR (memcpy, int-float conversion, frem, etc). Right now we're lowering to calls early and so missing out on potential optimizations.

We also are using this for some aspects of the EH work we're bringing up.

OK, this seems like a good use for a string function attribute. To go along with "stack-probe-size", I'm thinking "stack-probe-function". An empty string value means there is no function provided by the runtime, and we need to splat out some ORs or a loop for dynamic alloca.

majnemer accepted this revision.Jul 29 2015, 9:09 AM
majnemer added a reviewer: majnemer.
majnemer added a subscriber: majnemer.

I think it makes sense for this to be its own triple because it will need custom SDAG trickery.

rnk accepted this revision.Aug 3 2015, 10:46 AM
rnk edited edge metadata.

Agreed, if we need to change the lowering of FP operations, like calling a different set of runtime functions, then this should probably be an environment.

pgavlin updated this revision to Diff 32197.Aug 14 2015, 3:36 PM
pgavlin edited edge metadata.

Rebased against latest changes.

This revision was automatically updated to reflect the committed changes.