Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[llvm] Fix LLVM JIT when used with multiple AppDomains. #32219

Merged
merged 1 commit into from
Feb 15, 2020

Conversation

monojenkins
Copy link
Contributor

@monojenkins monojenkins commented Feb 13, 2020

!! This PR is a copy of mono/mono#18824, please do not edit or review it in this repo !!
!! Merge the PR only after the original PR is merged !!



We currently reuse LLVM's command line parsing system to configure and
enable passes. When using the default code generator pass configuration,
the ImplicitNullChecks and X86CallFrameOptimization passes can only
be enabled or disabled via the command line argument parser: the
cl::opts controlling these (and many other) passes are private to
their translation units, and TargetPassConfig/X86PassConfig read
from these cl::opts with no other means to override these values.

Unfortunately, some LLVM command line options have restrictions on the
number of times they may be set, and running the LLVM command line
argument parser more than once can fail, because the 'number of
occurrences' counter is stored in each global cl::opt. This causes
several tests to fail--one such test is unhandled-exception-7.cs.

This change:

  • removes the lazy LLVM JIT initialization logic and instead
    runs this initialization once during mini_init,

  • moves some stray JIT-only code from mini-llvm.c to llvm-jit.cpp,

  • wraps the declarations in domain-internals.h with a
    G_BEGIN_DECLS/G_END_DECLS pair, so that they avoid name
    mangling when included in C++ source, and

  • removes exception_cb and emitted_cb: neither were actually used
    by live code.

We currently reuse LLVM's command line parsing system to configure and
enable passes. When using the default code generator pass configuration,
the `ImplicitNullChecks` and `X86CallFrameOptimization` passes can only
be enabled or disabled via the command line argument parser: the
`cl::opt`s controlling these (and many other) passes are private to
their translation units, and `TargetPassConfig`/`X86PassConfig` read
from these `cl::opt`s with no other means to override these values.

Unfortunately, some LLVM command line options have restrictions on the
number of times they may be set, and running the LLVM command line
argument parser more than once can fail, because the 'number of
occurrences' counter is stored in each global `cl::opt`. This causes
several tests to fail--one such test is unhandled-exception-7.cs.

This change:
- removes the lazy LLVM JIT initialization logic and instead
  runs this initialization once during `mini_init`,

- moves some stray JIT-only code from mini-llvm.c to llvm-jit.cpp,

- wraps the declarations in domain-internals.h with a
  `G_BEGIN_DECLS`/`G_END_DECLS` pair, so that they avoid name
  mangling when included in C++ source, and

- removes `exception_cb` and `emitted_cb`: neither were actually used
  by live code.
@monojenkins monojenkins force-pushed the sync-pr-18824-from-mono branch from 209d74c to 16d40c0 Compare February 14, 2020 19:08
@imhameed imhameed merged commit d4b06b1 into dotnet:master Feb 15, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Dec 10, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants