Commit Graph

1291 Commits

Author SHA1 Message Date
Amanieu d'Antras
0d936e19c9 Remove the reg_thumb register class for asm! on ARM
Also restricts r8-r14 from being used on Thumb1 targets as per #90736.
2021-12-07 23:54:09 +00:00
Nikita Popov
98afc30b95 Use object crate for .rustc metadata generation
We already use the object crate for generating uncompressed .rmeta
metadata object files. This switches the generation of compressed
.rustc object files to use the object crate as well. These have
slightly different requirements in that .rmeta should be completely
excluded from any final compilation artifacts, while .rustc should
be part of shared objects, but not loaded into memory.

The primary motivation for this change is #90326: In LLVM 14, the
current way of setting section flags (and in particular, preventing
the setting of SHF_ALLOC) will no longer work. There are other ways
we could work around this, but switching to the object crate seems
like the most elegant, as we already use it for .rmeta, and as it
makes this independent of the codegen backend. In particular, we
don't need separate handling in codegen_llvm and codegen_gcc.
codegen_cranelift should be able to reuse the implementation as
well, though I have omitted that here, as it is not based on
codegen_ssa.

This change mostly extracts the existing code for .rmeta handling
to allow using it for .rustc as well, and adjust the codegen
infrastructure to handle the metadata object file separately: We
no longer create a backend-specific module for it, and directly
produce the compiled module instead.

This does not fix #90326 by itself yet, as .llvmbc will need to be
handled separately.
2021-12-07 09:39:05 +01:00
Andrew Dona-Couch
4e68093d8c Implement inline asm! for AVR platform 2021-12-06 01:02:49 -05:00
cynecx
4fa64fd1c3 rustc_codegen_gcc: proper check for may_unwind 2021-12-03 23:51:49 +01:00
cynecx
b7cb08d4e7 rustc_codegen_gcc: error on unwinding inline asm 2021-12-03 23:51:49 +01:00
bors
48fc7d9351 Auto merge of #91003 - psumbera:sparc64-abi, r=nagisa
fix sparc64 ABI for aggregates with floating point members

Fixes #86163
2021-12-02 02:59:44 +00:00
Petr Sumbera
dcd48250d7 fix sparc64 ABI for aggregates with floating point members 2021-12-01 10:03:45 +01:00
rdambrosio
0d61135280 Feat: make cg_ssa get_param borrow the builder mutable 2021-11-23 22:30:20 -05:00
Andreas Jonson
a912fedd0f Remove workaround for the forward progress handling in LLVM 2021-11-14 16:35:09 +01:00
antoyo
ebe6f6785c
Fix negation operation (#108) 2021-10-31 14:27:52 -04:00
bjorn3
08183f9f2d
Remove unused dependency on object (#102) 2021-10-31 12:17:13 -04:00
antoyo
fc8e79fea9
Sync from rust (#107)
* Rebase fallout.

* Move rustc_middle::middle::cstore to rustc_session.

* Create more accurate debuginfo for vtables.

Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.

* Remove alloc::prelude

As per the libs team decision in #58935.

Closes #58935

* Make hash_result an Option.

* Properly check `target_features` not to trigger an assertion

* Add LLVM CFI support to the Rust compiler

This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).

* Update to nightly-2021-10-30

* Add deduplication of constant values as rustc relies on LLVM doing that

Co-authored-by: Camille GILLOT <gillot.camille@gmail.com>
Co-authored-by: Michael Woerister <michaelwoerister@posteo>
Co-authored-by: Amanieu d'Antras <amanieu@gmail.com>
Co-authored-by: Yuki Okushi <yuki.okushi@huawei.com>
Co-authored-by: Ramon de C Valle <rcvalle@users.noreply.github.com>
2021-10-30 18:21:33 -04:00
bors
d5a6aafb88 Auto merge of #89652 - rcvalle:rust-cfi, r=nagisa
Add LLVM CFI support to the Rust compiler

This PR adds LLVM Control Flow Integrity (CFI) support to the Rust compiler. It initially provides forward-edge control flow protection for Rust-compiled code only by aggregating function pointers in groups identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code share the same virtual address space) will be provided in later work as part of this project by defining and using compatible type identifiers (see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e., -Clto).

Thank you, `@eddyb` and `@pcc,` for all the help!
2021-10-27 09:19:42 +00:00
Yuki Okushi
8094e2e5ae Properly check target_features not to trigger an assertion 2021-10-26 11:02:51 +09:00
Ramon de C Valle
14b83de047 Add LLVM CFI support to the Rust compiler
This commit adds LLVM Control Flow Integrity (CFI) support to the Rust
compiler. It initially provides forward-edge control flow protection for
Rust-compiled code only by aggregating function pointers in groups
identified by their number of arguments.

Forward-edge control flow protection for C or C++ and Rust -compiled
code "mixed binaries" (i.e., for when C or C++ and Rust -compiled code
share the same virtual address space) will be provided in later work as
part of this project by defining and using compatible type identifiers
(see Type metadata in the design document in the tracking issue #89653).

LLVM CFI can be enabled with -Zsanitizer=cfi and requires LTO (i.e.,
-Clto).
2021-10-25 16:23:01 -07:00
antoyo
1d064f1741
Disable strict aliasing (#104) 2021-10-25 17:48:15 -04:00
Camille GILLOT
ce9faca631 Make hash_result an Option. 2021-10-20 18:29:18 +02:00
Amanieu d'Antras
98f0580cdb Remove alloc::prelude
As per the libs team decision in #58935.

Closes #58935
2021-10-15 01:41:31 +02:00
Fisher Darling
863cfb2d63
Fix FIXME in Builder::and and Builder::or impls (#101)
* impl bitwise and & or
2021-10-12 12:39:14 -04:00
antoyo
669359530e
Add missing cast and change some bitcasts to casts to avoid a gimple verification failure (#100) 2021-10-11 10:56:08 -04:00
bors
775b6daf0f Auto merge of #89597 - michaelwoerister:improve-vtable-debuginfo, r=wesleywiser
Create more accurate debuginfo for vtables.

Before this PR all vtables would have the same name (`"vtable"`) in debuginfo. Now they get an unambiguous name that identifies the implementing type and the trait that is being implemented.

This is only one of several possible improvements:
- This PR describes vtables as arrays of `*const u8` pointers. It would nice to describe them as structs where function pointer is represented by a field with a name indicative of the method it maps to. However, this requires coming up with a naming scheme that avoids clashes between methods with the same name (which is possible if the vtable contains multiple traits).
- The PR does not update the debuginfo we generate for the vtable-pointer field in a fat `dyn` pointer. Right now there does not seem to be an easy way of getting ahold of a vtable-layout without also knowing the concrete self-type of a trait object.

r? `@wesleywiser`
2021-10-11 04:31:47 +00:00
Michael Woerister
7033f75a49 Create more accurate debuginfo for vtables.
Before this commit all vtables would have the same name "vtable" in
debuginfo. Now they get a name that identifies the implementing type
and the trait that is being implemented.
2021-10-08 10:33:47 +02:00
Camille GILLOT
583170aec8 Move rustc_middle::middle::cstore to rustc_session. 2021-10-03 16:08:51 +02:00
Camille GILLOT
27a819ebc7 Rebase fallout. 2021-09-30 20:22:42 +02:00
antoyo
cd4810de42
Fix warnings (#98) 2021-09-28 09:32:54 -04:00
antoyo
9809f5d219
Update to nightly-2021-09-28 (#97) 2021-09-28 09:18:27 -04:00
antoyo
11c2023ef5
Fix/count trailing zeroes (#95)
* Fix count trailing zeroes
* Fix pop count
* Fix bit reverse
2021-09-27 20:35:45 -04:00
antoyo
63608ac6b3
Fix/mismatch types (#94)
* Refactor test.sh script

* Fix mismatched types error
2021-09-27 19:31:24 -04:00
antoyo
ab4ff2dfe0
Cleanup fix for global initialization (#93)
* Cleanup fix for global initialization
* Remove linker script hack
* Use v0 symbol mangling
* Fix warnings
2021-09-27 09:34:06 -04:00
antoyo
64c561dc22
Fix global initialization (#91)
* Make define_global() return a RValue directly
* Return LValue in functions declaring a global variable
* Remove useless cast
* Fix bytes_in_context to use an array rvalue
* Remove global_names which is unused
* Make const_struct create a constant struct
* Correctly initialize global in static_addr_of_mut
* Fix global variable initialization
* Remove workaround for ARGV
2021-09-26 12:20:02 -04:00
Commeownist
4e7e822f39
Impove handling of registers in inline asm (#82)
* Correctly handle st(0) register in the clobbers list
* Gate the clobbers based on enabled target features
2021-09-26 09:30:45 -04:00
antoyo
0f4b616a08
Add notes for cross-compilation to gcc-only targets (#68) 2021-09-26 00:06:42 -04:00
Commeownist
48d60ab7c5
Update to nightly-2021-09-11 (#79)
* Implement `black_box` as intrinsic

Responsibility of implementing the black box is now lies on backend

* Remove some TODOs

* Update to nightly-2021-09-17

* CI: don't fail on warnings
2021-09-17 17:19:25 -04:00
Emerson Laurentino
8ec7976ced
fix: gh origin on readme (#83) 2021-09-16 21:47:19 -04:00
Antoni Boucher
4d3dcd414c Remove FUNDING.yml 2021-09-16 07:37:23 -04:00
Commeownist
7c707e4b95
Implement basic inline asm support (#72)
* Implement basic support for inline assembly

* Disable LTO

We don't support it yet at all

* Handle `inout(reg) var` correctly

Turns out that `+` readwrite output registers cannot be tied with
input variables.

* Add limited support for llvm_asm!

* Handle CHANNEL correctly

* Add support for arbitrary explicit registers

* Handle symbols properly

* Add rudimentary asm tests

* Exclude llvm_asm! tests from tests runs

* Insert `__builtin_unreachable()` after diverging asm blocks
2021-09-05 11:26:01 -04:00
antoyo
5dad13cc3b
Update custom rustc instructions (#73) 2021-08-28 11:34:47 -04:00
Antoni Boucher
6f50986667 Empty gcc_path 2021-08-15 10:54:12 -04:00
antoyo
e228f0c16e
Cleanup (#67) 2021-08-15 08:28:46 -04:00
antoyo
0c89065b93
Update to nightly-2021-08-12 (#61) 2021-08-14 10:05:49 -04:00
Antoni Boucher
afae271d5d Initial commit 2021-08-12 21:46:50 -04:00