538 Commits

Author SHA1 Message Date
Antoni Boucher
783789f831 Build the sysroot and run more tests 2023-10-25 11:19:03 -04:00
Antoni Boucher
a93d1b73c6 Fix volatile_load 2023-10-24 19:53:59 -04:00
Antoni Boucher
7425c560d3 Add comment 2023-10-21 18:48:03 -04:00
Andy Sadler
81c1f39a86
optimize u128/i128 popcounts further
Don't fall back on breaking apart the popcount operation if 128-bit
integers are natively supported.

Signed-off-by: Andy Sadler <andrewsadler122@gmail.com>
2023-10-18 22:10:41 -05:00
Antoni Boucher
9d5e0ba1f5 Fixes including fixing compilation for --no-default-features 2023-10-17 20:55:54 -04:00
Antoni Boucher
e5fa9f8692 Use the correct alignment for integer types 2023-10-17 20:55:54 -04:00
antoyo
fabdc1a273
Merge pull request #348 from sadlerap/optimize-popcount
optimize popcount implementation
2023-10-17 20:47:05 -04:00
Andy Sadler
64abf5862f
optimize popcount implementation
In the current implementation, the gcc backend of rustc currently emits the
following for a function that implements popcount for a u32 (x86_64 targeting
AVX2, using standard unix calling convention):

    popcount:
        mov     eax, edi
        and     edi, 1431655765
        shr     eax
        and     eax, 1431655765
        add     edi, eax
        mov     edx, edi
        and     edi, 858993459
        shr     edx, 2
        and     edx, 858993459
        add     edx, edi
        mov     eax, edx
        and     edx, 252645135
        shr     eax, 4
        and     eax, 252645135
        add     eax, edx
        mov     edx, eax
        and     eax, 16711935
        shr     edx, 8
        and     edx, 16711935
        add     edx, eax
        movzx   eax, dx
        shr     edx, 16
        add     eax, edx
        ret

Rather than using this implementation, gcc could be told to use Wenger's
algorithm.  This would give the same function the following implementation:

    popcount:
        xor eax, eax
        xor edx, edx
        popcnt eax, edi
        test edi, edi
        cmove eax, edx
        ret

This patch implements the popcount operation in terms of Wenger's algorithm in
all cases.

Signed-off-by: Andy Sadler <andrewsadler122@gmail.com>
2023-10-17 16:20:55 -05:00
Guillaume Gomez
0348a5f17a Improve code readability 2023-10-17 23:00:23 +02:00
Guillaume Gomez
096f14d374 Add support for NonNull function attribute 2023-10-17 15:03:25 +02:00
Antoni Boucher
e3998b2d46 Handle unsigned comparison for signed integers 2023-10-13 07:50:42 -04:00
Antoni Boucher
100dfced20 Fix #[inline(always)] attribute 2023-10-11 20:55:32 -04:00
Antoni Boucher
a7532daa76 Fix unchecked_ssub, unchecked_smul, and unchecked_umul 2023-10-09 13:16:47 -04:00
Antoni Boucher
a00ea0bf98 Fix unchecked_sadd 2023-10-09 13:03:23 -04:00
Antoni Boucher
bd7e5b9d4e Fix bitcast with different sizes 2023-10-09 10:38:37 -04:00
Antoni Boucher
c567e59bad Merge branch 'master' into sync_from_rust_2023_10_08 2023-10-08 11:31:53 -04:00
Antoni Boucher
b3c10d4a7d Fix 128-bit non-native integers negation 2023-10-08 08:49:20 -04:00
Antoni Boucher
b3fecae7d7 Fix 128-bit non-native integers comparison 2023-10-07 15:14:54 -04:00
Erik Desjardins
7e8c85ba31 Reapply: Mark drop calls in landing pads cold instead of noinline
Co-authored-by: Max Fan <git@max.fan>
Co-authored-by: Nikita Popov <npopov@redhat.com>
2023-10-02 10:37:53 +02:00
Oli Scherer
8373b05514 Have a single struct for queries and hook 2023-09-22 16:26:20 +00:00
Oli Scherer
38b9e26a75 Add a way to decouple the implementation and the declaration of a TyCtxt method. 2023-09-22 09:23:15 +00:00
antoyo
e7d1dc33c6
Merge pull request #337 from rust-lang/fix/gep
Fix gep on pointers to non-number
2023-09-20 17:57:04 -04:00
Antoni Boucher
be3b1e3321 Fix gep on pointers to non-number 2023-09-20 09:10:24 -04:00
Antoni Boucher
5ab4e2b484 Implement llvm.x86.rdrand.64 2023-09-18 18:24:09 -04:00
Ralf Jung
cd519aabd7 fix gcc, cranelift build 2023-09-15 10:43:44 +02:00
Ralf Jung
22e13b4c55 clarify PassMode::Indirect as well 2023-09-15 10:43:44 +02:00
Antoni Boucher
f3b82df8f8 Add note to readme 2023-09-14 21:49:14 -04:00
Antoni Boucher
f096c19db5 Handle target-cpu=native 2023-09-14 20:47:14 -04:00
Antoni Boucher
a9a2c687ff Send -march to gcc 2023-09-14 20:42:14 -04:00
Antoni Boucher
87daba2cad Only add feature flags on functions 2023-09-14 20:35:11 -04:00
Antoni Boucher
20d4c39462 Correctly handle target features 2023-09-14 19:55:19 -04:00
Antoni Boucher
f692124c5d Handle disabled features 2023-09-14 19:55:19 -04:00
Antoni Boucher
5bb0d630ab Do not always enable avx2 2023-09-14 19:55:19 -04:00
Antoni Boucher
adc0b210f3 Enable one more feature 2023-09-14 19:55:19 -04:00
Antoni Boucher
f6337e4966 Don't always enabled CPU features 2023-09-14 19:55:19 -04:00
Antoni Boucher
32df82648d Handle static relocation model 2023-09-14 19:02:00 -04:00
Deadbeef
d7766ffa36 treat host effect params as erased generics in codegen
This fixes the changes brought to codegen tests when effect params are
added to libcore, by not attempting to monomorphize functions that get
the host param by being `const fn`.
2023-09-14 07:34:35 +00:00
Antoni Boucher
cd1644a658 Fix const handling in ATT syntax 2023-09-09 12:50:25 -04:00
Daniel Paoliello
8028885239 Deduplicate inlined function debug info, but create a new lexical scope to child subsequent scopes and variables from colliding 2023-09-01 14:27:21 -07:00
Guillaume Gomez
03bcfff8b3 Only apply NoAlias attribute if optimization is enabled 2023-08-31 21:19:36 +02:00
Antoni Boucher
62867dc29f LTO implementation 2023-08-30 20:29:24 -04:00
Matthias Krüger
13e402ed7c Rollup merge of #111580 - atsuzaki:layout-ice, r=oli-obk
Don't ICE on layout computation failure

Fixes #111176 regression.

r? `@oli-obk`
2023-08-29 20:49:02 +02:00
Guillaume Gomez
c83e5679b3 Don't generate __restrict__ attribute for ByValue arguments 2023-08-29 15:45:48 +02:00
Katherine Philip
642fae9409 Don't ICE on layout computation failure 2023-08-28 12:40:39 -07:00
Matthias Krüger
cdb012e0ba Rollup merge of #115240 - RalfJung:llvm-no-type, r=bjorn3
codegen_llvm/llvm_type: avoid matching on the Rust type

This `match` is highly suspicious. Looking at `scalar_llvm_type_at` I think it makes no difference. But if it were to make a difference that would be a huge problem, since it doesn't look through `repr(transparent)`!

Cc `@eddyb` `@bjorn3`
2023-08-28 19:53:55 +02:00
Ralf Jung
0d2cd6f650 remove an unused argument
it was already unused before, but due to the recursion the compiler did not realize
2023-08-28 18:21:16 +02:00
Ralf Jung
44401b89ad carry out the same changes in the gcc backend 2023-08-28 16:35:22 +02:00
Wesley Wiser
ec4a85e889 Revert "Use the same DISubprogram for each instance of the same inlined function within the caller"
This reverts commit 687bffa49375aa00bacc51f5d9adfb84a9453e17.

Reverting to resolve ICEs reported on nightly.
2023-08-25 19:49:10 -04:00
Guillaume Gomez
5ac2530d3c Add support for noalias function parameters 2023-08-25 22:39:22 +02:00
bors
17b7f1e198 Auto merge of #114643 - dpaoliello:inlinedebuginfo, r=wesleywiser
Use the same DISubprogram for each instance of the same inlined function within a caller

# Issue Details:
The call to `panic` within a function like `Option::unwrap` is translated to LLVM as a `tail call` (as it will never return), when multiple calls to the same function like this is inlined LLVM will notice the common `tail call` block (i.e., loading the same panic string + location info and then calling `panic`) and merge them together.

When merging these instructions together, LLVM will also attempt to merge the debug locations as well, but this fails (i.e., debug info is dropped) as Rust emits a new `DISubprogram` at each inline site thus LLVM doesn't recognize that these are actually the same function and so thinks that there isn't a common debug location.

As an example of this when building for x86_64 Windows (note the lack of `.cv_loc` before the call to `panic`, thus it will be attributed to the same line at the `addq` instruction):

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	leaq	.Lalloc_f570dea0a53168780ce9a91e67646421(%rip), %rcx
	leaq	.Lalloc_629ace53b7e5b76aaa810d549cc84ea3(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17h12e60b9063f6dee8E
	int3
```

# Fix Details:
Cache the `DISubprogram` emitted for each inlined function instance within a caller so that this can be reused if that instance is encountered again, this also requires caching the `DILexicalBlock` and `DIVariable` objects to avoid creating duplicates.

After this change the above assembly now looks like:

```
	.cv_loc	0 1 23 0                        # src\lib.rs:23:0
	addq	$40, %rsp
	retq
	.cv_inline_site_id 5 within 0 inlined_at 1 0 0
	.cv_inline_site_id 6 within 5 inlined_at 1 12 0
	.cv_loc	6 2 935 0                       # library\core\src\option.rs:935:0
	leaq	.Lalloc_5f55955de67e57c79064b537689facea(%rip), %rcx
	leaq	.Lalloc_e741d4de8cb5801e1fd7a6c6795c1559(%rip), %r8
	movl	$43, %edx
	callq	_ZN4core9panicking5panic17hde1558f32d5b1c04E
	int3
```
2023-08-22 20:15:29 +00:00