about summary refs log tree commit diff
path: root/src/test/assembly
AgeCommit message (Collapse)AuthorLines
2023-01-11Move /src/test to /testsAlbert Larsan-6608/+0
2023-01-05Add vendor to Fuchsia's target tripleDavid Koloski-2/+2
Historically, Rust's Fuchsia targets have been labeled x86_64-fuchsia and aarch64-fuchsia. However, they should technically contain vendor information. This CL changes Fuchsia's target triples to include the "unknown" vendor since Clang now does normalization and handles all triple spellings. This was previously attempted in #90510, which was closed due to inactivity.
2022-12-20Add `-Zno-jump-tables`Miguel Ojeda-0/+34
This flag mimics GCC/Clang's `-fno-jump-tables` [1][2], which makes the codegen backend avoid generating jump tables when lowering switches. In the case of LLVM, the `"no-jump-tables"="true"` function attribute is added to every function. The kernel currently needs it for x86 when enabling IBT [3], as well as for Alpha (plus VDSO objects in MIPS/LoongArch). [1] https://gcc.gnu.org/onlinedocs/gcc/Code-Gen-Options.html#index-fno-jump-tables [2] https://clang.llvm.org/docs/ClangCommandLineReference.html#cmdoption-clang-fjump-tables [3] https://github.com/torvalds/linux/blob/v6.1/arch/x86/Makefile#L75-L83 Signed-off-by: Miguel Ojeda <ojeda@kernel.org>
2022-12-02Rollup merge of #105033 - durin42:llvm-16-dont-tail-call-me-bro, r=tmandryMatthias Krüger-0/+5
sparc-struct-abi: work around new tail-call optimization Upstream LLVM change https://reviews.llvm.org/D138741 introduced some new tail-call smarts for SPARC which broke some of the checks in this test. Rather than adjust the test expectations, we add an extra no-args function that can get tail-called or not without hurting the needs of the test. r? ``@nikic``
2022-11-29v8a as default aarch64 targetTommy Chiang (oToToT)-0/+37
After https://github.com/llvm/llvm-project/commit/8689f5e landed, LLVM takes the intersection of v8a and v8r as default. This commit brings back v8a support by explicitly specifying v8a in the feature list. This should solve #97724.
2022-11-28sparc-struct-abi: work around new tail-call optimizationAugie Fackler-0/+5
Upstream LLVM change https://reviews.llvm.org/D138741 introduced some new tail-call smarts for SPARC which broke some of the checks in this test. Rather than adjust the test expectations, we add an extra no-args function that can get tail-called or not without hurting the needs of the test.
2022-11-19fix assembly test on appleLukas Markeffsky-5/+5
2022-11-19fix assembly test on windowsLukas Markeffsky-10/+10
2022-11-19always use `align_offset` in `is_aligned_to` + add assembly testLukas Markeffsky-0/+58
2022-11-06Add a codegen test for rust-lang/rust#96152Ben Kimock-0/+37
2022-10-17Stabilize asm_symAmanieu d'Antras-15/+17
2022-09-29Enable inline stack probes on X86 with LLVM 16Josh Stone-0/+42
2022-08-21Rollup merge of #100556 - Alex-Velez:patch-1, r=scottmcmMatthias Krüger-0/+25
Clamp Function for f32 and f64 I thought the clamp function could use a little improvement for readability purposes. The function now returns early in order to skip the extra bound checks. If there was a reason for binding `self` to `x` or if this code is incorrect, please correct me :)
2022-08-20Allow other directives before the `ret`scottmcm-1/+1
2022-08-16Update src/test/assembly/x86_64-floating-point-clamp.rsAlex-1/+1
Co-authored-by: scottmcm <scottmcm@users.noreply.github.com>
2022-08-16Update src/test/assembly/x86_64-floating-point-clamp.rsAlex-0/+25
Simple Clamp Function I thought this was more robust and easier to read. I also allowed this function to return early in order to skip the extra bound check (I'm sure the difference is negligible). I'm not sure if there was a reason for binding `self` to `x`; if so, please correct me. Simple Clamp Function for f64 I thought this was more robust and easier to read. I also allowed this function to return early in order to skip the extra bound check (I'm sure the difference is negligible). I'm not sure if there was a reason for binding `self` to `x`; if so, please correct me. Floating point clamp test f32 clamp using mut self f64 clamp using mut self Update library/core/src/num/f32.rs Update f64.rs Update x86_64-floating-point-clamp.rs Update src/test/assembly/x86_64-floating-point-clamp.rs Update x86_64-floating-point-clamp.rs Co-Authored-By: scottmcm <scottmcm@users.noreply.github.com>
2022-08-14Update the minimum external LLVM to 13Josh Stone-7/+0
2022-08-02RISC-V ASM test: relax label name constraint.Tim Neumann-1/+1
2022-07-20adapt assembly/static-relocation-model test for LLVM changeKrasimir Georgiev-3/+4
After https://github.com/llvm/llvm-project/commit/f0dd12ec5c0169ba5b4363b62d59511181cf954a, LLVM emits `movzbl` instead. Adapted this test case accordingly. Discovered in our experimental rust + llvm at head ci: https://buildkite.com/llvm-project/rust-llvm-integrate-prototype/builds/12104#0182195b-8791-4f88-853c-bb23a1e4b54c
2022-07-18Rollup merge of #98998 - ↵Dylan DPC-0/+45
workingjubilee:naked-means-no-clothes-enforcement-technology, r=Amanieu Remove branch target prologues from `#[naked] fn` This patch hacks around rust-lang/rust#98768 for now via injecting appropriate attributes into the LLVMIR we emit for naked functions. I intend to pursue this upstream so that these attributes can be removed in general, but it's slow going wading through C++ for me.
2022-07-16Auto merge of #98866 - nagisa:nagisa/align-offset-wroom, r=Mark-Simulacrumbors-0/+48
Add a special case for align_offset /w stride != 1 This generalizes the previous `stride == 1` special case to apply to any situation where the requested alignment is divisible by the stride. This in turn allows the test case from #98809 produce ideal assembly, along the lines of: leaq 15(%rdi), %rax andq $-16, %rax This also produces pretty high quality code for situations where the alignment of the input pointer isn’t known: pub unsafe fn ptr_u32(slice: *const u32) -> *const u32 { slice.offset(slice.align_offset(16) as isize) } // => movl %edi, %eax andl $3, %eax leaq 15(%rdi), %rcx andq $-16, %rcx subq %rdi, %rcx shrq $2, %rcx negq %rax sbbq %rax, %rax orq %rcx, %rax leaq (%rdi,%rax,4), %rax Here LLVM is smart enough to replace the `usize::MAX` special case with a branch-less bitwise-OR approach, where the mask is constructed using the neg and sbb instructions. This appears to work across various architectures I’ve tried. This change ends up introducing more branches and code in situations where there is less knowledge of the arguments. For example when the requested alignment is entirely unknown. This use-case was never really a focus of this function, so I’m not particularly worried, especially since llvm-mca is saying that the new code is still appreciably faster, despite all the new branching. Fixes #98809. Sadly, this does not help with #72356.
2022-07-17Add a special case for align_offset /w stride != 1Simonas Kazlauskas-0/+48
This generalizes the previous `stride == 1` special case to apply to any situation where the requested alignment is divisible by the stride. This in turn allows the test case from #98809 produce ideal assembly, along the lines of: leaq 15(%rdi), %rax andq $-16, %rax This also produces pretty high quality code for situations where the alignment of the input pointer isn’t known: pub unsafe fn ptr_u32(slice: *const u32) -> *const u32 { slice.offset(slice.align_offset(16) as isize) } // => movl %edi, %eax andl $3, %eax leaq 15(%rdi), %rcx andq $-16, %rcx subq %rdi, %rcx shrq $2, %rcx negq %rax sbbq %rax, %rax orq %rcx, %rax leaq (%rdi,%rax,4), %rax Here LLVM is smart enough to replace the `usize::MAX` special case with a branch-less bitwise-OR approach, where the mask is constructed using the neg and sbb instructions. This appears to work across various architectures I’ve tried. This change ends up introducing more branches and code in situations where there is less knowledge of the arguments. For example when the requested alignment is entirely unknown. This use-case was never really a focus of this function, so I’m not particularly worried, especially since llvm-mca is saying that the new code is still appreciably faster, despite all the new branching. Fixes #98809. Sadly, this does not help with #72356.
2022-07-08Implement support for DWARF version 5.Patrick Walton-0/+20
DWARF version 5 brings a number of improvements over version 4. Quoting from the announcement [1]: > Version 5 incorporates improvements in many areas: better data compression, > separation of debugging data from executable files, improved description of > macros and source files, faster searching for symbols, improved debugging > optimized code, as well as numerous improvements in functionality and > performance. On platforms where DWARF version 5 is supported (Linux, primarily), this commit adds support for it behind a new `-Z dwarf-version=5` flag. [1]: https://dwarfstd.org/Public_Review.php
2022-07-06Also stop emitting BTI prologues for naked functionsJubilee Young-0/+21
Same idea but for AArch64.
2022-07-06Stop emitting CET prologues for naked functionsJubilee Young-0/+24
We can apply nocf_check as a hack for now.
2022-06-07hexagon: adapt test for upstream output changesAugie Fackler-3/+3
The output of IR formatting changed slightly in upstream rev a0bc67e555f404d0e7ddb2e78cb891d96eaf913d (https://reviews.llvm.org/D123096). I'm not actually sure what any of that means, as I don't even know what hexagon is in this context, but this change allows the test to pass on both old and new LLVMs. r? @nikic
2022-05-25Fix stack protector basic testNikita Popov-1/+1
This is a >= condition, so we need a maximum size of 7 to not create a stack protector in basic mode. The reason this still worked is that the alloca type was converted into an integer (rather than an array). The way these heuristics are implemented in LLVM is rather questionable and not resilient to optimization.
2022-05-03Collect function instance used in `global_asm!` sym operandTomasz Miąsko-0/+5
The constants used in SymFn operands have FnDef type, so the type of the constant identifies the function.
2022-04-26Rollup merge of #94703 - kjetilkjeka:nvptx-kernel-args-abi2, r=nagisaGuillaume Gomez-0/+254
Fix codegen bug in "ptx-kernel" abi related to arg passing I found a codegen bug in the nvptx abi related to that args are passed as ptrs ([see comment](https://github.com/rust-lang/rust/issues/38788#issuecomment-1048999928)), this is not as specified in the [ptx-interoperability doc](https://docs.nvidia.com/cuda/ptx-writers-guide-to-interoperability/) or how C/C++ does it. It will also almost always fail in practice since device/host uses different memory spaces for most hardware. This PR fixes the bug and add tests for passing structs to ptx kernels. I observed that all nvptx assembly tests had been marked as [ignore a long time ago](https://github.com/rust-lang/rust/pull/59752#issuecomment-501713428). I'm not sure if the new one should be marked as ignore, it passed on my computer but it might fail if ptx-linker is missing on the server? I guess this is outside scope for this PR and should be looked at in a different issue/PR. I only fixed the nvptx64-nvidia-cuda target and not the potential code paths for the non-existing 32bit target. Even though 32bit nvptx is not a supported target there are still some code under the hood supporting codegen for 32 bit ptx. I was advised to create an MCP to find out if this code should be removed or updated. Perhaps ``@RDambrosio016`` would have interest in taking a quick look at this.
2022-04-25Add test for asserting correct generation of ptx-kernel argsKjetil Kjeka-0/+254
2022-04-16Update tests for sym support in global_asm!Amanieu d'Antras-1/+12
2022-03-10short-circuit the easy cases in `is_copy_modulo_regions`Scott McMurray-0/+2
This change is somewhat extensive, since it affects MIR -- since this is called to determine Copy vs Move -- so any test that's `no_core` needs to actually have the normal `impl`s it uses.
2022-01-22Add preliminary support for inline assembly for msp430.William D. Jones-0/+158
2021-12-29Auto merge of #88354 - Jmc18134:hint-space-pauth-opt, r=nagisabors-0/+22
Add codegen option for branch protection and pointer authentication on AArch64 The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets.
2021-12-12Address review feedbackAmanieu d'Antras-3/+3
2021-12-12Stabilize asm! and global_asm!Amanieu d'Antras-7/+11
They are also removed from the prelude as per the decision in https://github.com/rust-lang/rust/issues/87228. stdarch and compiler-builtins are updated to work with the new, stable asm! and global_asm! macros.
2021-12-07Remove the reg_thumb register class for asm! on ARMAmanieu d'Antras-36/+0
Also restricts r8-r14 from being used on Thumb1 targets as per #90736.
2021-12-06Implement inline asm! for AVR platformAndrew Dona-Couch-0/+282
2021-12-02Auto merge of #91003 - psumbera:sparc64-abi, r=nagisabors-0/+64
fix sparc64 ABI for aggregates with floating point members Fixes #86163
2021-12-01Review commentsJamie Cunliffe-1/+1
- Changed the separator from '+' to ','. - Moved the branch protection options from -C to -Z. - Additional test for incorrect branch-protection option. - Remove LLVM < 12 code. - Style fixes. Co-authored-by: James McGregor <james.mcgregor2@arm.com>
2021-12-01Add codegen option for branch protection and pointer authentication on AArch64James McGregor-0/+22
The branch-protection codegen option enables the use of hint-space pointer authentication code for AArch64 targets
2021-12-01fix sparc64 ABI for aggregates with floating point membersPetr Sumbera-0/+64
2021-11-22add rustc option for using LLVM stack smash protectionBenjamin A. Bjørnseth-0/+682
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-11-07Add features gates for experimental asm featuresAmanieu d'Antras-12/+12
2021-10-22Update the minimum external LLVM to 12Josh Stone-5/+1
2021-10-22Update the minimum external LLVM to 11Josh Stone-14/+2
2021-10-15test fix: aarch64 atomics are only outlined on Linux.Hans Kratz-0/+1
2021-10-09Fix min LLVM version for bpf-types testAlessandro Decina-1/+1
Closes #89689
2021-10-04Rollup merge of #83655 - sebpop:arm64-outline-atomics, r=workingjubileeJubilee-0/+16
[aarch64] add target feature outline-atomics Enable outline-atomics by default as enabled in clang by the following commit https://reviews.llvm.org/rGc5e7e649d537067dec7111f3de1430d0fc8a4d11 Performance improves by several orders of magnitude when using the LSE instructions instead of the ARMv8.0 compatible load/store exclusive instructions. Tested on Graviton2 aarch64-linux with x.py build && x.py install && x.py test
2021-10-01Rollup merge of #88820 - hlopko:add_pie_relocation_model, r=petrochenkovManish Goregaokar-0/+73
Add `pie` as another `relocation-model` value MCP: https://github.com/rust-lang/compiler-team/issues/461