Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d8cc575
std_detect Darwin AArch64: add new-style detection for FEAT_CRC32
pthariensflame Sep 10, 2025
edc87e3
std_detect Darwin AArch64: re-alphabetize
pthariensflame Sep 14, 2025
d49f6a7
std_detect Darwin AArch64: synchronize features
pthariensflame Sep 14, 2025
3847786
bootstrap: Don't force -static for musl targets in cc-rs
Gelbpunkt Sep 15, 2025
f4b8768
Support ctr and lr as clobber-only registers in PowerPC inline assembly
taiki-e Sep 21, 2025
2dfcd09
btree InternalNode::new safety comments
hkBst Sep 21, 2025
8886790
Add panic=immediate-abort
saethlin Sep 7, 2025
df58fd8
Change the cfg to a dash
saethlin Sep 18, 2025
aef02fb
Explain tests and setting cfgs
saethlin Sep 21, 2025
5f0a68e
regression test for https://github.com/rust-lang/rust/issues/117763
the8472 Aug 14, 2025
b3c2435
Make mips64el-unknown-linux-muslabi64 link dynamically
Gelbpunkt Sep 21, 2025
3565b06
emit attribute for readonly non-pure inline assembly
folkertdev Sep 19, 2025
c54a953
Early return in `visibility_print_with_space`
yotamofek Sep 21, 2025
cdf9661
Re-use some existing util fns
yotamofek Sep 21, 2025
2067160
Introduce "wrapper" helpers to rustdoc
yotamofek Sep 21, 2025
ce78d6f
port `#[feature]` to the new attribute parsing infrastructure
jdonszelmann Aug 24, 2025
858e26c
use feature parser throughout the compiler
jdonszelmann Sep 16, 2025
5d77369
Rollup merge of #145411 - the8472:cows-have-no-branches, r=Mark-Simul…
Zalathar Sep 22, 2025
cf662e3
Rollup merge of #146317 - saethlin:panic=immediate-abort, r=nnethercote
Zalathar Sep 22, 2025
8ff0836
Rollup merge of #146397 - pthariensflame:patch-1, r=Amanieu
Zalathar Sep 22, 2025
63a296a
Rollup merge of #146594 - Gelbpunkt:bootstrap-musl-static, r=Mark-Sim…
Zalathar Sep 22, 2025
ce358ff
Rollup merge of #146652 - jdonszelmann:convert-feature-attr-parser, r…
Zalathar Sep 22, 2025
a25ee5a
Rollup merge of #146791 - folkertdev:readonly-not-pure, r=nikic,josht…
Zalathar Sep 22, 2025
feede06
Rollup merge of #146831 - taiki-e:powerpc-clobber, r=Amanieu
Zalathar Sep 22, 2025
b2866fc
Rollup merge of #146838 - yotamofek:pr/rustdoc/wrappers, r=lolbinarycat
Zalathar Sep 22, 2025
1119d33
Rollup merge of #146846 - hkBst:btree-2, r=tgross35
Zalathar Sep 22, 2025
6335498
Rollup merge of #146858 - Gelbpunkt:mips64el-musl-dynamic, r=jieyouxu
Zalathar Sep 22, 2025
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions compiler/rustc_codegen_llvm/src/asm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,8 +340,8 @@ impl<'ll, 'tcx> AsmBuilderMethods<'tcx> for Builder<'_, 'll, 'tcx> {
attrs.push(llvm::AttributeKind::WillReturn.create_attr(self.cx.llcx));
} else if options.contains(InlineAsmOptions::NOMEM) {
attrs.push(llvm::MemoryEffects::InaccessibleMemOnly.create_attr(self.cx.llcx));
} else {
// LLVM doesn't have an attribute to represent ReadOnly + SideEffect
} else if options.contains(InlineAsmOptions::READONLY) {
attrs.push(llvm::MemoryEffects::ReadOnlyNotPure.create_attr(self.cx.llcx));
}
attributes::apply_to_callsite(result, llvm::AttributePlace::Function, &{ attrs });

Expand Down
1 change: 1 addition & 0 deletions compiler/rustc_codegen_llvm/src/llvm/ffi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -710,6 +710,7 @@ pub(crate) enum MemoryEffects {
None,
ReadOnly,
InaccessibleMemOnly,
ReadOnlyNotPure,
}

/// LLVMOpcode
Expand Down
5 changes: 5 additions & 0 deletions compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,6 +553,7 @@ enum class LLVMRustMemoryEffects {
None,
ReadOnly,
InaccessibleMemOnly,
ReadOnlyNotPure,
};

extern "C" LLVMAttributeRef
Expand All @@ -568,6 +569,10 @@ LLVMRustCreateMemoryEffectsAttr(LLVMContextRef C,
case LLVMRustMemoryEffects::InaccessibleMemOnly:
return wrap(Attribute::getWithMemoryEffects(
*unwrap(C), MemoryEffects::inaccessibleMemOnly()));
case LLVMRustMemoryEffects::ReadOnlyNotPure:
return wrap(Attribute::getWithMemoryEffects(
*unwrap(C),
MemoryEffects::readOnly() | MemoryEffects::inaccessibleMemOnly()));
default:
report_fatal_error("bad MemoryEffects.");
}
Expand Down
48 changes: 48 additions & 0 deletions tests/codegen-llvm/asm/readonly-not-pure.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
//@ add-core-stubs
//@ compile-flags: -Copt-level=3 --target x86_64-unknown-linux-gnu
//@ needs-llvm-components: x86

#![crate_type = "rlib"]
#![feature(no_core)]
#![no_core]

// Test that when an inline assembly block specifies `readonly` but not `pure`, a detailed
// `MemoryEffects` is provided to LLVM: this assembly block is not allowed to perform writes,
// but it may have side-effects.

extern crate minicore;
use minicore::*;

pub static mut VAR: i32 = 0;

// CHECK-LABEL: @no_options
// CHECK: call i32 asm
#[no_mangle]
pub unsafe fn no_options() -> i32 {
VAR = 1;
let _ignored: i32;
asm!("mov {0}, 1", out(reg) _ignored);
VAR
}

// CHECK-LABEL: @readonly_pure
// CHECK-NOT: call i32 asm
#[no_mangle]
pub unsafe fn readonly_pure() -> i32 {
VAR = 1;
let _ignored: i32;
asm!("mov {0}, 1", out(reg) _ignored, options(pure, readonly));
VAR
}

// CHECK-LABEL: @readonly_not_pure
// CHECK: call i32 asm {{.*}} #[[ATTR:[0-9]+]]
#[no_mangle]
pub unsafe fn readonly_not_pure() -> i32 {
VAR = 1;
let _ignored: i32;
asm!("mov {0}, 1", out(reg) _ignored, options(readonly));
VAR
}

// CHECK: attributes #[[ATTR]] = { nounwind memory(read, inaccessiblemem: readwrite) }