Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 12eb345

Browse files
committed
Auto merge of #146304 - matthiaskrgr:rollup-69hs07h, r=matthiaskrgr
Rollup of 4 pull requests Successful merges: - #146170 (fix: offline rustdoc html missing favicon) - #146209 (Misc LTO cleanups) - #146269 (feat(std): emulate flock for solaris via fcntl) - #146297 (Introduce PlaceContext::may_observe_address.) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 2371802 + 36557d1 commit 12eb345

File tree

17 files changed

+166
-87
lines changed

17 files changed

+166
-87
lines changed

‎compiler/rustc_codegen_gcc/src/back/lto.rs‎

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -305,12 +305,9 @@ pub(crate) fn run_thin(
305305
)
306306
}
307307

308-
pub(crate) fn prepare_thin(
309-
module: ModuleCodegen<GccContext>,
310-
_emit_summary: bool,
311-
) -> (String, ThinBuffer) {
308+
pub(crate) fn prepare_thin(module: ModuleCodegen<GccContext>) -> (String, ThinBuffer) {
312309
let name = module.name;
313-
//let buffer = ThinBuffer::new(module.module_llvm.context, true, emit_summary);
310+
//let buffer = ThinBuffer::new(module.module_llvm.context, true);
314311
let buffer = ThinBuffer::new(&module.module_llvm.context);
315312
(name, buffer)
316313
}
@@ -650,10 +647,6 @@ impl ThinBufferMethods for ThinBuffer {
650647
fn data(&self) -> &[u8] {
651648
&[]
652649
}
653-
654-
fn thin_link_data(&self) -> &[u8] {
655-
unimplemented!();
656-
}
657650
}
658651

659652
pub struct ThinData; //(Arc<TempDir>);

‎compiler/rustc_codegen_gcc/src/lib.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -408,11 +408,8 @@ impl WriteBackendMethods for GccCodegenBackend {
408408
back::write::codegen(cgcx, module, config)
409409
}
410410

411-
fn prepare_thin(
412-
module: ModuleCodegen<Self::Module>,
413-
emit_summary: bool,
414-
) -> (String, Self::ThinBuffer) {
415-
back::lto::prepare_thin(module, emit_summary)
411+
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
412+
back::lto::prepare_thin(module)
416413
}
417414

418415
fn serialize_module(_module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {

‎compiler/rustc_codegen_llvm/src/back/lto.rs‎

Lines changed: 12 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -185,12 +185,9 @@ pub(crate) fn run_thin(
185185
thin_lto(cgcx, dcx, modules, upstream_modules, cached_modules, &symbols_below_threshold)
186186
}
187187

188-
pub(crate) fn prepare_thin(
189-
module: ModuleCodegen<ModuleLlvm>,
190-
emit_summary: bool,
191-
) -> (String, ThinBuffer) {
188+
pub(crate) fn prepare_thin(module: ModuleCodegen<ModuleLlvm>) -> (String, ThinBuffer) {
192189
let name = module.name;
193-
let buffer = ThinBuffer::new(module.module_llvm.llmod(), true, emit_summary);
190+
let buffer = ThinBuffer::new(module.module_llvm.llmod(), true);
194191
(name, buffer)
195192
}
196193

@@ -687,9 +684,9 @@ unsafe impl Send for ThinBuffer {}
687684
unsafe impl Sync for ThinBuffer {}
688685

689686
impl ThinBuffer {
690-
pub(crate) fn new(m: &llvm::Module, is_thin: bool,emit_summary:bool) -> ThinBuffer {
687+
pub(crate) fn new(m: &llvm::Module, is_thin: bool) -> ThinBuffer {
691688
unsafe {
692-
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin, emit_summary);
689+
let buffer = llvm::LLVMRustThinLTOBufferCreate(m, is_thin);
693690
ThinBuffer(buffer)
694691
}
695692
}
@@ -698,21 +695,21 @@ impl ThinBuffer {
698695
let mut ptr = NonNull::new(ptr).unwrap();
699696
ThinBuffer(unsafe { ptr.as_mut() })
700697
}
701-
}
702698

703-
impl ThinBufferMethods for ThinBuffer {
704-
fn data(&self) -> &[u8] {
699+
pub(crate) fn thin_link_data(&self) -> &[u8] {
705700
unsafe {
706-
let ptr = llvm::LLVMRustThinLTOBufferPtr(self.0) as *const _;
707-
let len = llvm::LLVMRustThinLTOBufferLen(self.0);
701+
let ptr = llvm::LLVMRustThinLTOBufferThinLinkDataPtr(self.0) as *const _;
702+
let len = llvm::LLVMRustThinLTOBufferThinLinkDataLen(self.0);
708703
slice::from_raw_parts(ptr, len)
709704
}
710705
}
706+
}
711707

712-
fn thin_link_data(&self) -> &[u8] {
708+
impl ThinBufferMethods for ThinBuffer {
709+
fn data(&self) -> &[u8] {
713710
unsafe {
714-
let ptr = llvm::LLVMRustThinLTOBufferThinLinkDataPtr(self.0) as *const _;
715-
let len = llvm::LLVMRustThinLTOBufferThinLinkDataLen(self.0);
711+
let ptr = llvm::LLVMRustThinLTOBufferPtr(self.0) as *const _;
712+
let len = llvm::LLVMRustThinLTOBufferLen(self.0);
716713
slice::from_raw_parts(ptr, len)
717714
}
718715
}

‎compiler/rustc_codegen_llvm/src/back/write.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -837,7 +837,7 @@ pub(crate) fn codegen(
837837
"LLVM_module_codegen_make_bitcode",
838838
&*module.name,
839839
);
840-
ThinBuffer::new(llmod, config.emit_thin_lto,false)
840+
ThinBuffer::new(llmod, config.emit_thin_lto)
841841
};
842842
let data = thin.data();
843843
let _timer = cgcx

‎compiler/rustc_codegen_llvm/src/lib.rs‎

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -211,11 +211,8 @@ impl WriteBackendMethods for LlvmCodegenBackend {
211211
) -> CompiledModule {
212212
back::write::codegen(cgcx, module, config)
213213
}
214-
fn prepare_thin(
215-
module: ModuleCodegen<Self::Module>,
216-
emit_summary: bool,
217-
) -> (String, Self::ThinBuffer) {
218-
back::lto::prepare_thin(module, emit_summary)
214+
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer) {
215+
back::lto::prepare_thin(module)
219216
}
220217
fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer) {
221218
(module.name, back::lto::ModuleBuffer::new(module.module_llvm.llmod()))

‎compiler/rustc_codegen_llvm/src/llvm/ffi.rs‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,7 +2602,6 @@ unsafe extern "C" {
26022602
pub(crate) fn LLVMRustThinLTOBufferCreate(
26032603
M: &Module,
26042604
is_thin: bool,
2605-
emit_summary: bool,
26062605
) -> &'static mut ThinLTOBuffer;
26072606
pub(crate) fn LLVMRustThinLTOBufferFree(M: &'static mut ThinLTOBuffer);
26082607
pub(crate) fn LLVMRustThinLTOBufferPtr(M: &ThinLTOBuffer) -> *const c_char;

‎compiler/rustc_codegen_ssa/src/back/write.rs‎

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -830,6 +830,8 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
830830
cgcx: &CodegenContext<B>,
831831
mut module: ModuleCodegen<B::Module>,
832832
) -> WorkItemResult<B> {
833+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_optimize", &*module.name);
834+
833835
let dcx = cgcx.create_dcx();
834836
let dcx = dcx.handle();
835837

@@ -862,7 +864,7 @@ fn execute_optimize_work_item<B: ExtraBackendMethods>(
862864
WorkItemResult::Finished(module)
863865
}
864866
ComputedLtoType::Thin => {
865-
let (name, thin_buffer) = B::prepare_thin(module,false);
867+
let (name, thin_buffer) = B::prepare_thin(module);
866868
if let Some(path) = bitcode {
867869
fs::write(&path, thin_buffer.data()).unwrap_or_else(|e| {
868870
panic!("Error writing pre-lto-bitcode file `{}`: {}", path.display(), e);
@@ -890,6 +892,10 @@ fn execute_copy_from_cache_work_item<B: ExtraBackendMethods>(
890892
cgcx: &CodegenContext<B>,
891893
module: CachedModuleCodegen,
892894
) -> WorkItemResult<B> {
895+
let _timer = cgcx
896+
.prof
897+
.generic_activity_with_arg("codegen_copy_artifacts_from_incr_cache", &*module.name);
898+
893899
let incr_comp_session_dir = cgcx.incr_comp_session_dir.as_ref().unwrap();
894900

895901
let mut links_from_incr_cache = Vec::new();
@@ -977,6 +983,8 @@ fn execute_fat_lto_work_item<B: ExtraBackendMethods>(
977983
mut needs_fat_lto: Vec<FatLtoInput<B>>,
978984
import_only_modules: Vec<(SerializedModule<B::ModuleBuffer>, WorkProduct)>,
979985
) -> WorkItemResult<B> {
986+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", "everything");
987+
980988
for (module, wp) in import_only_modules {
981989
needs_fat_lto.push(FatLtoInput::Serialized { name: wp.cgu_name, buffer: module })
982990
}
@@ -995,6 +1003,8 @@ fn execute_thin_lto_work_item<B: ExtraBackendMethods>(
9951003
cgcx: &CodegenContext<B>,
9961004
module: lto::ThinModule<B>,
9971005
) -> WorkItemResult<B> {
1006+
let _timer = cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", module.name());
1007+
9981008
let module = B::optimize_thin(cgcx, module);
9991009
let module = B::codegen(cgcx, module, &cgcx.module_config);
10001010
WorkItemResult::Finished(module)
@@ -1714,38 +1724,21 @@ fn spawn_work<'a, B: ExtraBackendMethods>(
17141724

17151725
B::spawn_named_thread(cgcx.time_trace, work.short_description(), move || {
17161726
let result = std::panic::catch_unwind(AssertUnwindSafe(|| match work {
1717-
WorkItem::Optimize(m) => {
1718-
let _timer =
1719-
cgcx.prof.generic_activity_with_arg("codegen_module_optimize", &*m.name);
1720-
execute_optimize_work_item(&cgcx, m)
1721-
}
1722-
WorkItem::CopyPostLtoArtifacts(m) => {
1723-
let _timer = cgcx
1724-
.prof
1725-
.generic_activity_with_arg("codegen_copy_artifacts_from_incr_cache", &*m.name);
1726-
execute_copy_from_cache_work_item(&cgcx, m)
1727-
}
1727+
WorkItem::Optimize(m) => execute_optimize_work_item(&cgcx, m),
1728+
WorkItem::CopyPostLtoArtifacts(m) => execute_copy_from_cache_work_item(&cgcx, m),
17281729
WorkItem::FatLto {
17291730
exported_symbols_for_lto,
17301731
each_linked_rlib_for_lto,
17311732
needs_fat_lto,
17321733
import_only_modules,
1733-
} => {
1734-
let _timer =
1735-
cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", "everything");
1736-
execute_fat_lto_work_item(
1737-
&cgcx,
1738-
&exported_symbols_for_lto,
1739-
&each_linked_rlib_for_lto,
1740-
needs_fat_lto,
1741-
import_only_modules,
1742-
)
1743-
}
1744-
WorkItem::ThinLto(m) => {
1745-
let _timer =
1746-
cgcx.prof.generic_activity_with_arg("codegen_module_perform_lto", m.name());
1747-
execute_thin_lto_work_item(&cgcx, m)
1748-
}
1734+
} => execute_fat_lto_work_item(
1735+
&cgcx,
1736+
&exported_symbols_for_lto,
1737+
&each_linked_rlib_for_lto,
1738+
needs_fat_lto,
1739+
import_only_modules,
1740+
),
1741+
WorkItem::ThinLto(m) => execute_thin_lto_work_item(&cgcx, m),
17491742
}));
17501743

17511744
let msg = match result {

‎compiler/rustc_codegen_ssa/src/traits/write.rs‎

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,16 +50,12 @@ pub trait WriteBackendMethods: Clone + 'static {
5050
module: ModuleCodegen<Self::Module>,
5151
config: &ModuleConfig,
5252
) -> CompiledModule;
53-
fn prepare_thin(
54-
module: ModuleCodegen<Self::Module>,
55-
want_summary: bool,
56-
) -> (String, Self::ThinBuffer);
53+
fn prepare_thin(module: ModuleCodegen<Self::Module>) -> (String, Self::ThinBuffer);
5754
fn serialize_module(module: ModuleCodegen<Self::Module>) -> (String, Self::ModuleBuffer);
5855
}
5956

6057
pub trait ThinBufferMethods: Send + Sync {
6158
fn data(&self) -> &[u8];
62-
fn thin_link_data(&self) -> &[u8];
6359
}
6460

6561
pub trait ModuleBufferMethods: Send + Sync {

‎compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp‎

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1568,12 +1568,11 @@ extern "C" bool LLVMRustPrepareThinLTOImport(const LLVMRustThinLTOData *Data,
15681568
return true;
15691569
}
15701570

1571-
extern "C" LLVMRustThinLTOBuffer *
1572-
LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin, bool emit_summary) {
1571+
extern "C" LLVMRustThinLTOBuffer *LLVMRustThinLTOBufferCreate(LLVMModuleRef M,
1572+
bool is_thin) {
15731573
auto Ret = std::make_unique<LLVMRustThinLTOBuffer>();
15741574
{
15751575
auto OS = raw_string_ostream(Ret->data);
1576-
auto ThinLinkOS = raw_string_ostream(Ret->thin_link_data);
15771576
{
15781577
if (is_thin) {
15791578
PassBuilder PB;
@@ -1587,11 +1586,7 @@ LLVMRustThinLTOBufferCreate(LLVMModuleRef M, bool is_thin, bool emit_summary) {
15871586
PB.registerLoopAnalyses(LAM);
15881587
PB.crossRegisterProxies(LAM, FAM, CGAM, MAM);
15891588
ModulePassManager MPM;
1590-
// We only pass ThinLinkOS to be filled in if we want the summary,
1591-
// because otherwise LLVM does extra work and may double-emit some
1592-
// errors or warnings.
1593-
MPM.addPass(
1594-
ThinLTOBitcodeWriterPass(OS, emit_summary ? &ThinLinkOS : nullptr));
1589+
MPM.addPass(ThinLTOBitcodeWriterPass(OS, nullptr));
15951590
MPM.run(*unwrap(M), MAM);
15961591
} else {
15971592
WriteBitcodeToFile(*unwrap(M), OS);

‎compiler/rustc_middle/src/mir/visit.rs‎

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,6 +1415,24 @@ impl PlaceContext {
14151415
)
14161416
}
14171417

1418+
/// Returns `true` if this place context may be used to know the address of the given place.
1419+
#[inline]
1420+
pub fn may_observe_address(self) -> bool {
1421+
matches!(
1422+
self,
1423+
PlaceContext::NonMutatingUse(
1424+
NonMutatingUseContext::SharedBorrow
1425+
| NonMutatingUseContext::RawBorrow
1426+
| NonMutatingUseContext::FakeBorrow
1427+
) | PlaceContext::MutatingUse(
1428+
MutatingUseContext::Drop
1429+
| MutatingUseContext::Borrow
1430+
| MutatingUseContext::RawBorrow
1431+
| MutatingUseContext::AsmOutput
1432+
)
1433+
)
1434+
}
1435+
14181436
/// Returns `true` if this place context represents a storage live or storage dead marker.
14191437
#[inline]
14201438
pub fn is_storage_marker(self) -> bool {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /