Commit Graph

404 Commits

Author SHA1 Message Date
bjorn3
e2f645dd7f Let LtoModuleCodegen::optimize take self by value 2022-04-30 20:51:17 +02:00
bjorn3
758a7da13b Rename run_lto_pass_manager to optimize_fat and remove thin parameter 2022-04-30 20:50:17 +02:00
antoyo
0405aa0065
Merge pull request #163 from yvt/fix-asm-sym
Add inline assembly `sym` operands as GCC input operands
2022-04-30 10:30:20 -04:00
antoyo
248c1c5e45
Merge pull request #168 from rust-lang/config/no-fmt
Add rustfmt config to disable formatting
2022-04-29 23:18:05 -04:00
Antoni Boucher
dc8da94d56 Add rustfmt config to disable formatting 2022-04-29 23:17:44 -04:00
yvt
63ffdfdd17 Add compilation tests with optimization enabled
Introduces a new variant of `tests/lib.rs` that compiles the source
files in `tests/run` with `-Copt-level=3`.
2022-04-30 09:53:06 +09:00
yvt
5d25b8fc45 Convert inline assembly sym operands into GCC input operands
This commit updates `<Builder as AsmBuilderMethods>::codegen_inline_asm`
to convert `sym` operands into `"X" (&func_or_static)` input operands
to indicate the dependency on the referenced symbols and prevent them
from being eliminated.

We follow the suit of the LLVM codegen with a mixture of its differing
techniques for `asm!` and `global_asm!`. The codegen module generates
input operands for the `sym` operands (as in `asm!` in cg_llvm).
However, the codegen module replaces all placeholders with mangled
symbol names before passing the assembly template string to the backend
(as in `global_asm!` in cg_llvm), which means these input operands are
never referenced in the final assembly template string.

Unlike the LLVM codegen, the input operand constraint must be `X`
instead of `s`. If the `s` constraint is used, GCC will employ checks to
make sure that the operand can really be represented by a simple
symbolic constant, thus rejecting symbols requiring GOT, etc. to
resolve. Such checks are unnecessary for Rust `sym` as it's up to
programmers to handle such complex cases, e.g., by manually appending
GOT addressing modifiers to the substituted symbol names.

Using the `X` constraint doesn't seem to generate any extra code, so
this will not compromise the property of naked functions.
2022-04-25 01:55:36 +09:00
antoyo
1d62e95368
Merge pull request #164 from yvt/no-intel-syntax
Don't emit `.intel_syntax` for non-x86 targets
2022-04-24 12:12:49 -04:00
yvt
a0742bdd06 Don't emit .intel_syntax for non-x86 targets 2022-04-24 13:09:57 +09:00
antoyo
b30a8f31f5
Merge pull request #162 from rust-lang/fix/test-script
Fix test.sh --build
2022-04-23 21:32:20 -04:00
Antoni Boucher
889c402258 Fix test.sh --build 2022-04-23 10:48:12 -04:00
Dylan DPC
63e9911e56 Rollup merge of #95740 - Amanieu:kreg0, r=nagisa
asm: Add a kreg0 register class on x86 which includes k0

Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977
2022-04-19 22:57:39 +02:00
Amanieu d'Antras
52cd51f3ec asm: Add a kreg0 register class on x86 which includes k0
Previously we only exposed a kreg register class which excludes the k0
register since it can't be used in many instructions. However k0 is a
valid register and we need to have a way of marking it as clobbered for
clobber_abi.

Fixes #94977
2022-04-19 17:14:23 +02:00
bors
21be9da209 Auto merge of #95689 - lqd:self-profiler, r=wesleywiser
Allow self-profiler to only record potentially costly arguments when argument recording is turned on

As discussed [on zulip](https://rust-lang.zulipchat.com/#narrow/stream/247081-t-compiler.2Fperformance/topic/Identifying.20proc-macro.20slowdowns/near/277304909) with `@wesleywiser,` I'd like to record proc-macro expansions in the self-profiler, with some detailed data (per-expansion spans for example, to follow #95473).

At the same time, I'd also like to avoid doing expensive things when tracking a generic activity's arguments, if they were not specifically opted into the event filter mask, to allow the self-profiler to be used in hotter contexts.

This PR tries to offer:
- a way to ensure a closure to record arguments will only be called in that situation, so that potentially costly arguments can still be recorded when needed. With the additional requirement that, if possible, it would offer a way to record non-owned data without adding many `generic_activity_with_arg_{...}`-style methods. This lead to the `generic_activity_with_arg_recorder` single entry-point, and the closure parameter would offer the new methods, able to be executed in a context where costly argument could be created without disturbing the profiled piece of code.
- some facilities/patterns allowing to record more rustc specific data in this situation, without making `rustc_data_structures`  where the self-profiler is defined, depend on other rustc crates (causing circular dependencies): in particular, spans. They are quite tricky to turn into strings (if the default `Debug` impl output does not match the context one needs them for), and since I'd also like to avoid the allocation there when arg recording is turned off today, that has turned into another flexibility requirement for the API in this PR (separating the span-specific recording into an extension trait). **edit**: I've removed this from the PR so that it's easier to review, and opened https://github.com/rust-lang/rust/pull/95739.
- allow for extensibility in the future: other ways to record arguments, or additional data attached to them could be added in the future (e.g. recording the argument's name as well as its data).

Some areas where I'd love feedback:
- the API and names: the `EventArgRecorder` and its method for example. As well as the verbosity that comes from the increased flexibility.
- if I should convert the existing `generic_activity_with_arg{s}` to just forward to `generic_activity_with_arg_recorder` + `recorder.record_arg` (or remove them altogether ? Probably not): I've used the new API in the simple case I could find of allocating for an arg that may not be recorded, and the rest don't seem costly.
- [x] whether this API should panic if no arguments were recorded by the user-provided closure (like this PR currently does: it seems like an error to use an API dedicated to record arguments but not call the methods to then do so) or if this should just record a generic activity without arguments ?
- whether the `record_arg` function should be `#[inline(always)]`, like the `generic_activity_*` functions ?

As mentioned, r? `@wesleywiser` following our recent discussion.
2022-04-16 11:43:28 +00:00
antoyo
4210fd49cb
Merge pull request #160 from MikaelUrankar/master
Don't assume /bin/bash is available on every system.
2022-04-15 11:06:01 -04:00
Amanieu d'Antras
0e31b92112 Add codegen for global_asm! sym operands 2022-04-15 14:36:30 +01:00
Mikael Urankar
f92779512d Add set -v as we can't pass command line argument with /usr/bin/env 2022-04-15 09:58:25 +02:00
antoyo
c35f4e841e
Merge pull request #158 from rust-lang/feature/gcc12
Add feature for future libgccjit 12 release
2022-04-14 17:20:34 -04:00
MikaelUrankar
330127599a Don't assume /bin/bash is available on every system. 2022-04-14 14:12:06 +02:00
Antoni Boucher
4d7de81199 Add feature for future libgccjit 12 release 2022-04-13 23:01:01 -04:00
Rémy Rakic
c59b01f241 simplify a self-profiling activity call in the cg_gcc backend 2022-04-07 15:47:20 +02:00
antoyo
d69ada6bf3
Merge pull request #156 from yvt/fix-int-ops
Implement `saturating_{add, sub}` for non-native integer types
2022-04-06 10:14:19 -04:00
yvt
a7a09d556a Wrap numbers with black_box in-line, remove one 2022-04-06 22:11:52 +09:00
yvt
5061e3ad16 Remove redundant assertions 2022-04-06 21:49:54 +09:00
yvt
00677e5159 Implement saturating_{add, sub} for non-native integer types
Updates their unsigned code paths to use the `Builder::gcc_` methods
that automatically lower non-native integer operations to native ones.

Also updates the signed code path of `saturating_add` to support non-
native integer types. That of `saturating_sub` already supports this,
so no major changes have been made.
2022-04-06 01:48:37 +09:00
yvt
837a4467bc test: Test more integer types and checked arithmetic in tests/run/int.rs 2022-04-06 01:25:13 +09:00
Oli Scherer
249d3e9dd9 Use WrappingRange::full instead of hand-rolling it 2022-04-05 13:18:22 +00:00
Oli Scherer
d71f633d38 Mark scalar layout unions so that backends that do not support partially initialized scalars can special case them. 2022-04-05 13:18:21 +00:00
Loïc BRANSTETT
6ce5ce82af Cleanup after some refactoring in rustc_target 2022-04-03 21:29:57 +02:00
David Morrison
88c058b614 make memcmp return a value of c_int_width instead of i32 2022-04-02 17:21:08 -07:00
yvt
56983cf3c6 test: Remove redundant code from tests/run/int.rs 2022-04-01 12:55:00 +09:00
antoyo
341b9f274b
Merge pull request #153 from GuillaumeGomez/general-intrinsics
Sort archs and make the generate predictable
2022-03-31 10:16:51 -04:00
Guillaume Gomez
035ac03521 Add intrinsics not bound to a specific arch 2022-03-31 14:58:31 +02:00
antoyo
403e198f4a
Merge pull request #154 from rust-lang/fix/error-var-tracking
Fix error related to var tracking assignments
2022-03-31 08:40:18 -04:00
Antoni Boucher
ef1a6d7c23 Fix error related to var tracking assignments 2022-03-31 08:40:05 -04:00
antoyo
dac359504c
Merge pull request #152 from GuillaumeGomez/more-intrinsics
Generate all listed architectures from llvmint
2022-03-30 14:26:27 -04:00
Guillaume Gomez
68ac3a4b3b Generate all listed architectures from llvmint 2022-03-30 18:41:57 +02:00
antoyo
0237d9562d
Merge pull request #151 from GuillaumeGomez/x86-intrinsics
Add intrinsic translation for x86 arch
2022-03-30 12:22:19 -04:00
Guillaume Gomez
3970825b92 Add intrinsic translation for x86 arch 2022-03-30 17:37:33 +02:00
antoyo
f537564454
Merge pull request #148 from rust-lang/feature/packed-struct
Feature/packed struct
2022-03-30 09:55:30 -04:00
antoyo
76cf7c2058
Merge pull request #150 from bjorn3/bootstrap_missing_vendor_intrinsics
Add missing vendor intrinsics
2022-03-30 09:47:12 -04:00
bjorn3
9bb797c2ae Add missing vendor intrinsics 2022-03-30 14:16:02 +02:00
Dylan DPC
81083b906f Rollup merge of #95461 - nyurik:spelling, r=lcnr
Spellchecking some comments

This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 09:10:07 +02:00
Yuri Astrakhan
c519b85387 Spellchecking compiler code
Address some spelling mistakes in strings, private function names, and function params.
2022-03-30 01:42:10 -04:00
Yuri Astrakhan
74edcb8bd1 Spellchecking some comments
This PR attempts to clean up some minor spelling mistakes in comments
2022-03-30 01:39:38 -04:00
Antoni Boucher
927eea3860 Add support for packed struct 2022-03-29 22:52:25 -04:00
antoyo
a445bcb53d
Merge pull request #149 from rust-lang/missing-comments
Add support for target builtins
2022-03-29 22:51:00 -04:00
Antoni Boucher
267e5e1ea7 Add support for target builtins 2022-03-29 22:50:20 -04:00
antoyo
13ab1ab9de
Merge pull request #129 from rust-lang/feature/simd
Feature/simd
2022-03-29 22:47:16 -04:00
Antoni Boucher
02970a6ca8 Add support for target builtins 2022-03-29 21:41:17 -04:00