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 9748d87

Browse files
committed
Auto merge of #144269 - jieyouxu:rollup-137ysl2, r=jieyouxu
Rollup of 14 pull requests Successful merges: - #142097 (gpu offload host code generation) - #143430 (Lower extra lifetimes before normal generic params.) - #143768 (Constify Try, From, TryFrom and relevant traits) - #143816 (Implement `check` for compiletest and RA using tool macro) - #143985 (rustc_public: de-StableMIR-ize) - #144027 (clippy: make tests work in stage 1) - #144080 (Mitigate `#[align]` name resolution ambiguity regression with a rename) - #144176 (Add approval blocking labels for new bors) - #144187 (fix handling of base address for TypeId allocations) - #144212 (Remove the ptr_unique lang item) - #144243 (Subtree update of `rust-analyzer`) - #144246 (Don't use another main test file as auxiliary) - #144251 (rustc-dev-guide subtree update) - #144254 (opt-dist: make `artifact-dir` an absolute path for `opt-dist local`) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 3f9f20f + 6628a4a commit 9748d87

File tree

185 files changed

+2120
-1166
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

185 files changed

+2120
-1166
lines changed

‎compiler/rustc_ast_lowering/src/lib.rs‎

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -874,25 +874,32 @@ impl<'a, 'hir> LoweringContext<'a, 'hir> {
874874
/// name resolver owing to lifetime elision; this also populates the resolver's node-id->def-id
875875
/// map, so that later calls to `opt_node_id_to_def_id` that refer to these extra lifetime
876876
/// parameters will be successful.
877-
#[instrument(level = "debug", skip(self))]
877+
#[instrument(level = "debug", skip(self), ret)]
878878
#[inline]
879879
fn lower_lifetime_binder(
880880
&mut self,
881881
binder: NodeId,
882882
generic_params: &[GenericParam],
883883
) -> &'hir [hir::GenericParam<'hir>] {
884-
let mut generic_params: Vec<_> = self
885-
.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder)
886-
.collect();
884+
// Start by creating params for extra lifetimes params, as this creates the definitions
885+
// that may be referred to by the AST inside `generic_params`.
887886
let extra_lifetimes = self.resolver.extra_lifetime_params(binder);
888887
debug!(?extra_lifetimes);
889-
generic_params.extend(extra_lifetimes.into_iter().filter_map(|(ident, node_id, res)| {
890-
self.lifetime_res_to_generic_param(ident, node_id, res, hir::GenericParamSource::Binder)
891-
}));
892-
let generic_params = self.arena.alloc_from_iter(generic_params);
893-
debug!(?generic_params);
894-
895-
generic_params
888+
let extra_lifetimes: Vec<_> = extra_lifetimes
889+
.into_iter()
890+
.filter_map(|(ident, node_id, res)| {
891+
self.lifetime_res_to_generic_param(
892+
ident,
893+
node_id,
894+
res,
895+
hir::GenericParamSource::Binder,
896+
)
897+
})
898+
.collect();
899+
let arena = self.arena;
900+
let explicit_generic_params =
901+
self.lower_generic_params_mut(generic_params, hir::GenericParamSource::Binder);
902+
arena.alloc_from_iter(explicit_generic_params.chain(extra_lifetimes.into_iter()))
896903
}
897904

898905
fn with_dyn_type_scope<T>(&mut self, in_scope: bool, f: impl FnOnce(&mut Self) -> T) -> T {

‎compiler/rustc_attr_data_structures/src/attributes.rs‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -234,6 +234,7 @@ pub enum CfgEntry {
234234
pub enum AttributeKind {
235235
// tidy-alphabetical-start
236236
/// Represents `#[align(N)]`.
237+
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
237238
Align { align: Align, span: Span },
238239

239240
/// Represents `#[rustc_allow_const_fn_unstable]`.

‎compiler/rustc_attr_parsing/src/attributes/codegen_attrs.rs‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ impl<S: Stage> AttributeParser<S> for NakedParser {
177177
sym::instruction_set,
178178
sym::repr,
179179
sym::rustc_std_internal_symbol,
180-
sym::align,
180+
// FIXME(#82232, #143834): temporarily renamed to mitigate `#[align]` nameres ambiguity
181+
sym::rustc_align,
181182
// obviously compatible with self
182183
sym::naked,
183184
// documentation

‎compiler/rustc_attr_parsing/src/attributes/repr.rs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ fn parse_alignment(node: &LitKind) -> Result<Align, &'static str> {
274274
pub(crate) struct AlignParser(Option<(Align, Span)>);
275275

276276
impl AlignParser {
277-
const PATH: &'static [Symbol] = &[sym::align];
277+
const PATH: &'static [Symbol] = &[sym::rustc_align];
278278
const TEMPLATE: AttributeTemplate = template!(List: "<alignment in bytes>");
279279

280280
fn parse<'c, S: Stage>(

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ pub(crate) fn run_pass_manager(
654654
// We then run the llvm_optimize function a second time, to optimize the code which we generated
655655
// in the enzyme differentiation pass.
656656
let enable_ad = config.autodiff.contains(&config::AutoDiff::Enable);
657+
let enable_gpu = config.offload.contains(&config::Offload::Enable);
657658
let stage = if thin {
658659
write::AutodiffStage::PreAD
659660
} else {
@@ -668,6 +669,12 @@ pub(crate) fn run_pass_manager(
668669
write::llvm_optimize(cgcx, dcx, module, None, config, opt_level, opt_stage, stage)?;
669670
}
670671

672+
if enable_gpu && !thin {
673+
let cx =
674+
SimpleCx::new(module.module_llvm.llmod(), &module.module_llvm.llcx, cgcx.pointer_size);
675+
crate::builder::gpu_offload::handle_gpu_code(cgcx, &cx);
676+
}
677+
671678
if cfg!(llvm_enzyme) && enable_ad && !thin {
672679
let cx =
673680
SimpleCx::new(module.module_llvm.llmod(), &module.module_llvm.llcx, cgcx.pointer_size);

‎compiler/rustc_codegen_llvm/src/builder.rs‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use std::ops::Deref;
33
use std::{iter, ptr};
44

55
pub(crate) mod autodiff;
6+
pub(crate) mod gpu_offload;
67

78
use libc::{c_char, c_uint, size_t};
89
use rustc_abi as abi;
@@ -117,6 +118,74 @@ impl<'a, 'll, CX: Borrow<SCx<'ll>>> GenericBuilder<'a, 'll, CX> {
117118
}
118119
bx
119120
}
121+
122+
// The generic builder has less functionality and thus (unlike the other alloca) we can not
123+
// easily jump to the beginning of the function to place our allocas there. We trust the user
124+
// to manually do that. FIXME(offload): improve the genericCx and add more llvm wrappers to
125+
// handle this.
126+
pub(crate) fn direct_alloca(&mut self, ty: &'ll Type, align: Align, name: &str) -> &'ll Value {
127+
let val = unsafe {
128+
let alloca = llvm::LLVMBuildAlloca(self.llbuilder, ty, UNNAMED);
129+
llvm::LLVMSetAlignment(alloca, align.bytes() as c_uint);
130+
// Cast to default addrspace if necessary
131+
llvm::LLVMBuildPointerCast(self.llbuilder, alloca, self.cx.type_ptr(), UNNAMED)
132+
};
133+
if name != "" {
134+
let name = std::ffi::CString::new(name).unwrap();
135+
llvm::set_value_name(val, &name.as_bytes());
136+
}
137+
val
138+
}
139+
140+
pub(crate) fn inbounds_gep(
141+
&mut self,
142+
ty: &'ll Type,
143+
ptr: &'ll Value,
144+
indices: &[&'ll Value],
145+
) -> &'ll Value {
146+
unsafe {
147+
llvm::LLVMBuildGEPWithNoWrapFlags(
148+
self.llbuilder,
149+
ty,
150+
ptr,
151+
indices.as_ptr(),
152+
indices.len() as c_uint,
153+
UNNAMED,
154+
GEPNoWrapFlags::InBounds,
155+
)
156+
}
157+
}
158+
159+
pub(crate) fn store(&mut self, val: &'ll Value, ptr: &'ll Value, align: Align) -> &'ll Value {
160+
debug!("Store {:?} -> {:?}", val, ptr);
161+
assert_eq!(self.cx.type_kind(self.cx.val_ty(ptr)), TypeKind::Pointer);
162+
unsafe {
163+
let store = llvm::LLVMBuildStore(self.llbuilder, val, ptr);
164+
llvm::LLVMSetAlignment(store, align.bytes() as c_uint);
165+
store
166+
}
167+
}
168+
169+
pub(crate) fn load(&mut self, ty: &'ll Type, ptr: &'ll Value, align: Align) -> &'ll Value {
170+
unsafe {
171+
let load = llvm::LLVMBuildLoad2(self.llbuilder, ty, ptr, UNNAMED);
172+
llvm::LLVMSetAlignment(load, align.bytes() as c_uint);
173+
load
174+
}
175+
}
176+
177+
fn memset(&mut self, ptr: &'ll Value, fill_byte: &'ll Value, size: &'ll Value, align: Align) {
178+
unsafe {
179+
llvm::LLVMRustBuildMemSet(
180+
self.llbuilder,
181+
ptr,
182+
align.bytes() as c_uint,
183+
fill_byte,
184+
size,
185+
false,
186+
);
187+
}
188+
}
120189
}
121190

122191
/// Empty string, to be used where LLVM expects an instruction name, indicating

0 commit comments

Comments
(0)

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