Skip to content

Commit 6bf3008

Browse files
committed
Auto merge of #94024 - matthiaskrgr:rollup-0hwxm0w, r=matthiaskrgr
Rollup of 5 pull requests Successful merges: - #93899 (Describe VecDeque with more consistent names) - #93949 (Add basic platform support to library/{panic_}unwind for m68k) - #93999 (suggest using raw strings when invalid escapes appear in literals) - #94001 (llvm: migrate to new parameter-bearing uwtable attr) - #94014 (Move transmute_undefined_repr back to nursery) Failed merges: - #94020 (Support pretty printing of invalid constants) r? `@ghost` `@rustbot` modify labels: rollup
2 parents 5569757 + cc836ee commit 6bf3008

File tree

16 files changed

+180
-118
lines changed

16 files changed

+180
-118
lines changed

compiler/rustc_codegen_llvm/src/allocator.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ pub(crate) unsafe fn codegen(
6464
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
6565
}
6666
if tcx.sess.must_emit_unwind_tables() {
67-
attributes::emit_uwtable(llfn, true);
67+
attributes::emit_uwtable(llfn);
6868
}
6969

7070
let callee = kind.fn_name(method.name);
@@ -111,7 +111,7 @@ pub(crate) unsafe fn codegen(
111111
llvm::LLVMRustSetVisibility(llfn, llvm::Visibility::Hidden);
112112
}
113113
if tcx.sess.must_emit_unwind_tables() {
114-
attributes::emit_uwtable(llfn, true);
114+
attributes::emit_uwtable(llfn);
115115
}
116116

117117
let kind = if has_alloc_error_handler { AllocatorKind::Global } else { AllocatorKind::Default };

compiler/rustc_codegen_llvm/src/attributes.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,11 @@ pub fn sanitize<'ll>(cx: &CodegenCx<'ll, '_>, no_sanitize: SanitizerSet, llfn: &
5959

6060
/// Tell LLVM to emit or not emit the information necessary to unwind the stack for the function.
6161
#[inline]
62-
pub fn emit_uwtable(val: &Value, emit: bool) {
63-
Attribute::UWTable.toggle_llfn(Function, val, emit);
62+
pub fn emit_uwtable(val: &Value) {
63+
// NOTE: We should determine if we even need async unwind tables, as they
64+
// take have more overhead and if we can use sync unwind tables we
65+
// probably should.
66+
llvm::EmitUWTableAttr(val, true);
6467
}
6568

6669
/// Tell LLVM if this function should be 'naked', i.e., skip the epilogue and prologue.
@@ -275,7 +278,7 @@ pub fn from_fn_attrs<'ll, 'tcx>(
275278
// You can also find more info on why Windows always requires uwtables here:
276279
// https://bugzilla.mozilla.org/show_bug.cgi?id=1302078
277280
if cx.sess().must_emit_unwind_tables() {
278-
attributes::emit_uwtable(llfn, true);
281+
attributes::emit_uwtable(llfn);
279282
}
280283

281284
if cx.sess().opts.debugging_opts.profile_sample_use.is_some() {

compiler/rustc_codegen_llvm/src/llvm/ffi.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1182,6 +1182,7 @@ extern "C" {
11821182
pub fn LLVMRustAddByValAttr(Fn: &Value, index: c_uint, ty: &Type);
11831183
pub fn LLVMRustAddStructRetAttr(Fn: &Value, index: c_uint, ty: &Type);
11841184
pub fn LLVMRustAddFunctionAttribute(Fn: &Value, index: c_uint, attr: Attribute);
1185+
pub fn LLVMRustEmitUWTableAttr(Fn: &Value, async_: bool);
11851186
pub fn LLVMRustAddFunctionAttrStringValue(
11861187
Fn: &Value,
11871188
index: c_uint,

compiler/rustc_codegen_llvm/src/llvm/mod.rs

+4
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ impl LLVMRustResult {
3131
}
3232
}
3333

34+
pub fn EmitUWTableAttr(llfn: &Value, async_: bool) {
35+
unsafe { LLVMRustEmitUWTableAttr(llfn, async_) }
36+
}
37+
3438
pub fn AddFunctionAttrStringValue(llfn: &Value, idx: AttributePlace, attr: &CStr, value: &CStr) {
3539
unsafe {
3640
LLVMRustAddFunctionAttrStringValue(llfn, idx.as_uint(), attr.as_ptr(), value.as_ptr())

compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

+11
Original file line numberDiff line numberDiff line change
@@ -334,6 +334,17 @@ extern "C" void LLVMRustAddStructRetAttr(LLVMValueRef Fn, unsigned Index,
334334
AddAttribute(F, Index, Attr);
335335
}
336336

337+
extern "C" void LLVMRustEmitUWTableAttr(LLVMValueRef Fn, bool Async) {
338+
Function *F = unwrap<Function>(Fn);
339+
#if LLVM_VERSION_LT(15, 0)
340+
Attribute Attr = Attribute::get(F->getContext(), Attribute::UWTable);
341+
#else
342+
Attribute Attr = Attribute::getWithUWTableKind(
343+
F->getContext(), Async ? UWTableKind::Async : UWTableKind::Sync);
344+
#endif
345+
AddAttribute(F, AttributeList::AttrIndex::FunctionIndex, Attr);
346+
}
347+
337348
extern "C" void LLVMRustAddFunctionAttrStringValue(LLVMValueRef Fn,
338349
unsigned Index,
339350
const char *Name,

compiler/rustc_parse/src/lexer/unescape_error_reporting.rs

+9
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,15 @@ pub(crate) fn emit_unescape_error(
185185
version control settings",
186186
);
187187
} else {
188+
if !mode.is_bytes() {
189+
diag.span_suggestion(
190+
span_with_quotes,
191+
"if you meant to write a literal backslash (perhaps escaping in a regular expression), consider a raw string literal",
192+
format!("r\"{}\"", lit),
193+
Applicability::MaybeIncorrect,
194+
);
195+
}
196+
188197
diag.help(
189198
"for more information, visit \
190199
<https://static.rust-lang.org/doc/master/reference.html#literals>",

0 commit comments

Comments
 (0)