2019-07-23 20:34:17 +03:00
|
|
|
#![allow(non_camel_case_types)]
|
|
|
|
#![allow(non_upper_case_globals)]
|
|
|
|
|
2018-05-29 20:41:36 +03:00
|
|
|
use super::debuginfo::{
|
2018-07-04 16:36:49 +03:00
|
|
|
DIArray, DIBasicType, DIBuilder, DICompositeType, DIDerivedType, DIDescriptor, DIEnumerator,
|
2020-02-10 22:52:20 +02:00
|
|
|
DIFile, DIFlags, DIGlobalVariableExpression, DILexicalBlock, DILocation, DINameSpace,
|
|
|
|
DISPFlags, DIScope, DISubprogram, DISubrange, DITemplateTypeParameter, DIType, DIVariable,
|
2023-11-15 23:07:37 -05:00
|
|
|
DebugEmissionKind, DebugNameTableKind,
|
2018-05-29 20:41:36 +03:00
|
|
|
};
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-08-03 00:25:19 +03:00
|
|
|
use libc::{c_char, c_int, c_uint, size_t};
|
2018-07-10 18:00:02 +03:00
|
|
|
use libc::{c_ulonglong, c_void};
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-16 16:02:31 +03:00
|
|
|
use std::marker::PhantomData;
|
2018-06-27 13:12:47 +03:00
|
|
|
|
2018-07-13 14:43:12 +03:00
|
|
|
use super::RustString;
|
2016-08-03 00:25:19 +03:00
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
pub type Bool = c_uint;
|
|
|
|
|
|
|
|
pub const True: Bool = 1 as Bool;
|
|
|
|
pub const False: Bool = 0 as Bool;
|
|
|
|
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2018-07-10 18:00:02 +03:00
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum LLVMRustResult {
|
|
|
|
Success,
|
|
|
|
Failure,
|
|
|
|
}
|
2021-03-08 12:42:54 -08:00
|
|
|
|
|
|
|
// Rust version of the C struct with the same name in rustc_llvm/llvm-wrapper/RustWrapper.cpp.
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct LLVMRustCOFFShortExport {
|
|
|
|
pub name: *const c_char,
|
2021-09-10 17:34:09 -07:00
|
|
|
pub ordinal_present: bool,
|
2022-11-27 11:15:06 +00:00
|
|
|
/// value of `ordinal` only important when `ordinal_present` is true
|
2021-09-10 17:34:09 -07:00
|
|
|
pub ordinal: u16,
|
2021-03-08 12:42:54 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl LLVMRustCOFFShortExport {
|
2021-09-10 17:34:09 -07:00
|
|
|
pub fn new(name: *const c_char, ordinal: Option<u16>) -> LLVMRustCOFFShortExport {
|
|
|
|
LLVMRustCOFFShortExport {
|
|
|
|
name,
|
|
|
|
ordinal_present: ordinal.is_some(),
|
|
|
|
ordinal: ordinal.unwrap_or(0),
|
|
|
|
}
|
2021-03-08 12:42:54 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// Translation of LLVM's MachineTypes enum, defined in llvm\include\llvm\BinaryFormat\COFF.h.
|
|
|
|
///
|
|
|
|
/// We include only architectures supported on Windows.
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum LLVMMachineType {
|
|
|
|
AMD64 = 0x8664,
|
|
|
|
I386 = 0x14c,
|
|
|
|
ARM64 = 0xaa64,
|
Add arm64ec-pc-windows-msvc target
Introduces the `arm64ec-pc-windows-msvc` target for building Arm64EC ("Emulation Compatible") binaries for Windows.
For more information about Arm64EC see <https://learn.microsoft.com/en-us/windows/arm/arm64ec>.
Tier 3 policy:
> A tier 3 target must have a designated developer or developers (the "target maintainers") on record to be CCed when issues arise regarding the target. (The mechanism to track and CC such developers may evolve over time.)
I will be the maintainer for this target.
> Targets must use naming consistent with any existing targets; for instance, a target for the same CPU or OS as an existing Rust target should use the same name for that CPU or OS. Targets should normally use the same names and naming conventions as used elsewhere in the broader ecosystem beyond Rust (such as in other toolchains), unless they have a very good reason to diverge. Changing the name of a target can be highly disruptive, especially once the target reaches a higher tier, so getting the name right is important even for a tier 3 target.
Target uses the `arm64ec` architecture to match LLVM and MSVC, and the `-pc-windows-msvc` suffix to indicate that it targets Windows via the MSVC environment.
> Target names should not introduce undue confusion or ambiguity unless absolutely necessary to maintain ecosystem compatibility. For example, if the name of the target makes people extremely likely to form incorrect beliefs about what it targets, the name should be changed or augmented to disambiguate it.
Target name exactly specifies the type of code that will be produced.
> If possible, use only letters, numbers, dashes and underscores for the name. Periods (.) are known to cause issues in Cargo.
Done.
> Tier 3 targets may have unusual requirements to build or use, but must not create legal issues or impose onerous legal terms for the Rust project or for Rust developers or users.
> The target must not introduce license incompatibilities.
Uses the same dependencies, requirements and licensing as the other `*-pc-windows-msvc` targets.
> Anything added to the Rust repository must be under the standard Rust license (MIT OR Apache-2.0).
Understood.
> The target must not cause the Rust tools or libraries built for any other host (even when supporting cross-compilation to the target) to depend on any new dependency less permissive than the Rust licensing policy. This applies whether the dependency is a Rust crate that would require adding new license exceptions (as specified by the tidy tool in the rust-lang/rust repository), or whether the dependency is a native library or binary. In other words, the introduction of the target must not cause a user installing or running a version of Rust or the Rust tools to be subject to any new license requirements.
> Compiling, linking, and emitting functional binaries, libraries, or other code for the target (whether hosted on the target itself or cross-compiling from another target) must not depend on proprietary (non-FOSS) libraries. Host tools built for the target itself may depend on the ordinary runtime libraries supplied by the platform and commonly used by other applications built for the target, but those libraries must not be required for code generation for the target; cross-compilation to the target must not require such libraries at all. For instance, rustc built for the target may depend on a common proprietary C runtime library or console output library, but must not depend on a proprietary code generation library or code optimization library. Rust's license permits such combinations, but the Rust project has no interest in maintaining such combinations within the scope of Rust itself, even at tier 3.
> "onerous" here is an intentionally subjective term. At a minimum, "onerous" legal/licensing terms include but are not limited to: non-disclosure requirements, non-compete requirements, contributor license agreements (CLAs) or equivalent, "non-commercial"/"research-only"/etc terms, requirements conditional on the employer or employment of any particular Rust developers, revocable terms, any requirements that create liability for the Rust project or its developers or users, or any requirements that adversely affect the livelihood or prospects of the Rust project or its developers or users.
Uses the same dependencies, requirements and licensing as the other `*-pc-windows-msvc` targets.
> Neither this policy nor any decisions made regarding targets shall create any binding agreement or estoppel by any party. If any member of an approving Rust team serves as one of the maintainers of a target, or has any legal or employment requirement (explicit or implicit) that might affect their decisions regarding a target, they must recuse themselves from any approval decisions regarding the target's tier status, though they may otherwise participate in discussions.
> This requirement does not prevent part or all of this policy from being cited in an explicit contract or work agreement (e.g. to implement or maintain support for a target). This requirement exists to ensure that a developer or team responsible for reviewing and approving a target does not face any legal threats or obligations that would prevent them from freely exercising their judgment in such approval, even if such judgment involves subjective matters or goes beyond the letter of these requirements.
Understood, I am not a member of the Rust team.
> Tier 3 targets should attempt to implement as much of the standard libraries as possible and appropriate (core for most targets, alloc for targets that can support dynamic memory allocation, std for targets with an operating system or equivalent layer of system-provided functionality), but may leave some code unimplemented (either unavailable or stubbed out as appropriate), whether because the target makes it impossible to implement or challenging to implement. The authors of pull requests are not obligated to avoid calling any portions of the standard library on the basis of a tier 3 target not implementing those portions.
Both `core` and `alloc` are supported.
Support for `std` dependends on making changes to the standard library, `stdarch` and `backtrace` which cannot be done yet as the bootstrapping compiler raises a warning ("unexpected `cfg` condition value") for `target_arch = "arm64ec"`.
> The target must provide documentation for the Rust community explaining how to build for the target, using cross-compilation if possible. If the target supports running binaries, or running tests (even if they do not pass), the documentation must explain how to run such binaries or tests for the target, using emulation if possible or dedicated hardware if necessary.
Documentation is provided in src/doc/rustc/src/platform-support/arm64ec-pc-windows-msvc.md
> Tier 3 targets must not impose burden on the authors of pull requests, or other developers in the community, to maintain the target. In particular, do not post comments (automated or manual) on a PR that derail or suggest a block on the PR based on a tier 3 target. Do not send automated messages or notifications (via any medium, including via @) to a PR author or others involved with a PR regarding a tier 3 target, unless they have opted into such messages.
> Backlinks such as those generated by the issue/PR tracker when linking to an issue or PR are not considered a violation of this policy, within reason. However, such messages (even on a separate repository) must not generate notifications to anyone involved with a PR who has not requested such notifications.
> Patches adding or updating tier 3 targets must not break any existing tier 2 or tier 1 target, and must not knowingly break another tier 3 target without approval of either the compiler team or the maintainers of the other tier 3 target.
> In particular, this may come up when working on closely related targets, such as variations of the same architecture with different features. Avoid introducing unconditional uses of features that another variation of the target may not have; use conditional compilation or runtime detection, as appropriate, to let each target run code supported by that target.
Understood.
2023-12-15 16:46:34 -08:00
|
|
|
ARM64EC = 0xa641,
|
2021-03-08 12:42:54 -08:00
|
|
|
ARM = 0x01c0,
|
|
|
|
}
|
|
|
|
|
2022-01-19 14:51:59 +00:00
|
|
|
/// LLVM's Module::ModFlagBehavior, defined in llvm/include/llvm/IR/Module.h.
|
|
|
|
///
|
|
|
|
/// When merging modules (e.g. during LTO), their metadata flags are combined. Conflicts are
|
|
|
|
/// resolved according to the merge behaviors specified here. Flags differing only in merge
|
|
|
|
/// behavior are still considered to be in conflict.
|
|
|
|
///
|
|
|
|
/// In order for Rust-C LTO to work, we must specify behaviors compatible with Clang. Notably,
|
|
|
|
/// 'Error' and 'Warning' cannot be mixed for a given flag.
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum LLVMModFlagBehavior {
|
|
|
|
Error = 1,
|
|
|
|
Warning = 2,
|
|
|
|
Require = 3,
|
|
|
|
Override = 4,
|
|
|
|
Append = 5,
|
|
|
|
AppendUnique = 6,
|
|
|
|
Max = 7,
|
2022-12-19 19:06:30 -08:00
|
|
|
Min = 8,
|
2022-01-19 14:51:59 +00:00
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
// Consts for the LLVM CallConv type, pre-cast to usize.
|
|
|
|
|
|
|
|
/// LLVM CallingConv::ID. Should we wrap this?
|
2023-08-26 17:42:59 -07:00
|
|
|
///
|
|
|
|
/// See <https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/IR/CallingConv.h>
|
2016-12-31 04:55:29 +02:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
2016-08-02 23:10:10 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum CallConv {
|
|
|
|
CCallConv = 0,
|
|
|
|
FastCallConv = 8,
|
|
|
|
ColdCallConv = 9,
|
2023-08-26 17:42:59 -07:00
|
|
|
PreserveMost = 14,
|
|
|
|
PreserveAll = 15,
|
|
|
|
Tail = 18,
|
2016-08-02 23:10:10 +03:00
|
|
|
X86StdcallCallConv = 64,
|
|
|
|
X86FastcallCallConv = 65,
|
2016-11-16 17:33:23 -05:00
|
|
|
ArmAapcsCallConv = 67,
|
2016-12-18 23:45:20 -05:00
|
|
|
Msp430Intr = 69,
|
2017-05-17 09:40:46 -04:00
|
|
|
X86_ThisCall = 70,
|
2016-12-22 16:24:29 -05:00
|
|
|
PtxKernel = 71,
|
2016-06-27 02:34:02 +02:00
|
|
|
X86_64_SysV = 78,
|
2016-08-02 23:10:10 +03:00
|
|
|
X86_64_Win64 = 79,
|
2016-10-22 18:37:35 +05:30
|
|
|
X86_VectorCall = 80,
|
2017-02-14 21:39:42 +01:00
|
|
|
X86_Intr = 83,
|
2016-05-06 09:32:10 -04:00
|
|
|
AvrNonBlockingInterrupt = 84,
|
|
|
|
AvrInterrupt = 85,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2016-09-01 13:52:33 -05:00
|
|
|
/// LLVMRustLinkage
|
2021-05-14 03:47:41 +02:00
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
2016-08-02 23:10:10 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum Linkage {
|
|
|
|
ExternalLinkage = 0,
|
|
|
|
AvailableExternallyLinkage = 1,
|
|
|
|
LinkOnceAnyLinkage = 2,
|
|
|
|
LinkOnceODRLinkage = 3,
|
2016-09-01 13:52:33 -05:00
|
|
|
WeakAnyLinkage = 4,
|
|
|
|
WeakODRLinkage = 5,
|
|
|
|
AppendingLinkage = 6,
|
|
|
|
InternalLinkage = 7,
|
|
|
|
PrivateLinkage = 8,
|
|
|
|
ExternalWeakLinkage = 9,
|
|
|
|
CommonLinkage = 10,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2016-11-28 17:44:51 -05:00
|
|
|
// LLVMRustVisibility
|
|
|
|
#[repr(C)]
|
2021-05-25 23:54:07 +02:00
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
2016-11-28 17:44:51 -05:00
|
|
|
pub enum Visibility {
|
|
|
|
Default = 0,
|
|
|
|
Hidden = 1,
|
|
|
|
Protected = 2,
|
|
|
|
}
|
|
|
|
|
2020-03-11 00:00:00 +00:00
|
|
|
/// LLVMUnnamedAddr
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum UnnamedAddr {
|
|
|
|
No,
|
|
|
|
Local,
|
|
|
|
Global,
|
|
|
|
}
|
|
|
|
|
2016-08-03 00:25:19 +03:00
|
|
|
/// LLVMDLLStorageClass
|
2016-08-02 23:10:10 +03:00
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub enum DLLStorageClass {
|
2018-07-10 18:00:02 +03:00
|
|
|
#[allow(dead_code)]
|
2016-10-22 18:37:35 +05:30
|
|
|
Default = 0,
|
|
|
|
DllImport = 1, // Function to be imported from DLL.
|
2018-07-10 18:00:02 +03:00
|
|
|
#[allow(dead_code)]
|
2016-10-22 18:37:35 +05:30
|
|
|
DllExport = 2, // Function to be accessible from DLL.
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2020-07-26 20:11:30 +03:00
|
|
|
/// Matches LLVMRustAttribute in LLVMWrapper.h
|
2016-11-16 23:36:08 +01:00
|
|
|
/// Semantically a subset of the C++ enum llvm::Attribute::AttrKind,
|
|
|
|
/// though it is not ABI compatible (since it's a C++ enum)
|
|
|
|
#[repr(C)]
|
|
|
|
#[derive(Copy, Clone, Debug)]
|
2022-02-21 11:19:16 -05:00
|
|
|
pub enum AttributeKind {
|
2016-11-16 23:36:08 +01:00
|
|
|
AlwaysInline = 0,
|
|
|
|
ByVal = 1,
|
|
|
|
Cold = 2,
|
|
|
|
InlineHint = 3,
|
|
|
|
MinSize = 4,
|
|
|
|
Naked = 5,
|
|
|
|
NoAlias = 6,
|
|
|
|
NoCapture = 7,
|
|
|
|
NoInline = 8,
|
|
|
|
NonNull = 9,
|
|
|
|
NoRedZone = 10,
|
|
|
|
NoReturn = 11,
|
|
|
|
NoUnwind = 12,
|
|
|
|
OptimizeForSize = 13,
|
|
|
|
ReadOnly = 14,
|
|
|
|
SExt = 15,
|
|
|
|
StructRet = 16,
|
|
|
|
UWTable = 17,
|
|
|
|
ZExt = 18,
|
2016-12-21 21:42:10 +03:00
|
|
|
InReg = 19,
|
2016-12-29 23:28:11 -05:00
|
|
|
SanitizeThread = 20,
|
2017-02-03 18:58:47 -05:00
|
|
|
SanitizeAddress = 21,
|
2016-12-29 23:28:11 -05:00
|
|
|
SanitizeMemory = 22,
|
2018-09-26 19:19:55 +03:00
|
|
|
NonLazyBind = 23,
|
2018-10-27 15:29:06 +03:00
|
|
|
OptimizeNone = 24,
|
2020-02-17 21:36:01 +00:00
|
|
|
ReadNone = 26,
|
2021-01-22 18:32:38 -08:00
|
|
|
SanitizeHWAddress = 28,
|
2021-02-20 17:02:23 +01:00
|
|
|
WillReturn = 29,
|
add rustc option for using LLVM stack smash protection
LLVM has built-in heuristics for adding stack canaries to functions. These
heuristics can be selected with LLVM function attributes. This patch adds a
rustc option `-Z stack-protector={none,basic,strong,all}` which controls the use
of these attributes. This gives rustc the same stack smash protection support as
clang offers through options `-fno-stack-protector`, `-fstack-protector`,
`-fstack-protector-strong`, and `-fstack-protector-all`. The protection this can
offer is demonstrated in test/ui/abi/stack-protector.rs. This fills a gap in the
current list of rustc exploit
mitigations (https://doc.rust-lang.org/rustc/exploit-mitigations.html),
originally discussed in #15179.
Stack smash protection adds runtime overhead and is therefore still off by
default, but now users have the option to trade performance for security as they
see fit. An example use case is adding Rust code in an existing C/C++ code base
compiled with stack smash protection. Without the ability to add stack smash
protection to the Rust code, the code base artifacts could be exploitable in
ways not possible if the code base remained pure C/C++.
Stack smash protection support is present in LLVM for almost all the current
tier 1/tier 2 targets: see
test/assembly/stack-protector/stack-protector-target-support.rs. The one
exception is nvptx64-nvidia-cuda. This patch follows clang's example, and adds a
warning message printed if stack smash protection is used with this target (see
test/ui/stack-protector/warn-stack-protector-unsupported.rs). Support for tier 3
targets has not been checked.
Since the heuristics are applied at the LLVM level, the heuristics are expected
to add stack smash protection to a fraction of functions comparable to C/C++.
Some experiments demonstrating how Rust code is affected by the different
heuristics can be found in
test/assembly/stack-protector/stack-protector-heuristics-effect.rs. There is
potential for better heuristics using Rust-specific safety information. For
example it might be reasonable to skip stack smash protection in functions which
transitively only use safe Rust code, or which uses only a subset of functions
the user declares safe (such as anything under `std.*`). Such alternative
heuristics could be added at a later point.
LLVM also offers a "safestack" sanitizer as an alternative way to guard against
stack smashing (see #26612). This could possibly also be included as a
stack-protection heuristic. An alternative is to add it as a sanitizer (#39699).
This is what clang does: safestack is exposed with option
`-fsanitize=safe-stack`.
The options are only supported by the LLVM backend, but as with other codegen
options it is visible in the main codegen option help menu. The heuristic names
"basic", "strong", and "all" are hopefully sufficiently generic to be usable in
other backends as well.
Reviewed-by: Nikita Popov <nikic@php.net>
Extra commits during review:
- [address-review] make the stack-protector option unstable
- [address-review] reduce detail level of stack-protector option help text
- [address-review] correct grammar in comment
- [address-review] use compiler flag to avoid merging functions in test
- [address-review] specify min LLVM version in fortanix stack-protector test
Only for Fortanix test, since this target specifically requests the
`--x86-experimental-lvi-inline-asm-hardening` flag.
- [address-review] specify required LLVM components in stack-protector tests
- move stack protector option enum closer to other similar option enums
- rustc_interface/tests: sort debug option list in tracking hash test
- add an explicit `none` stack-protector option
Revert "set LLVM requirements for all stack protector support test revisions"
This reverts commit a49b74f92a4e7d701d6f6cf63d207a8aff2e0f68.
2021-04-06 21:37:49 +02:00
|
|
|
StackProtectReq = 30,
|
|
|
|
StackProtectStrong = 31,
|
|
|
|
StackProtect = 32,
|
2022-02-05 01:00:37 -05:00
|
|
|
NoUndef = 33,
|
2021-12-03 16:11:13 -05:00
|
|
|
SanitizeMemTag = 34,
|
2022-07-06 19:07:52 -07:00
|
|
|
NoCfCheck = 35,
|
2022-06-17 14:14:58 -04:00
|
|
|
ShadowCallStack = 36,
|
2022-03-21 15:30:54 -04:00
|
|
|
AllocSize = 37,
|
|
|
|
AllocatedPointer = 38,
|
|
|
|
AllocAlign = 39,
|
2023-05-19 19:30:15 -04:00
|
|
|
SanitizeSafeStack = 40,
|
2023-10-18 16:58:17 +02:00
|
|
|
FnRetThunkExtern = 41,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMIntPredicate
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum IntPredicate {
|
|
|
|
IntEQ = 32,
|
|
|
|
IntNE = 33,
|
|
|
|
IntUGT = 34,
|
|
|
|
IntUGE = 35,
|
|
|
|
IntULT = 36,
|
|
|
|
IntULE = 37,
|
|
|
|
IntSGT = 38,
|
|
|
|
IntSGE = 39,
|
|
|
|
IntSLT = 40,
|
|
|
|
IntSLE = 41,
|
|
|
|
}
|
|
|
|
|
2018-08-21 16:31:36 +02:00
|
|
|
impl IntPredicate {
|
2018-10-01 18:07:04 +02:00
|
|
|
pub fn from_generic(intpre: rustc_codegen_ssa::common::IntPredicate) -> Self {
|
2018-08-20 18:16:51 +02:00
|
|
|
match intpre {
|
2018-10-01 18:07:04 +02:00
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntEQ => IntPredicate::IntEQ,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntNE => IntPredicate::IntNE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntUGT => IntPredicate::IntUGT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntUGE => IntPredicate::IntUGE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntULT => IntPredicate::IntULT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntULE => IntPredicate::IntULE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSGT => IntPredicate::IntSGT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSGE => IntPredicate::IntSGE,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSLT => IntPredicate::IntSLT,
|
|
|
|
rustc_codegen_ssa::common::IntPredicate::IntSLE => IntPredicate::IntSLE,
|
2018-08-20 18:16:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMRealPredicate
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum RealPredicate {
|
|
|
|
RealPredicateFalse = 0,
|
|
|
|
RealOEQ = 1,
|
|
|
|
RealOGT = 2,
|
|
|
|
RealOGE = 3,
|
|
|
|
RealOLT = 4,
|
|
|
|
RealOLE = 5,
|
|
|
|
RealONE = 6,
|
|
|
|
RealORD = 7,
|
|
|
|
RealUNO = 8,
|
|
|
|
RealUEQ = 9,
|
|
|
|
RealUGT = 10,
|
|
|
|
RealUGE = 11,
|
|
|
|
RealULT = 12,
|
|
|
|
RealULE = 13,
|
|
|
|
RealUNE = 14,
|
|
|
|
RealPredicateTrue = 15,
|
|
|
|
}
|
|
|
|
|
2021-10-12 00:00:00 +00:00
|
|
|
impl RealPredicate {
|
|
|
|
pub fn from_generic(realp: rustc_codegen_ssa::common::RealPredicate) -> Self {
|
|
|
|
match realp {
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealPredicateFalse => {
|
|
|
|
RealPredicate::RealPredicateFalse
|
|
|
|
}
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOEQ => RealPredicate::RealOEQ,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOGT => RealPredicate::RealOGT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOGE => RealPredicate::RealOGE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOLT => RealPredicate::RealOLT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealOLE => RealPredicate::RealOLE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealONE => RealPredicate::RealONE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealORD => RealPredicate::RealORD,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUNO => RealPredicate::RealUNO,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUEQ => RealPredicate::RealUEQ,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUGT => RealPredicate::RealUGT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUGE => RealPredicate::RealUGE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealULT => RealPredicate::RealULT,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealULE => RealPredicate::RealULE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealUNE => RealPredicate::RealUNE,
|
|
|
|
rustc_codegen_ssa::common::RealPredicate::RealPredicateTrue => {
|
|
|
|
RealPredicate::RealPredicateTrue
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-03 00:25:19 +03:00
|
|
|
/// LLVMTypeKind
|
2016-08-02 23:10:10 +03:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum TypeKind {
|
2016-10-22 18:37:35 +05:30
|
|
|
Void = 0,
|
|
|
|
Half = 1,
|
|
|
|
Float = 2,
|
|
|
|
Double = 3,
|
|
|
|
X86_FP80 = 4,
|
|
|
|
FP128 = 5,
|
2018-09-28 12:18:03 +02:00
|
|
|
PPC_FP128 = 6,
|
2016-10-22 18:37:35 +05:30
|
|
|
Label = 7,
|
|
|
|
Integer = 8,
|
|
|
|
Function = 9,
|
|
|
|
Struct = 10,
|
|
|
|
Array = 11,
|
|
|
|
Pointer = 12,
|
|
|
|
Vector = 13,
|
|
|
|
Metadata = 14,
|
|
|
|
X86_MMX = 15,
|
|
|
|
Token = 16,
|
2020-06-25 18:52:41 -07:00
|
|
|
ScalableVector = 17,
|
|
|
|
BFloat = 18,
|
2020-11-03 22:47:16 +01:00
|
|
|
X86_AMX = 19,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2018-09-07 13:25:50 -07:00
|
|
|
impl TypeKind {
|
2018-10-01 18:07:04 +02:00
|
|
|
pub fn to_generic(self) -> rustc_codegen_ssa::common::TypeKind {
|
2018-09-07 13:25:50 -07:00
|
|
|
match self {
|
2018-10-01 18:07:04 +02:00
|
|
|
TypeKind::Void => rustc_codegen_ssa::common::TypeKind::Void,
|
|
|
|
TypeKind::Half => rustc_codegen_ssa::common::TypeKind::Half,
|
|
|
|
TypeKind::Float => rustc_codegen_ssa::common::TypeKind::Float,
|
|
|
|
TypeKind::Double => rustc_codegen_ssa::common::TypeKind::Double,
|
|
|
|
TypeKind::X86_FP80 => rustc_codegen_ssa::common::TypeKind::X86_FP80,
|
|
|
|
TypeKind::FP128 => rustc_codegen_ssa::common::TypeKind::FP128,
|
|
|
|
TypeKind::PPC_FP128 => rustc_codegen_ssa::common::TypeKind::PPC_FP128,
|
|
|
|
TypeKind::Label => rustc_codegen_ssa::common::TypeKind::Label,
|
|
|
|
TypeKind::Integer => rustc_codegen_ssa::common::TypeKind::Integer,
|
|
|
|
TypeKind::Function => rustc_codegen_ssa::common::TypeKind::Function,
|
|
|
|
TypeKind::Struct => rustc_codegen_ssa::common::TypeKind::Struct,
|
|
|
|
TypeKind::Array => rustc_codegen_ssa::common::TypeKind::Array,
|
|
|
|
TypeKind::Pointer => rustc_codegen_ssa::common::TypeKind::Pointer,
|
|
|
|
TypeKind::Vector => rustc_codegen_ssa::common::TypeKind::Vector,
|
|
|
|
TypeKind::Metadata => rustc_codegen_ssa::common::TypeKind::Metadata,
|
|
|
|
TypeKind::X86_MMX => rustc_codegen_ssa::common::TypeKind::X86_MMX,
|
|
|
|
TypeKind::Token => rustc_codegen_ssa::common::TypeKind::Token,
|
2020-06-25 18:52:41 -07:00
|
|
|
TypeKind::ScalableVector => rustc_codegen_ssa::common::TypeKind::ScalableVector,
|
|
|
|
TypeKind::BFloat => rustc_codegen_ssa::common::TypeKind::BFloat,
|
2020-11-03 22:47:16 +01:00
|
|
|
TypeKind::X86_AMX => rustc_codegen_ssa::common::TypeKind::X86_AMX,
|
2018-09-07 13:25:50 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMAtomicRmwBinOp
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum AtomicRmwBinOp {
|
|
|
|
AtomicXchg = 0,
|
2016-10-22 18:37:35 +05:30
|
|
|
AtomicAdd = 1,
|
|
|
|
AtomicSub = 2,
|
|
|
|
AtomicAnd = 3,
|
2016-08-02 23:10:10 +03:00
|
|
|
AtomicNand = 4,
|
2016-10-22 18:37:35 +05:30
|
|
|
AtomicOr = 5,
|
|
|
|
AtomicXor = 6,
|
|
|
|
AtomicMax = 7,
|
|
|
|
AtomicMin = 8,
|
2016-08-02 23:10:10 +03:00
|
|
|
AtomicUMax = 9,
|
|
|
|
AtomicUMin = 10,
|
|
|
|
}
|
|
|
|
|
2018-08-21 17:54:12 +02:00
|
|
|
impl AtomicRmwBinOp {
|
2018-10-01 18:07:04 +02:00
|
|
|
pub fn from_generic(op: rustc_codegen_ssa::common::AtomicRmwBinOp) -> Self {
|
2018-08-21 17:54:12 +02:00
|
|
|
match op {
|
2018-10-01 18:07:04 +02:00
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXchg => AtomicRmwBinOp::AtomicXchg,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAdd => AtomicRmwBinOp::AtomicAdd,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicSub => AtomicRmwBinOp::AtomicSub,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicAnd => AtomicRmwBinOp::AtomicAnd,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicNand => AtomicRmwBinOp::AtomicNand,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicOr => AtomicRmwBinOp::AtomicOr,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicXor => AtomicRmwBinOp::AtomicXor,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMax => AtomicRmwBinOp::AtomicMax,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicMin => AtomicRmwBinOp::AtomicMin,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMax => AtomicRmwBinOp::AtomicUMax,
|
|
|
|
rustc_codegen_ssa::common::AtomicRmwBinOp::AtomicUMin => AtomicRmwBinOp::AtomicUMin,
|
2018-08-21 17:54:12 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMAtomicOrdering
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum AtomicOrdering {
|
2018-07-10 18:00:02 +03:00
|
|
|
#[allow(dead_code)]
|
2016-08-02 23:10:10 +03:00
|
|
|
NotAtomic = 0,
|
|
|
|
Unordered = 1,
|
|
|
|
Monotonic = 2,
|
|
|
|
// Consume = 3, // Not specified yet.
|
|
|
|
Acquire = 4,
|
|
|
|
Release = 5,
|
|
|
|
AcquireRelease = 6,
|
2016-10-22 18:37:35 +05:30
|
|
|
SequentiallyConsistent = 7,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2018-08-21 18:08:20 +02:00
|
|
|
impl AtomicOrdering {
|
2018-10-01 18:07:04 +02:00
|
|
|
pub fn from_generic(ao: rustc_codegen_ssa::common::AtomicOrdering) -> Self {
|
2018-08-21 18:08:20 +02:00
|
|
|
match ao {
|
2018-10-01 18:07:04 +02:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Unordered => AtomicOrdering::Unordered,
|
2022-05-24 00:00:00 +00:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Relaxed => AtomicOrdering::Monotonic,
|
2018-10-01 18:07:04 +02:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Acquire => AtomicOrdering::Acquire,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::Release => AtomicOrdering::Release,
|
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::AcquireRelease => {
|
2018-09-28 12:18:03 +02:00
|
|
|
AtomicOrdering::AcquireRelease
|
2019-12-22 17:42:04 -05:00
|
|
|
}
|
2018-10-01 18:07:04 +02:00
|
|
|
rustc_codegen_ssa::common::AtomicOrdering::SequentiallyConsistent => {
|
2018-08-21 18:08:20 +02:00
|
|
|
AtomicOrdering::SequentiallyConsistent
|
2019-12-22 17:42:04 -05:00
|
|
|
}
|
2018-08-21 18:08:20 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMRustFileType
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum FileType {
|
|
|
|
AssemblyFile,
|
|
|
|
ObjectFile,
|
|
|
|
}
|
|
|
|
|
2016-09-01 13:52:33 -05:00
|
|
|
/// LLVMMetadataType
|
2016-08-02 23:10:10 +03:00
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum MetadataType {
|
|
|
|
MD_dbg = 0,
|
|
|
|
MD_tbaa = 1,
|
|
|
|
MD_prof = 2,
|
|
|
|
MD_fpmath = 3,
|
|
|
|
MD_range = 4,
|
|
|
|
MD_tbaa_struct = 5,
|
|
|
|
MD_invariant_load = 6,
|
|
|
|
MD_alias_scope = 7,
|
|
|
|
MD_noalias = 8,
|
|
|
|
MD_nontemporal = 9,
|
|
|
|
MD_mem_parallel_loop_access = 10,
|
|
|
|
MD_nonnull = 11,
|
2022-02-15 23:45:09 -05:00
|
|
|
MD_align = 17,
|
2021-10-07 15:33:13 -07:00
|
|
|
MD_type = 19,
|
2022-04-21 14:02:54 +01:00
|
|
|
MD_vcall_visibility = 28,
|
2022-02-12 14:01:33 -05:00
|
|
|
MD_noundef = 29,
|
2022-11-21 21:29:00 -08:00
|
|
|
MD_kcfi_type = 36,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2016-08-03 00:25:19 +03:00
|
|
|
/// LLVMRustAsmDialect
|
2022-01-12 00:00:00 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum AsmDialect {
|
2016-08-03 00:25:19 +03:00
|
|
|
Att,
|
|
|
|
Intel,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustCodeGenOptLevel
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum CodeGenOptLevel {
|
|
|
|
None,
|
|
|
|
Less,
|
|
|
|
Default,
|
|
|
|
Aggressive,
|
|
|
|
}
|
|
|
|
|
2020-01-05 19:16:58 +01:00
|
|
|
/// LLVMRustPassBuilderOptLevel
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum PassBuilderOptLevel {
|
|
|
|
O0,
|
|
|
|
O1,
|
|
|
|
O2,
|
|
|
|
O3,
|
|
|
|
Os,
|
|
|
|
Oz,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustOptStage
|
|
|
|
#[derive(PartialEq)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum OptStage {
|
|
|
|
PreLinkNoLTO,
|
|
|
|
PreLinkThinLTO,
|
|
|
|
PreLinkFatLTO,
|
|
|
|
ThinLTO,
|
|
|
|
FatLTO,
|
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustSanitizerOptions
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct SanitizerOptions {
|
|
|
|
pub sanitize_address: bool,
|
2020-06-14 00:00:00 +00:00
|
|
|
pub sanitize_address_recover: bool,
|
2023-07-11 16:19:42 -07:00
|
|
|
pub sanitize_cfi: bool,
|
2024-02-01 13:16:30 -08:00
|
|
|
pub sanitize_dataflow: bool,
|
|
|
|
pub sanitize_dataflow_abilist: *const *const c_char,
|
|
|
|
pub sanitize_dataflow_abilist_len: size_t,
|
2023-07-11 16:19:42 -07:00
|
|
|
pub sanitize_kcfi: bool,
|
2020-06-14 00:00:00 +00:00
|
|
|
pub sanitize_memory: bool,
|
|
|
|
pub sanitize_memory_recover: bool,
|
2020-01-05 19:16:58 +01:00
|
|
|
pub sanitize_memory_track_origins: c_int,
|
2020-06-14 00:00:00 +00:00
|
|
|
pub sanitize_thread: bool,
|
2021-01-22 18:32:38 -08:00
|
|
|
pub sanitize_hwaddress: bool,
|
|
|
|
pub sanitize_hwaddress_recover: bool,
|
2022-09-11 19:36:19 -04:00
|
|
|
pub sanitize_kernel_address: bool,
|
|
|
|
pub sanitize_kernel_address_recover: bool,
|
2020-01-05 19:16:58 +01:00
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMRelocMode
|
|
|
|
#[derive(Copy, Clone, PartialEq)]
|
|
|
|
#[repr(C)]
|
2020-04-23 20:49:00 +03:00
|
|
|
pub enum RelocModel {
|
2017-04-28 17:21:59 -05:00
|
|
|
Static,
|
|
|
|
PIC,
|
|
|
|
DynamicNoPic,
|
|
|
|
ROPI,
|
|
|
|
RWPI,
|
|
|
|
ROPI_RWPI,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustCodeModel
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum CodeModel {
|
2020-05-07 03:34:27 +03:00
|
|
|
Tiny,
|
2016-08-02 23:10:10 +03:00
|
|
|
Small,
|
|
|
|
Kernel,
|
|
|
|
Medium,
|
|
|
|
Large,
|
2018-01-22 17:01:36 -08:00
|
|
|
None,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMRustDiagnosticKind
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2018-07-10 18:00:02 +03:00
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum DiagnosticKind {
|
|
|
|
Other,
|
|
|
|
InlineAsm,
|
|
|
|
StackSize,
|
|
|
|
DebugMetadataVersion,
|
|
|
|
SampleProfile,
|
|
|
|
OptimizationRemark,
|
|
|
|
OptimizationRemarkMissed,
|
|
|
|
OptimizationRemarkAnalysis,
|
|
|
|
OptimizationRemarkAnalysisFPCommute,
|
|
|
|
OptimizationRemarkAnalysisAliasing,
|
|
|
|
OptimizationRemarkOther,
|
|
|
|
OptimizationFailure,
|
2018-03-12 18:11:59 +01:00
|
|
|
PGOProfile,
|
2018-07-17 16:20:51 -07:00
|
|
|
Linker,
|
2020-09-29 12:20:56 +01:00
|
|
|
Unsupported,
|
2021-07-28 21:31:47 +02:00
|
|
|
SrcMgr,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2020-06-09 14:37:59 +01:00
|
|
|
/// LLVMRustDiagnosticLevel
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
#[allow(dead_code)] // Variants constructed by C++.
|
|
|
|
pub enum DiagnosticLevel {
|
|
|
|
Error,
|
|
|
|
Warning,
|
|
|
|
Note,
|
|
|
|
Remark,
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// LLVMRustArchiveKind
|
|
|
|
#[derive(Copy, Clone)]
|
2016-08-03 00:25:19 +03:00
|
|
|
#[repr(C)]
|
2016-08-02 23:10:10 +03:00
|
|
|
pub enum ArchiveKind {
|
|
|
|
K_GNU,
|
|
|
|
K_BSD,
|
2020-02-12 12:06:14 +01:00
|
|
|
K_DARWIN,
|
2016-08-02 23:10:10 +03:00
|
|
|
K_COFF,
|
2023-01-11 11:27:29 +08:00
|
|
|
K_AIXBIG,
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
2016-08-03 00:25:19 +03:00
|
|
|
|
2022-03-02 17:58:33 +01:00
|
|
|
// LLVMRustThinLTOData
|
2018-06-27 13:12:47 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type ThinLTOData;
|
|
|
|
}
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
|
2022-03-02 17:58:33 +01:00
|
|
|
// LLVMRustThinLTOBuffer
|
2018-06-27 13:12:47 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type ThinLTOBuffer;
|
|
|
|
}
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
|
|
|
|
/// LLVMRustThinLTOModule
|
|
|
|
#[repr(C)]
|
|
|
|
pub struct ThinLTOModule {
|
|
|
|
pub identifier: *const c_char,
|
|
|
|
pub data: *const u8,
|
|
|
|
pub len: usize,
|
|
|
|
}
|
|
|
|
|
2017-10-31 18:24:04 +00:00
|
|
|
/// LLVMThreadLocalMode
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum ThreadLocalMode {
|
|
|
|
NotThreadLocal,
|
|
|
|
GeneralDynamic,
|
|
|
|
LocalDynamic,
|
|
|
|
InitialExec,
|
|
|
|
LocalExec,
|
|
|
|
}
|
|
|
|
|
2023-05-09 10:02:59 +00:00
|
|
|
/// LLVMRustTailCallKind
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum TailCallKind {
|
|
|
|
None,
|
|
|
|
Tail,
|
|
|
|
MustTail,
|
|
|
|
NoTail,
|
|
|
|
}
|
|
|
|
|
2020-03-30 22:17:15 -07:00
|
|
|
/// LLVMRustChecksumKind
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum ChecksumKind {
|
|
|
|
None,
|
|
|
|
MD5,
|
|
|
|
SHA1,
|
2020-10-13 08:41:06 -07:00
|
|
|
SHA256,
|
2020-03-30 22:17:15 -07:00
|
|
|
}
|
|
|
|
|
2022-11-04 16:20:42 +00:00
|
|
|
/// LLVMRustMemoryEffects
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum MemoryEffects {
|
|
|
|
None,
|
|
|
|
ReadOnly,
|
|
|
|
InaccessibleMemOnly,
|
|
|
|
}
|
|
|
|
|
2018-07-16 16:02:31 +03:00
|
|
|
extern "C" {
|
|
|
|
type Opaque;
|
|
|
|
}
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
2018-07-16 16:02:31 +03:00
|
|
|
struct InvariantOpaque<'a> {
|
|
|
|
_marker: PhantomData<&'a mut &'a ()>,
|
|
|
|
_opaque: Opaque,
|
|
|
|
}
|
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
// Opaque pointer types
|
2018-06-27 17:57:25 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Module;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type Context;
|
|
|
|
}
|
2018-07-02 17:52:53 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Type;
|
|
|
|
}
|
2018-07-05 13:38:44 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Value;
|
|
|
|
}
|
2019-10-13 12:19:14 +02:00
|
|
|
extern "C" {
|
|
|
|
pub type ConstantInt;
|
|
|
|
}
|
2022-02-21 11:19:16 -05:00
|
|
|
extern "C" {
|
|
|
|
pub type Attribute;
|
|
|
|
}
|
2018-07-04 16:36:49 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Metadata;
|
|
|
|
}
|
2018-07-05 13:38:44 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type BasicBlock;
|
|
|
|
}
|
2018-07-17 18:33:09 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct Builder<'a>(InvariantOpaque<'a>);
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
2018-07-17 14:17:47 +03:00
|
|
|
pub struct PassManager<'a>(InvariantOpaque<'a>);
|
2018-07-05 13:38:44 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Pass;
|
|
|
|
}
|
2018-06-27 17:57:25 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type TargetMachine;
|
|
|
|
}
|
2018-07-05 13:38:44 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Archive;
|
|
|
|
}
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
2018-07-17 14:31:06 +03:00
|
|
|
pub struct ArchiveIterator<'a>(InvariantOpaque<'a>);
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct ArchiveChild<'a>(InvariantOpaque<'a>);
|
2018-07-05 13:38:44 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type Twine;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type DiagnosticInfo;
|
|
|
|
}
|
|
|
|
extern "C" {
|
|
|
|
pub type SMDiagnostic;
|
|
|
|
}
|
2018-07-17 16:00:10 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct RustArchiveMember<'a>(InvariantOpaque<'a>);
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
2018-07-16 16:02:31 +03:00
|
|
|
pub struct OperandBundleDef<'a>(InvariantOpaque<'a>);
|
2018-07-17 15:02:11 +03:00
|
|
|
#[repr(C)]
|
2018-07-17 14:26:22 +03:00
|
|
|
pub struct Linker<'a>(InvariantOpaque<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-11-12 00:00:00 +00:00
|
|
|
extern "C" {
|
|
|
|
pub type DiagnosticHandler;
|
|
|
|
}
|
|
|
|
|
|
|
|
pub type DiagnosticHandlerTy = unsafe extern "C" fn(&DiagnosticInfo, *mut c_void);
|
|
|
|
pub type InlineAsmDiagHandlerTy = unsafe extern "C" fn(&SMDiagnostic, *const c_void, c_uint);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
|
|
|
pub mod debuginfo {
|
2018-07-17 18:45:33 +03:00
|
|
|
use super::{InvariantOpaque, Metadata};
|
2019-10-22 08:51:35 -07:00
|
|
|
use bitflags::bitflags;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-17 18:45:33 +03:00
|
|
|
#[repr(C)]
|
|
|
|
pub struct DIBuilder<'a>(InvariantOpaque<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-04 16:36:49 +03:00
|
|
|
pub type DIDescriptor = Metadata;
|
2020-02-10 22:52:20 +02:00
|
|
|
pub type DILocation = Metadata;
|
2018-07-04 16:36:49 +03:00
|
|
|
pub type DIScope = DIDescriptor;
|
2016-08-02 23:10:10 +03:00
|
|
|
pub type DIFile = DIScope;
|
|
|
|
pub type DILexicalBlock = DIScope;
|
|
|
|
pub type DISubprogram = DIScope;
|
|
|
|
pub type DINameSpace = DIScope;
|
2018-07-04 16:36:49 +03:00
|
|
|
pub type DIType = DIDescriptor;
|
2016-08-02 23:10:10 +03:00
|
|
|
pub type DIBasicType = DIType;
|
|
|
|
pub type DIDerivedType = DIType;
|
|
|
|
pub type DICompositeType = DIDerivedType;
|
|
|
|
pub type DIVariable = DIDescriptor;
|
2018-09-14 19:06:45 +03:00
|
|
|
pub type DIGlobalVariableExpression = DIDescriptor;
|
2018-07-04 16:36:49 +03:00
|
|
|
pub type DIArray = DIDescriptor;
|
2016-08-02 23:10:10 +03:00
|
|
|
pub type DISubrange = DIDescriptor;
|
|
|
|
pub type DIEnumerator = DIDescriptor;
|
|
|
|
pub type DITemplateTypeParameter = DIDescriptor;
|
|
|
|
|
2016-11-18 17:15:14 -05:00
|
|
|
// These values **must** match with LLVMRustDIFlags!!
|
|
|
|
bitflags! {
|
2019-06-16 02:53:33 +02:00
|
|
|
#[repr(transparent)]
|
2023-12-30 17:09:02 +01:00
|
|
|
#[derive(Clone, Copy, Default)]
|
2019-06-01 14:21:38 +02:00
|
|
|
pub struct DIFlags: u32 {
|
2017-09-08 15:08:01 -04:00
|
|
|
const FlagZero = 0;
|
|
|
|
const FlagPrivate = 1;
|
|
|
|
const FlagProtected = 2;
|
|
|
|
const FlagPublic = 3;
|
|
|
|
const FlagFwdDecl = (1 << 2);
|
|
|
|
const FlagAppleBlock = (1 << 3);
|
|
|
|
const FlagBlockByrefStruct = (1 << 4);
|
|
|
|
const FlagVirtual = (1 << 5);
|
|
|
|
const FlagArtificial = (1 << 6);
|
|
|
|
const FlagExplicit = (1 << 7);
|
|
|
|
const FlagPrototyped = (1 << 8);
|
|
|
|
const FlagObjcClassComplete = (1 << 9);
|
|
|
|
const FlagObjectPointer = (1 << 10);
|
|
|
|
const FlagVector = (1 << 11);
|
|
|
|
const FlagStaticMember = (1 << 12);
|
|
|
|
const FlagLValueReference = (1 << 13);
|
|
|
|
const FlagRValueReference = (1 << 14);
|
2018-01-20 14:32:33 -06:00
|
|
|
const FlagExternalTypeRef = (1 << 15);
|
|
|
|
const FlagIntroducedVirtual = (1 << 18);
|
|
|
|
const FlagBitField = (1 << 19);
|
|
|
|
const FlagNoReturn = (1 << 20);
|
2016-11-18 17:15:14 -05:00
|
|
|
}
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
2019-01-16 09:59:03 -08:00
|
|
|
|
|
|
|
// These values **must** match with LLVMRustDISPFlags!!
|
|
|
|
bitflags! {
|
2019-06-16 02:53:33 +02:00
|
|
|
#[repr(transparent)]
|
2023-12-30 17:09:02 +01:00
|
|
|
#[derive(Clone, Copy, Default)]
|
2019-06-01 14:21:38 +02:00
|
|
|
pub struct DISPFlags: u32 {
|
2019-01-16 09:59:03 -08:00
|
|
|
const SPFlagZero = 0;
|
|
|
|
const SPFlagVirtual = 1;
|
|
|
|
const SPFlagPureVirtual = 2;
|
|
|
|
const SPFlagLocalToUnit = (1 << 2);
|
|
|
|
const SPFlagDefinition = (1 << 3);
|
|
|
|
const SPFlagOptimized = (1 << 4);
|
2019-04-04 13:05:41 -07:00
|
|
|
const SPFlagMainSubprogram = (1 << 5);
|
2019-01-16 09:59:03 -08:00
|
|
|
}
|
|
|
|
}
|
2019-01-22 13:01:14 -08:00
|
|
|
|
|
|
|
/// LLVMRustDebugEmissionKind
|
|
|
|
#[derive(Copy, Clone)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum DebugEmissionKind {
|
|
|
|
NoDebug,
|
|
|
|
FullDebug,
|
|
|
|
LineTablesOnly,
|
2021-04-06 16:00:35 -04:00
|
|
|
DebugDirectivesOnly,
|
2019-01-22 13:01:14 -08:00
|
|
|
}
|
|
|
|
|
|
|
|
impl DebugEmissionKind {
|
2020-03-11 12:49:08 +01:00
|
|
|
pub fn from_generic(kind: rustc_session::config::DebugInfo) -> Self {
|
2021-09-03 13:00:39 -04:00
|
|
|
// We should be setting LLVM's emission kind to `LineTablesOnly` if
|
|
|
|
// we are compiling with "limited" debuginfo. However, some of the
|
|
|
|
// existing tools relied on slightly more debuginfo being generated than
|
|
|
|
// would be the case with `LineTablesOnly`, and we did not want to break
|
|
|
|
// these tools in a "drive-by fix", without a good idea or plan about
|
|
|
|
// what limited debuginfo should exactly look like. So for now we are
|
|
|
|
// instead adding a new debuginfo option "line-tables-only" so as to
|
|
|
|
// not break anything and to allow users to have 'limited' debug info.
|
|
|
|
//
|
|
|
|
// See https://github.com/rust-lang/rust/issues/60020 for details.
|
2020-03-11 12:49:08 +01:00
|
|
|
use rustc_session::config::DebugInfo;
|
2019-01-22 13:01:14 -08:00
|
|
|
match kind {
|
|
|
|
DebugInfo::None => DebugEmissionKind::NoDebug,
|
2021-04-06 16:00:35 -04:00
|
|
|
DebugInfo::LineDirectivesOnly => DebugEmissionKind::DebugDirectivesOnly,
|
|
|
|
DebugInfo::LineTablesOnly => DebugEmissionKind::LineTablesOnly,
|
|
|
|
DebugInfo::Limited | DebugInfo::Full => DebugEmissionKind::FullDebug,
|
2019-01-22 13:01:14 -08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2023-11-15 23:07:37 -05:00
|
|
|
|
|
|
|
/// LLVMRustDebugNameTableKind
|
|
|
|
#[derive(Clone, Copy)]
|
|
|
|
#[repr(C)]
|
|
|
|
pub enum DebugNameTableKind {
|
|
|
|
Default,
|
|
|
|
Gnu,
|
|
|
|
None,
|
|
|
|
}
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|
|
|
|
|
2022-03-21 15:30:54 -04:00
|
|
|
use bitflags::bitflags;
|
|
|
|
// These values **must** match with LLVMRustAllocKindFlags
|
|
|
|
bitflags! {
|
|
|
|
#[repr(transparent)]
|
|
|
|
#[derive(Default)]
|
|
|
|
pub struct AllocKindFlags : u64 {
|
|
|
|
const Unknown = 0;
|
|
|
|
const Alloc = 1;
|
|
|
|
const Realloc = 1 << 1;
|
|
|
|
const Free = 1 << 2;
|
|
|
|
const Uninitialized = 1 << 3;
|
|
|
|
const Zeroed = 1 << 4;
|
|
|
|
const Aligned = 1 << 5;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-06-27 13:12:47 +03:00
|
|
|
extern "C" {
|
|
|
|
pub type ModuleBuffer;
|
|
|
|
}
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2020-02-11 22:37:16 +01:00
|
|
|
pub type SelfProfileBeforePassCallback =
|
|
|
|
unsafe extern "C" fn(*mut c_void, *const c_char, *const c_char);
|
|
|
|
pub type SelfProfileAfterPassCallback = unsafe extern "C" fn(*mut c_void);
|
|
|
|
|
2022-05-28 10:43:51 +00:00
|
|
|
pub type GetSymbolsCallback = unsafe extern "C" fn(*mut c_void, *const c_char) -> *mut c_void;
|
|
|
|
pub type GetSymbolsErrorCallback = unsafe extern "C" fn(*const c_char) -> *mut c_void;
|
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
extern "C" {
|
|
|
|
// Create and destroy contexts.
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMContextDispose(C: &'static mut Context);
|
|
|
|
pub fn LLVMGetMDKindIDInContext(C: &Context, Name: *const c_char, SLen: c_uint) -> c_uint;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-06-27 17:57:25 +03:00
|
|
|
// Create modules.
|
|
|
|
pub fn LLVMModuleCreateWithNameInContext(ModuleID: *const c_char, C: &Context) -> &Module;
|
|
|
|
pub fn LLVMGetModuleContext(M: &Module) -> &Context;
|
|
|
|
pub fn LLVMCloneModule(M: &Module) -> &Module;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
|
|
|
/// Data layout. See Module::getDataLayout.
|
2020-03-11 00:00:00 +00:00
|
|
|
pub fn LLVMGetDataLayoutStr(M: &Module) -> *const c_char;
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMSetDataLayout(M: &Module, Triple: *const c_char);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
|
|
|
/// See Module::setModuleInlineAsm.
|
2023-04-02 18:26:48 +03:00
|
|
|
pub fn LLVMAppendModuleInlineAsm(M: &Module, Asm: *const c_char, Len: size_t);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on integer types
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMInt1TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt8TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt16TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt32TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMInt64TypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMIntTypeInContext(C: &Context, NumBits: c_uint) -> &Type;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMGetIntTypeWidth(IntegerTy: &Type) -> c_uint;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on real types
|
2024-02-28 03:44:23 -05:00
|
|
|
pub fn LLVMHalfTypeInContext(C: &Context) -> &Type;
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMFloatTypeInContext(C: &Context) -> &Type;
|
|
|
|
pub fn LLVMDoubleTypeInContext(C: &Context) -> &Type;
|
2024-02-28 03:44:23 -05:00
|
|
|
pub fn LLVMFP128TypeInContext(C: &Context) -> &Type;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on function types
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMFunctionType<'a>(
|
2018-07-02 17:52:53 +03:00
|
|
|
ReturnType: &'a Type,
|
|
|
|
ParamTypes: *const &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
ParamCount: c_uint,
|
|
|
|
IsVarArg: Bool,
|
2018-07-02 17:52:53 +03:00
|
|
|
) -> &'a Type;
|
|
|
|
pub fn LLVMCountParamTypes(FunctionTy: &Type) -> c_uint;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMGetParamTypes<'a>(FunctionTy: &'a Type, Dest: *mut &'a Type);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on struct types
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMStructTypeInContext<'a>(
|
2018-07-02 17:52:53 +03:00
|
|
|
C: &'a Context,
|
|
|
|
ElementTypes: *const &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool,
|
2018-07-02 17:52:53 +03:00
|
|
|
) -> &'a Type;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on array, pointer, and vector types (sequence types)
|
2022-12-06 00:07:28 -05:00
|
|
|
pub fn LLVMPointerTypeInContext(C: &Context, AddressSpace: c_uint) -> &Type;
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMVectorType(ElementType: &Type, ElementCount: c_uint) -> &Type;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMGetElementType(Ty: &Type) -> &Type;
|
|
|
|
pub fn LLVMGetVectorSize(VectorTy: &Type) -> c_uint;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on other types
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMVoidTypeInContext(C: &Context) -> &Type;
|
2023-05-01 19:22:54 +00:00
|
|
|
pub fn LLVMTokenTypeInContext(C: &Context) -> &Type;
|
2023-04-02 18:26:48 +03:00
|
|
|
pub fn LLVMMetadataTypeInContext(C: &Context) -> &Type;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on all values
|
2018-07-05 13:38:44 +03:00
|
|
|
pub fn LLVMTypeOf(Val: &Value) -> &Type;
|
2019-12-04 12:00:28 -08:00
|
|
|
pub fn LLVMGetValueName2(Val: &Value, Length: *mut size_t) -> *const c_char;
|
|
|
|
pub fn LLVMSetValueName2(Val: &Value, Name: *const c_char, NameLen: size_t);
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMReplaceAllUsesWith<'a>(OldVal: &'a Value, NewVal: &'a Value);
|
|
|
|
pub fn LLVMSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Node: &'a Value);
|
|
|
|
pub fn LLVMGlobalSetMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
|
|
|
|
pub fn LLVMValueAsMetadata(Node: &Value) -> &Metadata;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on constants of any type
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMConstNull(Ty: &Type) -> &Value;
|
|
|
|
pub fn LLVMGetUndef(Ty: &Type) -> &Value;
|
2023-03-16 14:56:02 +01:00
|
|
|
pub fn LLVMGetPoison(Ty: &Type) -> &Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on metadata
|
2023-04-02 17:11:41 +03:00
|
|
|
// FIXME: deprecated, replace with LLVMMDStringInContext2
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMMDStringInContext(C: &Context, Str: *const c_char, SLen: c_uint) -> &Value;
|
2023-04-02 17:11:41 +03:00
|
|
|
|
|
|
|
pub fn LLVMMDStringInContext2(C: &Context, Str: *const c_char, SLen: size_t) -> &Metadata;
|
|
|
|
|
|
|
|
// FIXME: deprecated, replace with LLVMMDNodeInContext2
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMMDNodeInContext<'a>(
|
|
|
|
C: &'a Context,
|
|
|
|
Vals: *const &'a Value,
|
|
|
|
Count: c_uint,
|
|
|
|
) -> &'a Value;
|
2022-04-21 14:02:54 +01:00
|
|
|
pub fn LLVMMDNodeInContext2<'a>(
|
|
|
|
C: &'a Context,
|
|
|
|
Vals: *const &'a Metadata,
|
|
|
|
Count: size_t,
|
|
|
|
) -> &'a Metadata;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAddNamedMetadataOperand<'a>(M: &'a Module, Name: *const c_char, Val: &'a Value);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on scalar constants
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMConstInt(IntTy: &Type, N: c_ulonglong, SignExtend: Bool) -> &Value;
|
|
|
|
pub fn LLVMConstIntOfArbitraryPrecision(IntTy: &Type, Wn: c_uint, Ws: *const u64) -> &Value;
|
2019-07-07 19:08:40 +02:00
|
|
|
pub fn LLVMConstReal(RealTy: &Type, N: f64) -> &Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on composite constants
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMConstStringInContext(
|
|
|
|
C: &Context,
|
2016-08-02 23:10:10 +03:00
|
|
|
Str: *const c_char,
|
|
|
|
Length: c_uint,
|
|
|
|
DontNullTerminate: Bool,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMConstStructInContext<'a>(
|
2018-07-10 13:28:39 +03:00
|
|
|
C: &'a Context,
|
|
|
|
ConstantVals: *const &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Count: c_uint,
|
|
|
|
Packed: Bool,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2023-04-05 15:08:17 +03:00
|
|
|
// FIXME: replace with LLVMConstArray2 when bumped minimal version to llvm-17
|
2023-04-02 17:11:41 +03:00
|
|
|
// https://github.com/llvm/llvm-project/commit/35276f16e5a2cae0dfb49c0fbf874d4d2f177acc
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMConstArray<'a>(
|
2018-07-10 13:28:39 +03:00
|
|
|
ElementTy: &'a Type,
|
|
|
|
ConstantVals: *const &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Length: c_uint,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMConstVector(ScalarConstantVals: *const &Value, Size: c_uint) -> &Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Constant expressions
|
2023-07-10 00:19:06 -07:00
|
|
|
pub fn LLVMConstInBoundsGEP2<'a>(
|
2021-07-31 00:00:00 +00:00
|
|
|
ty: &'a Type,
|
2018-07-10 13:28:39 +03:00
|
|
|
ConstantVal: &'a Value,
|
|
|
|
ConstantIndices: *const &'a Value,
|
2018-01-16 09:31:48 +01:00
|
|
|
NumIndices: c_uint,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMConstPtrToInt<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstIntToPtr<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMConstBitCast<'a>(ConstantVal: &'a Value, ToType: &'a Type) -> &'a Value;
|
2022-06-29 14:00:40 +00:00
|
|
|
pub fn LLVMGetAggregateElement(ConstantVal: &Value, Idx: c_uint) -> Option<&Value>;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on global variables, functions, and aliases (globals)
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMIsDeclaration(Global: &Value) -> Bool;
|
|
|
|
pub fn LLVMSetSection(Global: &Value, Section: *const c_char);
|
|
|
|
pub fn LLVMGetAlignment(Global: &Value) -> c_uint;
|
|
|
|
pub fn LLVMSetAlignment(Global: &Value, Bytes: c_uint);
|
|
|
|
pub fn LLVMSetDLLStorageClass(V: &Value, C: DLLStorageClass);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on global variables
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMIsAGlobalVariable(GlobalVar: &Value) -> Option<&Value>;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAddGlobal<'a>(M: &'a Module, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMGetNamedGlobal(M: &Module, Name: *const c_char) -> Option<&Value>;
|
|
|
|
pub fn LLVMGetFirstGlobal(M: &Module) -> Option<&Value>;
|
|
|
|
pub fn LLVMGetNextGlobal(GlobalVar: &Value) -> Option<&Value>;
|
|
|
|
pub fn LLVMDeleteGlobal(GlobalVar: &Value);
|
|
|
|
pub fn LLVMGetInitializer(GlobalVar: &Value) -> Option<&Value>;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMSetInitializer<'a>(GlobalVar: &'a Value, ConstantVal: &'a Value);
|
2021-05-25 23:54:07 +02:00
|
|
|
pub fn LLVMIsThreadLocal(GlobalVar: &Value) -> Bool;
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMSetThreadLocalMode(GlobalVar: &Value, Mode: ThreadLocalMode);
|
|
|
|
pub fn LLVMIsGlobalConstant(GlobalVar: &Value) -> Bool;
|
|
|
|
pub fn LLVMSetGlobalConstant(GlobalVar: &Value, IsConstant: Bool);
|
|
|
|
pub fn LLVMSetTailCall(CallInst: &Value, IsTailCall: Bool);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2022-02-21 11:19:16 -05:00
|
|
|
// Operations on attributes
|
2022-03-03 00:00:00 +00:00
|
|
|
pub fn LLVMCreateStringAttribute(
|
2022-02-21 11:19:16 -05:00
|
|
|
C: &Context,
|
|
|
|
Name: *const c_char,
|
2022-03-03 00:00:00 +00:00
|
|
|
NameLen: c_uint,
|
2022-02-21 11:19:16 -05:00
|
|
|
Value: *const c_char,
|
2022-03-03 00:00:00 +00:00
|
|
|
ValueLen: c_uint,
|
2022-02-21 11:19:16 -05:00
|
|
|
) -> &Attribute;
|
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on functions
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMSetFunctionCallConv(Fn: &Value, CC: c_uint);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on parameters
|
2019-09-04 15:21:46 +03:00
|
|
|
pub fn LLVMIsAArgument(Val: &Value) -> Option<&Value>;
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMCountParams(Fn: &Value) -> c_uint;
|
|
|
|
pub fn LLVMGetParam(Fn: &Value, Index: c_uint) -> &Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on basic blocks
|
2018-07-10 14:34:34 +03:00
|
|
|
pub fn LLVMGetBasicBlockParent(BB: &BasicBlock) -> &Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAppendBasicBlockInContext<'a>(
|
2018-07-10 13:28:39 +03:00
|
|
|
C: &'a Context,
|
|
|
|
Fn: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 14:34:34 +03:00
|
|
|
) -> &'a BasicBlock;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on instructions
|
2019-09-04 15:21:46 +03:00
|
|
|
pub fn LLVMIsAInstruction(Val: &Value) -> Option<&Value>;
|
2018-07-10 14:34:34 +03:00
|
|
|
pub fn LLVMGetFirstBasicBlock(Fn: &Value) -> &BasicBlock;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on call sites
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMSetInstructionCallConv(Instr: &Value, CC: c_uint);
|
2016-10-22 18:37:35 +05:30
|
|
|
|
|
|
|
// Operations on load/store instructions (only)
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMSetVolatile(MemoryAccessInst: &Value, volatile: Bool);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Operations on phi nodes
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAddIncoming<'a>(
|
2018-07-10 13:28:39 +03:00
|
|
|
PhiNode: &'a Value,
|
|
|
|
IncomingValues: *const &'a Value,
|
2018-07-10 14:34:34 +03:00
|
|
|
IncomingBlocks: *const &'a BasicBlock,
|
2016-08-02 23:10:10 +03:00
|
|
|
Count: c_uint,
|
|
|
|
);
|
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Instruction builders
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMCreateBuilderInContext(C: &Context) -> &mut Builder<'_>;
|
|
|
|
pub fn LLVMPositionBuilderAtEnd<'a>(Builder: &Builder<'a>, Block: &'a BasicBlock);
|
|
|
|
pub fn LLVMGetInsertBlock<'a>(Builder: &Builder<'a>) -> &'a BasicBlock;
|
|
|
|
pub fn LLVMDisposeBuilder<'a>(Builder: &'a mut Builder<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Metadata
|
2023-04-02 15:20:00 +03:00
|
|
|
pub fn LLVMSetCurrentDebugLocation2<'a>(Builder: &Builder<'a>, Loc: &'a Metadata);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Terminators
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildRetVoid<'a>(B: &Builder<'a>) -> &'a Value;
|
|
|
|
pub fn LLVMBuildRet<'a>(B: &Builder<'a>, V: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMBuildBr<'a>(B: &Builder<'a>, Dest: &'a BasicBlock) -> &'a Value;
|
|
|
|
pub fn LLVMBuildCondBr<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
If: &'a Value,
|
2018-07-10 14:34:34 +03:00
|
|
|
Then: &'a BasicBlock,
|
|
|
|
Else: &'a BasicBlock,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSwitch<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
V: &'a Value,
|
2018-07-10 14:34:34 +03:00
|
|
|
Else: &'a BasicBlock,
|
2016-08-02 23:10:10 +03:00
|
|
|
NumCases: c_uint,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildLandingPad<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-03 15:49:43 +03:00
|
|
|
Ty: &'a Type,
|
2021-07-07 00:00:00 +00:00
|
|
|
PersFn: Option<&'a Value>,
|
2017-12-08 10:53:46 +01:00
|
|
|
NumClauses: c_uint,
|
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildResume<'a>(B: &Builder<'a>, Exn: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMBuildUnreachable<'a>(B: &Builder<'a>) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2023-04-03 15:12:21 +03:00
|
|
|
pub fn LLVMBuildCleanupPad<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
ParentPad: Option<&'a Value>,
|
|
|
|
Args: *const &'a Value,
|
2023-04-03 15:12:21 +03:00
|
|
|
NumArgs: c_uint,
|
2016-10-22 18:37:35 +05:30
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> Option<&'a Value>;
|
2023-04-03 15:12:21 +03:00
|
|
|
pub fn LLVMBuildCleanupRet<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
CleanupPad: &'a Value,
|
2023-04-03 15:12:21 +03:00
|
|
|
BB: Option<&'a BasicBlock>,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> Option<&'a Value>;
|
2023-04-03 15:12:21 +03:00
|
|
|
pub fn LLVMBuildCatchPad<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
ParentPad: &'a Value,
|
|
|
|
Args: *const &'a Value,
|
2023-04-03 15:12:21 +03:00
|
|
|
NumArgs: c_uint,
|
2016-10-22 18:37:35 +05:30
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> Option<&'a Value>;
|
2023-04-03 15:12:21 +03:00
|
|
|
pub fn LLVMBuildCatchRet<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2023-04-03 15:12:21 +03:00
|
|
|
CatchPad: &'a Value,
|
2018-07-17 18:26:58 +03:00
|
|
|
BB: &'a BasicBlock,
|
|
|
|
) -> Option<&'a Value>;
|
2023-04-03 15:12:21 +03:00
|
|
|
pub fn LLVMBuildCatchSwitch<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
Builder: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
ParentPad: Option<&'a Value>,
|
2023-04-03 15:12:21 +03:00
|
|
|
UnwindBB: Option<&'a BasicBlock>,
|
2016-08-02 23:10:10 +03:00
|
|
|
NumHandlers: c_uint,
|
2016-10-22 18:37:35 +05:30
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> Option<&'a Value>;
|
2023-04-03 16:30:34 +03:00
|
|
|
pub fn LLVMAddHandler<'a>(CatchSwitch: &'a Value, Dest: &'a BasicBlock);
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMSetPersonalityFn<'a>(Func: &'a Value, Pers: &'a Value);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Add a case to the switch instruction
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAddCase<'a>(Switch: &'a Value, OnVal: &'a Value, Dest: &'a BasicBlock);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Add a clause to the landing pad instruction
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMAddClause<'a>(LandingPad: &'a Value, ClauseVal: &'a Value);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Set the cleanup on a landing pad instruction
|
2018-07-10 13:28:39 +03:00
|
|
|
pub fn LLVMSetCleanup(LandingPad: &Value, Val: Bool);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Arithmetic
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildAdd<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFAdd<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSub<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFSub<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildMul<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFMul<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildUDiv<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildExactUDiv<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
Introduce unsafe offset_from on pointers
Adds intrinsics::exact_div to take advantage of the unsafe, which reduces the implementation from
```asm
sub rcx, rdx
mov rax, rcx
sar rax, 63
shr rax, 62
lea rax, [rax + rcx]
sar rax, 2
ret
```
down to
```asm
sub rcx, rdx
sar rcx, 2
mov rax, rcx
ret
```
(for `*const i32`)
2018-03-23 01:30:23 -07:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSDiv<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildExactSDiv<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFDiv<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildURem<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSRem<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFRem<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildShl<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildLShr<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildAShr<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNSWAdd<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNUWAdd<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNSWSub<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNUWSub<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNSWMul<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNUWMul<'a>(
|
2019-06-03 12:59:17 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildAnd<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildOr<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildXor<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildFNeg<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildNot<'a>(B: &Builder<'a>, V: &'a Value, Name: *const c_char) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Memory
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildAlloca<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildArrayAlloca<'a>(
|
2018-05-29 00:07:23 +09:00
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Val: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildLoad2<'a>(
|
2021-07-04 18:53:04 +02:00
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
PointerVal: &'a Value,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildStore<'a>(B: &Builder<'a>, Val: &'a Value, Ptr: &'a Value) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildGEP2<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2021-07-31 00:00:00 +00:00
|
|
|
Ty: &'a Type,
|
2018-07-10 13:28:39 +03:00
|
|
|
Pointer: &'a Value,
|
|
|
|
Indices: *const &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildInBoundsGEP2<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2021-08-01 00:00:00 +00:00
|
|
|
Ty: &'a Type,
|
2018-07-10 13:28:39 +03:00
|
|
|
Pointer: &'a Value,
|
|
|
|
Indices: *const &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
NumIndices: c_uint,
|
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Casts
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildTrunc<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildZExt<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSExt<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFPToUI<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFPToSI<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildUIToFP<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildSIToFP<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFPTrunc<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFPExt<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildPtrToInt<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildIntToPtr<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildBitCast<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildPointerCast<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2023-04-03 16:30:34 +03:00
|
|
|
pub fn LLVMBuildIntCast2<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
DestTy: &'a Type,
|
2023-04-08 12:15:26 +03:00
|
|
|
IsSigned: Bool,
|
2023-04-03 16:30:34 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Comparisons
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildICmp<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Op: c_uint,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildFCmp<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Op: c_uint,
|
2018-07-10 13:28:39 +03:00
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Miscellaneous instructions
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildPhi<'a>(B: &Builder<'a>, Ty: &'a Type, Name: *const c_char) -> &'a Value;
|
|
|
|
pub fn LLVMBuildSelect<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
If: &'a Value,
|
|
|
|
Then: &'a Value,
|
|
|
|
Else: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildVAArg<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
list: &'a Value,
|
2018-07-03 15:49:43 +03:00
|
|
|
Ty: &'a Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildExtractElement<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
VecVal: &'a Value,
|
|
|
|
Index: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildInsertElement<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
VecVal: &'a Value,
|
|
|
|
EltVal: &'a Value,
|
|
|
|
Index: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildShuffleVector<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
V1: &'a Value,
|
|
|
|
V2: &'a Value,
|
|
|
|
Mask: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildExtractValue<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
AggVal: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Index: c_uint,
|
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMBuildInsertValue<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
AggVal: &'a Value,
|
|
|
|
EltVal: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Index: c_uint,
|
2018-06-27 17:57:25 +03:00
|
|
|
Name: *const c_char,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2023-11-21 13:43:11 -05:00
|
|
|
// Atomic Operations
|
|
|
|
pub fn LLVMBuildAtomicCmpXchg<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
LHS: &'a Value,
|
|
|
|
CMP: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
FailureOrder: AtomicOrdering,
|
|
|
|
SingleThreaded: Bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMSetWeak(CmpXchgInst: &Value, IsWeak: Bool);
|
|
|
|
|
|
|
|
pub fn LLVMBuildAtomicRMW<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Op: AtomicRmwBinOp,
|
|
|
|
LHS: &'a Value,
|
|
|
|
RHS: &'a Value,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
SingleThreaded: Bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMBuildFence<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Order: AtomicOrdering,
|
|
|
|
SingleThreaded: Bool,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
|
|
|
/// Writes a module to the specified path. Returns 0 on success.
|
|
|
|
pub fn LLVMWriteBitcodeToFile(M: &Module, Path: *const c_char) -> c_int;
|
|
|
|
|
|
|
|
/// Creates a legacy pass manager -- only used for final codegen.
|
|
|
|
pub fn LLVMCreatePassManager<'a>() -> &'a mut PassManager<'a>;
|
|
|
|
|
|
|
|
pub fn LLVMAddAnalysisPasses<'a>(T: &'a TargetMachine, PM: &PassManager<'a>);
|
|
|
|
|
|
|
|
pub fn LLVMGetHostCPUFeatures() -> *mut c_char;
|
|
|
|
|
|
|
|
pub fn LLVMDisposeMessage(message: *mut c_char);
|
|
|
|
|
|
|
|
pub fn LLVMIsMultithreaded() -> Bool;
|
|
|
|
|
|
|
|
pub fn LLVMStructCreateNamed(C: &Context, Name: *const c_char) -> &Type;
|
|
|
|
|
|
|
|
pub fn LLVMStructSetBody<'a>(
|
|
|
|
StructTy: &'a Type,
|
|
|
|
ElementTypes: *const &'a Type,
|
|
|
|
ElementCount: c_uint,
|
|
|
|
Packed: Bool,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMMetadataAsValue<'a>(C: &'a Context, MD: &'a Metadata) -> &'a Value;
|
|
|
|
|
|
|
|
pub fn LLVMSetUnnamedAddress(Global: &Value, UnnamedAddr: UnnamedAddr);
|
|
|
|
|
|
|
|
pub fn LLVMIsAConstantInt(value_ref: &Value) -> Option<&ConstantInt>;
|
|
|
|
}
|
|
|
|
|
|
|
|
#[link(name = "llvm-wrapper", kind = "static")]
|
|
|
|
extern "C" {
|
|
|
|
pub fn LLVMRustInstallFatalErrorHandler();
|
|
|
|
pub fn LLVMRustDisableSystemDialogsOnCrash();
|
|
|
|
|
|
|
|
// Create and destroy contexts.
|
|
|
|
pub fn LLVMRustContextCreate(shouldDiscardNames: bool) -> &'static mut Context;
|
|
|
|
|
|
|
|
/// See llvm::LLVMTypeKind::getTypeID.
|
|
|
|
pub fn LLVMRustGetTypeKind(Ty: &Type) -> TypeKind;
|
|
|
|
|
|
|
|
// Operations on array, pointer, and vector types (sequence types)
|
|
|
|
pub fn LLVMRustArrayType(ElementType: &Type, ElementCount: u64) -> &Type;
|
|
|
|
|
|
|
|
// Operations on all values
|
|
|
|
pub fn LLVMRustGlobalAddMetadata<'a>(Val: &'a Value, KindID: c_uint, Metadata: &'a Metadata);
|
|
|
|
pub fn LLVMRustIsNonGVFunctionPointerTy(Val: &Value) -> bool;
|
|
|
|
|
|
|
|
// Operations on scalar constants
|
|
|
|
pub fn LLVMRustConstIntGetZExtValue(ConstantVal: &ConstantInt, Value: &mut u64) -> bool;
|
|
|
|
pub fn LLVMRustConstInt128Get(
|
|
|
|
ConstantVal: &ConstantInt,
|
|
|
|
SExt: bool,
|
|
|
|
high: &mut u64,
|
|
|
|
low: &mut u64,
|
|
|
|
) -> bool;
|
|
|
|
|
|
|
|
// Operations on global variables, functions, and aliases (globals)
|
|
|
|
pub fn LLVMRustGetLinkage(Global: &Value) -> Linkage;
|
|
|
|
pub fn LLVMRustSetLinkage(Global: &Value, RustLinkage: Linkage);
|
|
|
|
pub fn LLVMRustGetVisibility(Global: &Value) -> Visibility;
|
|
|
|
pub fn LLVMRustSetVisibility(Global: &Value, Viz: Visibility);
|
|
|
|
pub fn LLVMRustSetDSOLocal(Global: &Value, is_dso_local: bool);
|
|
|
|
|
|
|
|
// Operations on global variables
|
|
|
|
pub fn LLVMRustGetOrInsertGlobal<'a>(
|
|
|
|
M: &'a Module,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
T: &'a Type,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustInsertPrivateGlobal<'a>(M: &'a Module, T: &'a Type) -> &'a Value;
|
|
|
|
pub fn LLVMRustGetNamedValue(
|
|
|
|
M: &Module,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
) -> Option<&Value>;
|
|
|
|
pub fn LLVMRustSetTailCallKind(CallInst: &Value, TKC: TailCallKind);
|
|
|
|
|
|
|
|
// Operations on attributes
|
|
|
|
pub fn LLVMRustCreateAttrNoValue(C: &Context, attr: AttributeKind) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateAlignmentAttr(C: &Context, bytes: u64) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateDereferenceableAttr(C: &Context, bytes: u64) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateDereferenceableOrNullAttr(C: &Context, bytes: u64) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateByValAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
|
|
|
|
pub fn LLVMRustCreateStructRetAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
|
|
|
|
pub fn LLVMRustCreateElementTypeAttr<'a>(C: &'a Context, ty: &'a Type) -> &'a Attribute;
|
|
|
|
pub fn LLVMRustCreateUWTableAttr(C: &Context, async_: bool) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateAllocSizeAttr(C: &Context, size_arg: u32) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateAllocKindAttr(C: &Context, size_arg: u64) -> &Attribute;
|
|
|
|
pub fn LLVMRustCreateMemoryEffectsAttr(C: &Context, effects: MemoryEffects) -> &Attribute;
|
|
|
|
|
|
|
|
// Operations on functions
|
|
|
|
pub fn LLVMRustGetOrInsertFunction<'a>(
|
|
|
|
M: &'a Module,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
FunctionTy: &'a Type,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustAddFunctionAttributes<'a>(
|
|
|
|
Fn: &'a Value,
|
|
|
|
index: c_uint,
|
|
|
|
Attrs: *const &'a Attribute,
|
|
|
|
AttrsLen: size_t,
|
|
|
|
);
|
|
|
|
|
|
|
|
// Operations on call sites
|
|
|
|
pub fn LLVMRustAddCallSiteAttributes<'a>(
|
|
|
|
Instr: &'a Value,
|
|
|
|
index: c_uint,
|
|
|
|
Attrs: *const &'a Attribute,
|
|
|
|
AttrsLen: size_t,
|
|
|
|
);
|
|
|
|
|
|
|
|
pub fn LLVMRustBuildInvoke<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Fn: &'a Value,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
Then: &'a BasicBlock,
|
|
|
|
Catch: &'a BasicBlock,
|
|
|
|
OpBundles: *const &OperandBundleDef<'a>,
|
|
|
|
NumOpBundles: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
2023-12-26 04:20:35 +00:00
|
|
|
pub fn LLVMRustBuildCallBr<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Fn: &'a Value,
|
|
|
|
DefaultDest: &'a BasicBlock,
|
|
|
|
IndirectDests: *const &'a BasicBlock,
|
|
|
|
NumIndirectDests: c_uint,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
OpBundles: *const &OperandBundleDef<'a>,
|
|
|
|
NumOpBundles: c_uint,
|
|
|
|
Name: *const c_char,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
2023-11-21 13:43:11 -05:00
|
|
|
pub fn LLVMRustSetFastMath(Instr: &Value);
|
2024-02-06 14:32:00 -05:00
|
|
|
pub fn LLVMRustSetAlgebraicMath(Instr: &Value);
|
2024-02-18 23:10:34 +01:00
|
|
|
pub fn LLVMRustSetAllowReassoc(Instr: &Value);
|
2023-11-21 13:43:11 -05:00
|
|
|
|
|
|
|
// Miscellaneous instructions
|
|
|
|
pub fn LLVMRustGetInstrProfIncrementIntrinsic(M: &Module) -> &Value;
|
|
|
|
pub fn LLVMRustBuildCall<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Ty: &'a Type,
|
|
|
|
Fn: &'a Value,
|
|
|
|
Args: *const &'a Value,
|
|
|
|
NumArgs: c_uint,
|
|
|
|
OpBundles: *const &OperandBundleDef<'a>,
|
|
|
|
NumOpBundles: c_uint,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMemCpy<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Src: &'a Value,
|
|
|
|
SrcAlign: c_uint,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMemMove<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Src: &'a Value,
|
|
|
|
SrcAlign: c_uint,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMemSet<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Dst: &'a Value,
|
|
|
|
DstAlign: c_uint,
|
|
|
|
Val: &'a Value,
|
|
|
|
Size: &'a Value,
|
|
|
|
IsVolatile: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildVectorReduceFAdd<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Acc: &'a Value,
|
|
|
|
Src: &'a Value,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildVectorReduceFMul<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Acc: &'a Value,
|
|
|
|
Src: &'a Value,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildVectorReduceAdd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceMul<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceAnd<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceOr<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceXor<'a>(B: &Builder<'a>, Src: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceMin<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Src: &'a Value,
|
2018-03-13 16:46:55 +01:00
|
|
|
IsSigned: bool,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildVectorReduceMax<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Src: &'a Value,
|
2018-03-13 16:46:55 +01:00
|
|
|
IsSigned: bool,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildVectorReduceFMin<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Src: &'a Value,
|
|
|
|
IsNaN: bool,
|
|
|
|
) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildVectorReduceFMax<'a>(
|
|
|
|
B: &Builder<'a>,
|
|
|
|
Src: &'a Value,
|
|
|
|
IsNaN: bool,
|
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildMinNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
|
|
|
|
pub fn LLVMRustBuildMaxNum<'a>(B: &Builder<'a>, LHS: &'a Value, LHS: &'a Value) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2016-10-22 18:37:35 +05:30
|
|
|
// Atomic Operations
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildAtomicLoad<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2021-07-04 17:49:51 +02:00
|
|
|
ElementType: &'a Type,
|
2018-07-10 13:28:39 +03:00
|
|
|
PointerVal: &'a Value,
|
2018-06-27 17:57:25 +03:00
|
|
|
Name: *const c_char,
|
2016-08-02 23:10:10 +03:00
|
|
|
Order: AtomicOrdering,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustBuildAtomicStore<'a>(
|
2018-07-17 18:33:09 +03:00
|
|
|
B: &Builder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
|
|
|
Ptr: &'a Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
Order: AtomicOrdering,
|
2018-12-09 11:20:20 +01:00
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2023-11-21 13:43:11 -05:00
|
|
|
pub fn LLVMRustTimeTraceProfilerInitialize();
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2023-11-21 13:43:11 -05:00
|
|
|
pub fn LLVMRustTimeTraceProfilerFinishThread();
|
2022-09-18 15:49:49 -07:00
|
|
|
|
2023-11-21 13:43:11 -05:00
|
|
|
pub fn LLVMRustTimeTraceProfilerFinish(FileName: *const c_char);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
|
|
|
/// Returns a string describing the last error caused by an LLVMRust* call.
|
|
|
|
pub fn LLVMRustGetLastError() -> *const c_char;
|
|
|
|
|
|
|
|
/// Print the pass timings since static dtors aren't picking them up.
|
2023-07-19 17:00:06 +09:00
|
|
|
pub fn LLVMRustPrintPassTimings(size: *const size_t) -> *const c_char;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2022-11-05 01:08:57 -07:00
|
|
|
/// Print the statistics since static dtors aren't picking them up.
|
2023-07-19 17:00:06 +09:00
|
|
|
pub fn LLVMRustPrintStatistics(size: *const size_t) -> *const c_char;
|
2022-11-05 01:08:57 -07:00
|
|
|
|
2016-08-02 23:10:10 +03:00
|
|
|
/// Prepares inline assembly.
|
2018-07-02 17:52:53 +03:00
|
|
|
pub fn LLVMRustInlineAsm(
|
|
|
|
Ty: &Type,
|
2016-08-02 23:10:10 +03:00
|
|
|
AsmString: *const c_char,
|
2020-03-10 00:00:00 +00:00
|
|
|
AsmStringLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
Constraints: *const c_char,
|
2020-03-10 00:00:00 +00:00
|
|
|
ConstraintsLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
SideEffects: Bool,
|
|
|
|
AlignStack: Bool,
|
2016-08-03 00:25:19 +03:00
|
|
|
Dialect: AsmDialect,
|
2021-08-28 19:02:00 +02:00
|
|
|
CanThrow: Bool,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &Value;
|
2020-03-10 00:00:00 +00:00
|
|
|
pub fn LLVMRustInlineAsmVerify(
|
|
|
|
Ty: &Type,
|
|
|
|
Constraints: *const c_char,
|
|
|
|
ConstraintsLen: size_t,
|
|
|
|
) -> bool;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2020-07-02 11:27:15 -07:00
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteFilenamesSectionToBuffer(
|
|
|
|
Filenames: *const *const c_char,
|
|
|
|
FilenamesLen: size_t,
|
2023-07-24 17:27:29 +10:00
|
|
|
Lengths: *const size_t,
|
|
|
|
LengthsLen: size_t,
|
2020-07-02 11:27:15 -07:00
|
|
|
BufferOut: &RustString,
|
|
|
|
);
|
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteMappingToBuffer(
|
|
|
|
VirtualFileMappingIDs: *const c_uint,
|
|
|
|
NumVirtualFileMappingIDs: c_uint,
|
2023-07-22 18:23:39 +10:00
|
|
|
Expressions: *const crate::coverageinfo::ffi::CounterExpression,
|
2020-07-24 21:14:28 -07:00
|
|
|
NumExpressions: c_uint,
|
2023-07-22 18:23:39 +10:00
|
|
|
MappingRegions: *const crate::coverageinfo::ffi::CounterMappingRegion,
|
2020-07-24 21:14:28 -07:00
|
|
|
NumMappingRegions: c_uint,
|
2020-07-02 11:27:15 -07:00
|
|
|
BufferOut: &RustString,
|
|
|
|
);
|
|
|
|
|
2023-07-24 17:47:47 +10:00
|
|
|
pub fn LLVMRustCoverageCreatePGOFuncNameVar(
|
|
|
|
F: &Value,
|
|
|
|
FuncName: *const c_char,
|
|
|
|
FuncNameLen: size_t,
|
|
|
|
) -> &Value;
|
2020-11-23 12:56:07 -08:00
|
|
|
pub fn LLVMRustCoverageHashByteArray(Bytes: *const c_char, NumBytes: size_t) -> u64;
|
2020-07-02 11:27:15 -07:00
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
2020-11-23 12:56:07 -08:00
|
|
|
pub fn LLVMRustCoverageWriteMapSectionNameToString(M: &Module, Str: &RustString);
|
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteFuncSectionNameToString(M: &Module, Str: &RustString);
|
2020-07-02 11:27:15 -07:00
|
|
|
|
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustCoverageWriteMappingVarNameToString(Str: &RustString);
|
|
|
|
|
|
|
|
pub fn LLVMRustCoverageMappingVersion() -> u32;
|
2016-08-02 23:10:10 +03:00
|
|
|
pub fn LLVMRustDebugMetadataVersion() -> u32;
|
|
|
|
pub fn LLVMRustVersionMajor() -> u32;
|
|
|
|
pub fn LLVMRustVersionMinor() -> u32;
|
2020-10-12 22:33:27 -04:00
|
|
|
pub fn LLVMRustVersionPatch() -> u32;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2022-01-19 14:51:59 +00:00
|
|
|
/// Add LLVM module flags.
|
|
|
|
///
|
|
|
|
/// In order for Rust-C LTO to work, module flags must be compatible with Clang. What
|
|
|
|
/// "compatible" means depends on the merge behaviors involved.
|
|
|
|
pub fn LLVMRustAddModuleFlag(
|
|
|
|
M: &Module,
|
|
|
|
merge_behavior: LLVMModFlagBehavior,
|
|
|
|
name: *const c_char,
|
|
|
|
value: u32,
|
|
|
|
);
|
2022-04-21 13:35:40 +01:00
|
|
|
pub fn LLVMRustHasModuleFlag(M: &Module, name: *const c_char, len: size_t) -> bool;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreate(M: &Module) -> &mut DIBuilder<'_>;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderDispose<'a>(Builder: &'a mut DIBuilder<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2019-02-25 08:40:18 +01:00
|
|
|
pub fn LLVMRustDIBuilderFinalize(Builder: &DIBuilder<'_>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateCompileUnit<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Lang: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
Producer: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
ProducerLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
isOptimized: bool,
|
|
|
|
Flags: *const c_char,
|
|
|
|
RuntimeVer: c_uint,
|
2019-01-22 13:01:14 -08:00
|
|
|
SplitName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
SplitNameLen: size_t,
|
2019-01-22 13:01:14 -08:00
|
|
|
kind: DebugEmissionKind,
|
2020-09-23 16:25:20 +01:00
|
|
|
DWOId: u64,
|
|
|
|
SplitDebugInlining: bool,
|
2023-11-15 23:07:37 -05:00
|
|
|
DebugNameTableKind: DebugNameTableKind,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIDescriptor;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateFile<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Filename: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
FilenameLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
Directory: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
DirectoryLen: size_t,
|
2020-03-30 22:17:15 -07:00
|
|
|
CSKind: ChecksumKind,
|
|
|
|
Checksum: *const c_char,
|
|
|
|
ChecksumLen: size_t,
|
2018-07-17 18:45:33 +03:00
|
|
|
) -> &'a DIFile;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateSubroutineType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
ParameterTypes: &'a DIArray,
|
|
|
|
) -> &'a DICompositeType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateFunction<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIDescriptor,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
LinkageName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
LinkageNameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNo: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
2016-08-02 23:10:10 +03:00
|
|
|
ScopeLine: c_uint,
|
2016-11-18 17:15:14 -05:00
|
|
|
Flags: DIFlags,
|
2019-01-16 09:59:03 -08:00
|
|
|
SPFlags: DISPFlags,
|
2020-02-10 22:30:51 +02:00
|
|
|
MaybeFn: Option<&'a Value>,
|
2018-07-04 16:36:49 +03:00
|
|
|
TParam: &'a DIArray,
|
|
|
|
Decl: Option<&'a DIDescriptor>,
|
|
|
|
) -> &'a DISubprogram;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2023-05-03 15:52:31 -07:00
|
|
|
pub fn LLVMRustDIBuilderCreateMethod<'a>(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIDescriptor,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
LinkageName: *const c_char,
|
|
|
|
LinkageNameLen: size_t,
|
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
Flags: DIFlags,
|
|
|
|
SPFlags: DISPFlags,
|
|
|
|
TParam: &'a DIArray,
|
|
|
|
) -> &'a DISubprogram;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateBasicType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
SizeInBits: u64,
|
|
|
|
Encoding: c_uint,
|
2018-07-17 18:45:33 +03:00
|
|
|
) -> &'a DIBasicType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateTypedef<'a>(
|
2020-06-24 23:28:00 -07:00
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Type: &'a DIBasicType,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Scope: Option<&'a DIScope>,
|
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreatePointerType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
PointeeTy: &'a DIType,
|
2016-10-22 18:37:35 +05:30
|
|
|
SizeInBits: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2020-03-06 00:00:00 +00:00
|
|
|
AddressSpace: c_uint,
|
2016-10-22 18:37:35 +05:30
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIDerivedType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateStructType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: Option<&'a DIDescriptor>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2016-11-18 17:15:14 -05:00
|
|
|
Flags: DIFlags,
|
2018-07-04 16:36:49 +03:00
|
|
|
DerivedFrom: Option<&'a DIType>,
|
|
|
|
Elements: &'a DIArray,
|
2016-08-02 23:10:10 +03:00
|
|
|
RunTimeLang: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
VTableHolder: Option<&'a DIType>,
|
2016-08-02 23:10:10 +03:00
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DICompositeType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateMemberType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIDescriptor,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNo: c_uint,
|
|
|
|
SizeInBits: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2016-08-02 23:10:10 +03:00
|
|
|
OffsetInBits: u64,
|
2016-11-18 17:15:14 -05:00
|
|
|
Flags: DIFlags,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DIDerivedType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateVariantMemberType<'a>(
|
2017-11-29 14:42:25 -07:00
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2017-11-29 14:42:25 -07:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
OffsetInBits: u64,
|
|
|
|
Discriminant: Option<&'a Value>,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DIType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2022-06-20 17:50:27 +02:00
|
|
|
pub fn LLVMRustDIBuilderCreateStaticMemberType<'a>(
|
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIDescriptor,
|
|
|
|
Name: *const c_char,
|
|
|
|
NameLen: size_t,
|
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
Ty: &'a DIType,
|
|
|
|
Flags: DIFlags,
|
|
|
|
val: Option<&'a Value>,
|
|
|
|
AlignInBits: u32,
|
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateLexicalBlock<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIScope,
|
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
Line: c_uint,
|
|
|
|
Col: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DILexicalBlock;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateLexicalBlockFile<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIScope,
|
|
|
|
File: &'a DIFile,
|
|
|
|
) -> &'a DILexicalBlock;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateStaticVariable<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Context: Option<&'a DIScope>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2016-08-02 23:10:10 +03:00
|
|
|
LinkageName: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
LinkageNameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNo: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
2016-08-02 23:10:10 +03:00
|
|
|
isLocalToUnit: bool,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-04 16:36:49 +03:00
|
|
|
Decl: Option<&'a DIDescriptor>,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2018-09-14 19:06:45 +03:00
|
|
|
) -> &'a DIGlobalVariableExpression;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateVariable<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Tag: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIDescriptor,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNo: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
2016-08-02 23:10:10 +03:00
|
|
|
AlwaysPreserve: bool,
|
2016-11-18 17:15:14 -05:00
|
|
|
Flags: DIFlags,
|
2016-11-18 11:11:18 -05:00
|
|
|
ArgNo: c_uint,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIVariable;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateArrayType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Size: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
|
|
|
Subscripts: &'a DIArray,
|
|
|
|
) -> &'a DIType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderGetOrCreateSubrange<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Lo: i64,
|
|
|
|
Count: i64,
|
2018-07-17 18:45:33 +03:00
|
|
|
) -> &'a DISubrange;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderGetOrCreateArray<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ptr: *const Option<&'a DIDescriptor>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Count: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIArray;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderInsertDeclareAtEnd<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-10 13:28:39 +03:00
|
|
|
Val: &'a Value,
|
2018-07-04 16:36:49 +03:00
|
|
|
VarInfo: &'a DIVariable,
|
2022-01-03 11:25:33 +01:00
|
|
|
AddrOps: *const u64,
|
2016-08-02 23:10:10 +03:00
|
|
|
AddrOpsCount: c_uint,
|
2020-02-10 22:52:20 +02:00
|
|
|
DL: &'a DILocation,
|
2018-07-10 14:34:34 +03:00
|
|
|
InsertAtEnd: &'a BasicBlock,
|
2018-07-10 13:28:39 +03:00
|
|
|
) -> &'a Value;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateEnumerator<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-05 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2022-10-01 22:12:03 +01:00
|
|
|
Value: *const u64,
|
|
|
|
SizeInBits: c_uint,
|
2020-03-05 00:00:00 +00:00
|
|
|
IsUnsigned: bool,
|
2018-07-17 18:45:33 +03:00
|
|
|
) -> &'a DIEnumerator;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateEnumerationType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIScope,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2018-07-04 16:36:49 +03:00
|
|
|
Elements: &'a DIArray,
|
2017-11-29 14:42:25 -07:00
|
|
|
ClassType: &'a DIType,
|
2019-01-16 09:59:03 -08:00
|
|
|
IsScoped: bool,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateUnionType<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2021-04-26 14:39:57 -04:00
|
|
|
Scope: Option<&'a DIScope>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
File: &'a DIFile,
|
2016-08-02 23:10:10 +03:00
|
|
|
LineNumber: c_uint,
|
|
|
|
SizeInBits: u64,
|
2017-02-04 23:51:10 +13:00
|
|
|
AlignInBits: u32,
|
2016-11-18 17:15:14 -05:00
|
|
|
Flags: DIFlags,
|
2018-07-04 16:36:49 +03:00
|
|
|
Elements: Option<&'a DIArray>,
|
2016-08-02 23:10:10 +03:00
|
|
|
RunTimeLang: c_uint,
|
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DIType;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateVariantPart<'a>(
|
2017-11-29 14:42:25 -07:00
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
Scope: &'a DIScope,
|
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2017-11-29 14:42:25 -07:00
|
|
|
File: &'a DIFile,
|
|
|
|
LineNo: c_uint,
|
|
|
|
SizeInBits: u64,
|
|
|
|
AlignInBits: u32,
|
|
|
|
Flags: DIFlags,
|
|
|
|
Discriminator: Option<&'a DIDerivedType>,
|
|
|
|
Elements: &'a DIArray,
|
|
|
|
UniqueId: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
UniqueIdLen: size_t,
|
2017-11-29 14:42:25 -07:00
|
|
|
) -> &'a DIDerivedType;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateTemplateTypeParameter<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: Option<&'a DIScope>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
2018-07-04 16:36:49 +03:00
|
|
|
Ty: &'a DIType,
|
|
|
|
) -> &'a DITemplateTypeParameter;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateNameSpace<'a>(
|
2018-07-17 18:45:33 +03:00
|
|
|
Builder: &DIBuilder<'a>,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: Option<&'a DIScope>,
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2020-03-06 00:00:00 +00:00
|
|
|
NameLen: size_t,
|
|
|
|
ExportSymbols: bool,
|
2018-07-04 16:36:49 +03:00
|
|
|
) -> &'a DINameSpace;
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDICompositeTypeReplaceArrays<'a>(
|
2018-10-12 07:34:14 -06:00
|
|
|
Builder: &DIBuilder<'a>,
|
|
|
|
CompositeType: &'a DIType,
|
|
|
|
Elements: Option<&'a DIArray>,
|
|
|
|
Params: Option<&'a DIArray>,
|
|
|
|
);
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustDIBuilderCreateDebugLocation<'a>(
|
2016-08-02 23:10:10 +03:00
|
|
|
Line: c_uint,
|
|
|
|
Column: c_uint,
|
2018-07-04 16:36:49 +03:00
|
|
|
Scope: &'a DIScope,
|
2020-02-10 22:52:20 +02:00
|
|
|
InlinedAt: Option<&'a DILocation>,
|
|
|
|
) -> &'a DILocation;
|
2022-01-03 11:25:33 +01:00
|
|
|
pub fn LLVMRustDIBuilderCreateOpDeref() -> u64;
|
|
|
|
pub fn LLVMRustDIBuilderCreateOpPlusUconst() -> u64;
|
2022-10-01 23:10:36 +02:00
|
|
|
pub fn LLVMRustDIBuilderCreateOpLLVMFragment() -> u64;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 14:43:12 +03:00
|
|
|
pub fn LLVMRustWriteTypeToString(Type: &Type, s: &RustString);
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 14:43:12 +03:00
|
|
|
pub fn LLVMRustWriteValueToString(value_ref: &Value, s: &RustString);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-12 18:34:59 +03:00
|
|
|
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2023-07-13 16:56:29 -07:00
|
|
|
pub fn LLVMRustPrintTargetCPUs(
|
|
|
|
T: &TargetMachine,
|
|
|
|
cpu: *const c_char,
|
|
|
|
print: unsafe extern "C" fn(out: *mut c_void, string: *const c_char, len: usize),
|
|
|
|
out: *mut c_void,
|
|
|
|
);
|
2021-04-08 00:00:47 -05:00
|
|
|
pub fn LLVMRustGetTargetFeaturesCount(T: &TargetMachine) -> size_t;
|
|
|
|
pub fn LLVMRustGetTargetFeature(
|
|
|
|
T: &TargetMachine,
|
|
|
|
Index: size_t,
|
|
|
|
Feature: &mut *const c_char,
|
|
|
|
Desc: &mut *const c_char,
|
|
|
|
);
|
2016-08-06 15:50:48 +10:00
|
|
|
|
2018-08-23 11:03:22 -07:00
|
|
|
pub fn LLVMRustGetHostCPUName(len: *mut usize) -> *const c_char;
|
2023-09-17 14:40:22 +02:00
|
|
|
|
|
|
|
// This function makes copies of pointed to data, so the data's lifetime may end after this function returns
|
2016-08-02 23:10:10 +03:00
|
|
|
pub fn LLVMRustCreateTargetMachine(
|
|
|
|
Triple: *const c_char,
|
|
|
|
CPU: *const c_char,
|
|
|
|
Features: *const c_char,
|
2019-10-29 21:12:05 -07:00
|
|
|
Abi: *const c_char,
|
2016-08-02 23:10:10 +03:00
|
|
|
Model: CodeModel,
|
2020-04-23 20:49:00 +03:00
|
|
|
Reloc: RelocModel,
|
2016-08-02 23:10:10 +03:00
|
|
|
Level: CodeGenOptLevel,
|
|
|
|
UseSoftFP: bool,
|
|
|
|
FunctionSections: bool,
|
2017-11-11 07:08:00 -08:00
|
|
|
DataSections: bool,
|
2021-10-11 12:09:32 -07:00
|
|
|
UniqueSectionNames: bool,
|
2017-10-22 20:01:00 -07:00
|
|
|
TrapUnreachable: bool,
|
2018-08-12 17:59:18 +00:00
|
|
|
Singlethread: bool,
|
2018-09-13 19:43:15 +02:00
|
|
|
AsmComments: bool,
|
2019-12-02 17:52:45 +05:30
|
|
|
EmitStackSizeSection: bool,
|
|
|
|
RelaxELFRelocations: bool,
|
2020-04-16 19:40:11 -07:00
|
|
|
UseInitArray: bool,
|
2020-09-23 16:25:20 +01:00
|
|
|
SplitDwarfFile: *const c_char,
|
2023-09-09 14:00:24 +02:00
|
|
|
OutputObjFile: *const c_char,
|
2023-07-12 17:07:34 -04:00
|
|
|
DebugInfoCompression: *const c_char,
|
2023-11-13 20:48:23 +08:00
|
|
|
UseEmulatedTls: bool,
|
2023-07-03 13:11:27 +02:00
|
|
|
ArgsCstrBuff: *const c_char,
|
|
|
|
ArgsCstrBuffLen: usize,
|
2023-09-17 14:40:22 +02:00
|
|
|
) -> *mut TargetMachine;
|
2024-01-12 18:23:04 +08:00
|
|
|
|
2023-09-17 14:40:22 +02:00
|
|
|
pub fn LLVMRustDisposeTargetMachine(T: *mut TargetMachine);
|
2024-01-12 18:23:04 +08:00
|
|
|
pub fn LLVMRustAddLibraryInfo<'a>(
|
|
|
|
PM: &PassManager<'a>,
|
|
|
|
M: &'a Module,
|
|
|
|
DisableSimplifyLibCalls: bool,
|
|
|
|
);
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustWriteOutputFile<'a>(
|
2018-07-12 18:34:59 +03:00
|
|
|
T: &'a TargetMachine,
|
2018-07-17 14:17:47 +03:00
|
|
|
PM: &PassManager<'a>,
|
2018-07-12 18:34:59 +03:00
|
|
|
M: &'a Module,
|
2016-08-02 23:10:10 +03:00
|
|
|
Output: *const c_char,
|
2020-09-23 16:25:20 +01:00
|
|
|
DwoOutput: *const c_char,
|
2016-08-02 23:10:10 +03:00
|
|
|
FileType: FileType,
|
|
|
|
) -> LLVMRustResult;
|
2022-09-16 16:18:27 -07:00
|
|
|
pub fn LLVMRustOptimize<'a>(
|
2020-01-05 19:16:58 +01:00
|
|
|
M: &'a Module,
|
|
|
|
TM: &'a TargetMachine,
|
|
|
|
OptLevel: PassBuilderOptLevel,
|
|
|
|
OptStage: OptStage,
|
2023-07-11 16:19:42 -07:00
|
|
|
IsLinkerPluginLTO: bool,
|
2020-01-05 19:16:58 +01:00
|
|
|
NoPrepopulatePasses: bool,
|
|
|
|
VerifyIR: bool,
|
|
|
|
UseThinLTOBuffers: bool,
|
|
|
|
MergeFunctions: bool,
|
|
|
|
UnrollLoops: bool,
|
|
|
|
SLPVectorize: bool,
|
|
|
|
LoopVectorize: bool,
|
2024-01-12 18:23:04 +08:00
|
|
|
DisableSimplifyLibCalls: bool,
|
2020-05-13 00:00:00 +00:00
|
|
|
EmitLifetimeMarkers: bool,
|
2020-01-05 19:16:58 +01:00
|
|
|
SanitizerOptions: Option<&SanitizerOptions>,
|
|
|
|
PGOGenPath: *const c_char,
|
|
|
|
PGOUsePath: *const c_char,
|
2021-04-05 10:45:04 +02:00
|
|
|
InstrumentCoverage: bool,
|
2022-08-10 09:16:20 -07:00
|
|
|
InstrProfileOutput: *const c_char,
|
2021-04-05 11:26:48 +02:00
|
|
|
InstrumentGCOV: bool,
|
2021-05-07 07:41:37 +00:00
|
|
|
PGOSampleUsePath: *const c_char,
|
|
|
|
DebugInfoForProfiling: bool,
|
2020-02-11 22:37:16 +01:00
|
|
|
llvm_selfprofiler: *mut c_void,
|
|
|
|
begin_callback: SelfProfileBeforePassCallback,
|
|
|
|
end_callback: SelfProfileAfterPassCallback,
|
2021-04-05 15:37:11 +02:00
|
|
|
ExtraPasses: *const c_char,
|
|
|
|
ExtraPassesLen: size_t,
|
2021-11-24 11:43:40 +01:00
|
|
|
LLVMPlugins: *const c_char,
|
|
|
|
LLVMPluginsLen: size_t,
|
2021-04-05 15:37:11 +02:00
|
|
|
) -> LLVMRustResult;
|
2019-12-02 20:53:01 +11:00
|
|
|
pub fn LLVMRustPrintModule(
|
2021-12-14 13:49:49 -05:00
|
|
|
M: &Module,
|
2017-06-29 17:52:43 +03:00
|
|
|
Output: *const c_char,
|
|
|
|
Demangle: extern "C" fn(*const c_char, size_t, *mut c_char, size_t) -> size_t,
|
2019-04-05 17:48:23 -07:00
|
|
|
) -> LLVMRustResult;
|
2016-08-02 23:10:10 +03:00
|
|
|
pub fn LLVMRustSetLLVMOptions(Argc: c_int, Argv: *const *const c_char);
|
|
|
|
pub fn LLVMRustPrintPasses();
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMRustSetNormalizedTarget(M: &Module, triple: *const c_char);
|
|
|
|
pub fn LLVMRustRunRestrictionPass(M: &Module, syms: *const *const c_char, len: size_t);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-07-13 13:06:06 +03:00
|
|
|
pub fn LLVMRustOpenArchive(path: *const c_char) -> Option<&'static mut Archive>;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustArchiveIteratorNew(AR: &Archive) -> &mut ArchiveIterator<'_>;
|
|
|
|
pub fn LLVMRustArchiveIteratorNext<'a>(
|
2018-07-17 18:26:58 +03:00
|
|
|
AIR: &ArchiveIterator<'a>,
|
|
|
|
) -> Option<&'a mut ArchiveChild<'a>>;
|
2019-02-25 08:40:18 +01:00
|
|
|
pub fn LLVMRustArchiveChildName(ACR: &ArchiveChild<'_>, size: &mut size_t) -> *const c_char;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustArchiveChildFree<'a>(ACR: &'a mut ArchiveChild<'a>);
|
|
|
|
pub fn LLVMRustArchiveIteratorFree<'a>(AIR: &'a mut ArchiveIterator<'a>);
|
2018-07-13 13:06:06 +03:00
|
|
|
pub fn LLVMRustDestroyArchive(AR: &'static mut Archive);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 14:43:12 +03:00
|
|
|
pub fn LLVMRustWriteTwineToString(T: &Twine, s: &RustString);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustUnpackOptimizationDiagnostic<'a>(
|
2018-07-13 13:59:41 +03:00
|
|
|
DI: &'a DiagnosticInfo,
|
2018-07-13 14:43:12 +03:00
|
|
|
pass_name_out: &RustString,
|
|
|
|
function_out: &mut Option<&'a Value>,
|
|
|
|
loc_line_out: &mut c_uint,
|
|
|
|
loc_column_out: &mut c_uint,
|
|
|
|
loc_filename_out: &RustString,
|
|
|
|
message_out: &RustString,
|
|
|
|
);
|
2019-12-22 17:42:04 -05:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustUnpackInlineAsmDiagnostic<'a>(
|
2018-07-13 13:59:41 +03:00
|
|
|
DI: &'a DiagnosticInfo,
|
2020-06-09 14:37:59 +01:00
|
|
|
level_out: &mut DiagnosticLevel,
|
2024-02-21 12:18:59 +03:00
|
|
|
cookie_out: &mut u64,
|
2018-07-13 15:27:55 +03:00
|
|
|
message_out: &mut Option<&'a Twine>,
|
|
|
|
);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2018-07-13 14:43:12 +03:00
|
|
|
pub fn LLVMRustWriteDiagnosticInfoToString(DI: &DiagnosticInfo, s: &RustString);
|
2018-07-13 13:59:41 +03:00
|
|
|
pub fn LLVMRustGetDiagInfoKind(DI: &DiagnosticInfo) -> DiagnosticKind;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustGetSMDiagnostic<'a>(
|
2021-07-28 21:31:47 +02:00
|
|
|
DI: &'a DiagnosticInfo,
|
|
|
|
cookie_out: &mut c_uint,
|
|
|
|
) -> &'a SMDiagnostic;
|
|
|
|
|
2018-12-18 20:58:15 +02:00
|
|
|
#[allow(improper_ctypes)]
|
2020-05-26 20:07:59 +01:00
|
|
|
pub fn LLVMRustUnpackSMDiagnostic(
|
|
|
|
d: &SMDiagnostic,
|
|
|
|
message_out: &RustString,
|
|
|
|
buffer_out: &RustString,
|
2020-06-09 14:37:59 +01:00
|
|
|
level_out: &mut DiagnosticLevel,
|
2020-05-26 20:07:59 +01:00
|
|
|
loc_out: &mut c_uint,
|
|
|
|
ranges_out: *mut c_uint,
|
|
|
|
num_ranges: &mut usize,
|
|
|
|
) -> bool;
|
2016-08-02 23:10:10 +03:00
|
|
|
|
|
|
|
pub fn LLVMRustWriteArchive(
|
|
|
|
Dst: *const c_char,
|
|
|
|
NumMembers: size_t,
|
2019-02-25 08:40:18 +01:00
|
|
|
Members: *const &RustArchiveMember<'_>,
|
2016-08-02 23:10:10 +03:00
|
|
|
WriteSymbtab: bool,
|
2016-10-22 18:37:35 +05:30
|
|
|
Kind: ArchiveKind,
|
|
|
|
) -> LLVMRustResult;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustArchiveMemberNew<'a>(
|
2016-08-02 23:10:10 +03:00
|
|
|
Filename: *const c_char,
|
|
|
|
Name: *const c_char,
|
2018-08-10 06:31:10 -04:00
|
|
|
Child: Option<&ArchiveChild<'a>>,
|
2018-07-17 16:00:10 +03:00
|
|
|
) -> &'a mut RustArchiveMember<'a>;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustArchiveMemberFree<'a>(Member: &'a mut RustArchiveMember<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-03-08 12:42:54 -08:00
|
|
|
pub fn LLVMRustWriteImportLibrary(
|
|
|
|
ImportName: *const c_char,
|
|
|
|
Path: *const c_char,
|
|
|
|
Exports: *const LLVMRustCOFFShortExport,
|
|
|
|
NumExports: usize,
|
|
|
|
Machine: u16,
|
|
|
|
MinGW: bool,
|
|
|
|
) -> LLVMRustResult;
|
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustSetDataLayoutFromTargetMachine<'a>(M: &'a Module, TM: &'a TargetMachine);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2022-12-20 22:10:40 +01:00
|
|
|
pub fn LLVMRustBuildOperandBundleDef(
|
2016-08-02 23:10:10 +03:00
|
|
|
Name: *const c_char,
|
2022-12-20 22:10:40 +01:00
|
|
|
Inputs: *const &'_ Value,
|
2016-08-02 23:10:10 +03:00
|
|
|
NumInputs: c_uint,
|
2022-12-20 22:10:40 +01:00
|
|
|
) -> &mut OperandBundleDef<'_>;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustFreeOperandBundleDef<'a>(Bundle: &'a mut OperandBundleDef<'a>);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustPositionBuilderAtStart<'a>(B: &Builder<'a>, BB: &'a BasicBlock);
|
2016-08-02 23:10:10 +03:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustSetComdat<'a>(M: &'a Module, V: &'a Value, Name: *const c_char, NameLen: size_t);
|
2019-11-03 10:52:00 -06:00
|
|
|
pub fn LLVMRustSetModulePICLevel(M: &Module);
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMRustSetModulePIELevel(M: &Module);
|
2021-03-12 08:35:13 +09:00
|
|
|
pub fn LLVMRustSetModuleCodeModel(M: &Module, Model: CodeModel);
|
2018-07-17 16:08:25 +03:00
|
|
|
pub fn LLVMRustModuleBufferCreate(M: &Module) -> &'static mut ModuleBuffer;
|
|
|
|
pub fn LLVMRustModuleBufferPtr(p: &ModuleBuffer) -> *const u8;
|
|
|
|
pub fn LLVMRustModuleBufferLen(p: &ModuleBuffer) -> usize;
|
|
|
|
pub fn LLVMRustModuleBufferFree(p: &'static mut ModuleBuffer);
|
2018-06-27 17:57:25 +03:00
|
|
|
pub fn LLVMRustModuleCost(M: &Module) -> u64;
|
2022-11-03 22:34:24 +08:00
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustModuleInstructionStats(M: &Module, Str: &RustString);
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
|
2022-06-08 17:30:16 +03:00
|
|
|
pub fn LLVMRustThinLTOBufferCreate(M: &Module, is_thin: bool) -> &'static mut ThinLTOBuffer;
|
2018-07-17 16:31:09 +03:00
|
|
|
pub fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
|
|
|
|
pub fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;
|
|
|
|
pub fn LLVMRustThinLTOBufferLen(M: &ThinLTOBuffer) -> size_t;
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
pub fn LLVMRustCreateThinLTOData(
|
|
|
|
Modules: *const ThinLTOModule,
|
|
|
|
NumModules: c_uint,
|
|
|
|
PreservedSymbols: *const *const c_char,
|
|
|
|
PreservedSymbolsLen: c_uint,
|
2018-07-17 16:43:49 +03:00
|
|
|
) -> Option<&'static mut ThinLTOData>;
|
2020-06-25 18:52:41 -07:00
|
|
|
pub fn LLVMRustPrepareThinLTORename(
|
|
|
|
Data: &ThinLTOData,
|
|
|
|
Module: &Module,
|
|
|
|
Target: &TargetMachine,
|
|
|
|
) -> bool;
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
pub fn LLVMRustPrepareThinLTOResolveWeak(Data: &ThinLTOData, Module: &Module) -> bool;
|
|
|
|
pub fn LLVMRustPrepareThinLTOInternalize(Data: &ThinLTOData, Module: &Module) -> bool;
|
2020-06-25 18:52:41 -07:00
|
|
|
pub fn LLVMRustPrepareThinLTOImport(
|
|
|
|
Data: &ThinLTOData,
|
|
|
|
Module: &Module,
|
|
|
|
Target: &TargetMachine,
|
|
|
|
) -> bool;
|
2018-07-17 16:43:49 +03:00
|
|
|
pub fn LLVMRustFreeThinLTOData(Data: &'static mut ThinLTOData);
|
2019-02-11 07:46:04 -08:00
|
|
|
pub fn LLVMRustParseBitcodeForLTO(
|
2018-06-27 17:57:25 +03:00
|
|
|
Context: &Context,
|
rustc: Implement ThinLTO
This commit is an implementation of LLVM's ThinLTO for consumption in rustc
itself. Currently today LTO works by merging all relevant LLVM modules into one
and then running optimization passes. "Thin" LTO operates differently by having
more sharded work and allowing parallelism opportunities between optimizing
codegen units. Further down the road Thin LTO also allows *incremental* LTO
which should enable even faster release builds without compromising on the
performance we have today.
This commit uses a `-Z thinlto` flag to gate whether ThinLTO is enabled. It then
also implements two forms of ThinLTO:
* In one mode we'll *only* perform ThinLTO over the codegen units produced in a
single compilation. That is, we won't load upstream rlibs, but we'll instead
just perform ThinLTO amongst all codegen units produced by the compiler for
the local crate. This is intended to emulate a desired end point where we have
codegen units turned on by default for all crates and ThinLTO allows us to do
this without performance loss.
* In anther mode, like full LTO today, we'll optimize all upstream dependencies
in "thin" mode. Unlike today, however, this LTO step is fully parallelized so
should finish much more quickly.
There's a good bit of comments about what the implementation is doing and where
it came from, but the tl;dr; is that currently most of the support here is
copied from upstream LLVM. This code duplication is done for a number of
reasons:
* Controlling parallelism means we can use the existing jobserver support to
avoid overloading machines.
* We will likely want a slightly different form of incremental caching which
integrates with our own incremental strategy, but this is yet to be
determined.
* This buys us some flexibility about when/where we run ThinLTO, as well as
having it tailored to fit our needs for the time being.
* Finally this allows us to reuse some artifacts such as our `TargetMachine`
creation, where all our options we used today aren't necessarily supported by
upstream LLVM yet.
My hope is that we can get some experience with this copy/paste in tree and then
eventually upstream some work to LLVM itself to avoid the duplication while
still ensuring our needs are met. Otherwise I fear that maintaining these
bindings may be quite costly over the years with LLVM updates!
2017-07-23 08:14:38 -07:00
|
|
|
Data: *const u8,
|
|
|
|
len: usize,
|
|
|
|
Identifier: *const c_char,
|
2018-06-27 17:57:25 +03:00
|
|
|
) -> Option<&Module>;
|
2023-09-07 09:48:50 -04:00
|
|
|
pub fn LLVMRustGetSliceFromObjectDataByName(
|
|
|
|
data: *const u8,
|
|
|
|
len: usize,
|
|
|
|
name: *const u8,
|
|
|
|
out_len: &mut usize,
|
|
|
|
) -> *const u8;
|
2018-02-12 08:38:46 -08:00
|
|
|
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustLinkerNew(M: &Module) -> &mut Linker<'_>;
|
2019-02-25 08:40:18 +01:00
|
|
|
pub fn LLVMRustLinkerAdd(
|
|
|
|
linker: &Linker<'_>,
|
2018-02-12 08:38:46 -08:00
|
|
|
bytecode: *const c_char,
|
|
|
|
bytecode_len: usize,
|
|
|
|
) -> bool;
|
2021-12-14 13:49:49 -05:00
|
|
|
pub fn LLVMRustLinkerFree<'a>(linker: &'a mut Linker<'a>);
|
Use llvm::computeLTOCacheKey to determine post-ThinLTO CGU reuse
During incremental ThinLTO compilation, we attempt to re-use the
optimized (post-ThinLTO) bitcode file for a module if it is 'safe' to do
so.
Up until now, 'safe' has meant that the set of modules that our current
modules imports from/exports to is unchanged from the previous
compilation session. See PR #67020 and PR #71131 for more details.
However, this turns out be insufficient to guarantee that it's safe
to reuse the post-LTO module (i.e. that optimizing the pre-LTO module
would produce the same result). When LLVM optimizes a module during
ThinLTO, it may look at other information from the 'module index', such
as whether a (non-imported!) global variable is used. If this
information changes between compilation runs, we may end up re-using an
optimized module that (for example) had dead-code elimination run on a
function that is now used by another module.
Fortunately, LLVM implements its own ThinLTO module cache, which is used
when ThinLTO is performed by a linker plugin (e.g. when clang is used to
compile a C proect). Using this cache directly would require extensive
refactoring of our code - but fortunately for us, LLVM provides a
function that does exactly what we need.
The function `llvm::computeLTOCacheKey` is used to compute a SHA-1 hash
from all data that might influence the result of ThinLTO on a module.
In addition to the module imports/exports that we manually track, it
also hashes information about global variables (e.g. their liveness)
which might be used during optimization. By using this function, we
shouldn't have to worry about new LLVM passes breaking our module re-use
behavior.
In LLVM, the output of this function forms part of the filename used to
store the post-ThinLTO module. To keep our current filename structure
intact, this PR just writes out the mapping 'CGU name -> Hash' to a
file. To determine if a post-LTO module should be reused, we compare
hashes from the previous session.
This should unblock PR #75199 - by sheer chance, it seems to have hit
this issue due to the particular CGU partitioning and optimization
decisions that end up getting made.
2020-09-17 17:36:13 -04:00
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustComputeLTOCacheKey(
|
|
|
|
key_out: &RustString,
|
|
|
|
mod_id: *const c_char,
|
|
|
|
data: &ThinLTOData,
|
|
|
|
);
|
2021-11-12 00:00:00 +00:00
|
|
|
|
|
|
|
pub fn LLVMRustContextGetDiagnosticHandler(Context: &Context) -> Option<&DiagnosticHandler>;
|
|
|
|
pub fn LLVMRustContextSetDiagnosticHandler(
|
|
|
|
context: &Context,
|
|
|
|
diagnostic_handler: Option<&DiagnosticHandler>,
|
|
|
|
);
|
|
|
|
pub fn LLVMRustContextConfigureDiagnosticHandler(
|
|
|
|
context: &Context,
|
|
|
|
diagnostic_handler_callback: DiagnosticHandlerTy,
|
|
|
|
diagnostic_handler_context: *mut c_void,
|
|
|
|
remark_all_passes: bool,
|
|
|
|
remark_passes: *const *const c_char,
|
|
|
|
remark_passes_len: usize,
|
2023-06-25 23:39:02 +02:00
|
|
|
remark_file: *const c_char,
|
2023-08-07 17:56:57 +02:00
|
|
|
pgo_available: bool,
|
2021-11-12 00:00:00 +00:00
|
|
|
);
|
|
|
|
|
2022-03-01 00:53:25 +00:00
|
|
|
#[allow(improper_ctypes)]
|
|
|
|
pub fn LLVMRustGetMangledName(V: &Value, out: &RustString);
|
2022-07-19 15:03:39 +02:00
|
|
|
|
|
|
|
pub fn LLVMRustGetElementTypeArgIndex(CallSite: &Value) -> i32;
|
2022-05-28 10:43:51 +00:00
|
|
|
|
|
|
|
pub fn LLVMRustIsBitcode(ptr: *const u8, len: usize) -> bool;
|
|
|
|
|
2023-07-12 17:07:34 -04:00
|
|
|
pub fn LLVMRustLLVMHasZlibCompressionForDebugSymbols() -> bool;
|
|
|
|
|
|
|
|
pub fn LLVMRustLLVMHasZstdCompressionForDebugSymbols() -> bool;
|
|
|
|
|
2022-05-28 10:43:51 +00:00
|
|
|
pub fn LLVMRustGetSymbols(
|
|
|
|
buf_ptr: *const u8,
|
|
|
|
buf_len: usize,
|
|
|
|
state: *mut c_void,
|
|
|
|
callback: GetSymbolsCallback,
|
|
|
|
error_callback: GetSymbolsErrorCallback,
|
|
|
|
) -> *mut c_void;
|
2016-08-02 23:10:10 +03:00
|
|
|
}
|