Skip to content

Commit 7504256

Browse files
committed
Auto merge of rust-lang#79065 - Dylan-DPC:rollup-gag1drk, r=Dylan-DPC
Rollup of 15 pull requests Successful merges: - rust-lang#78352 (Do not call `unwrap` with `signatures` option enabled) - rust-lang#78590 (refactor: removing alloc::collections::vec_deque ignore-tidy-filelength) - rust-lang#78848 (Bump minimal supported LLVM version to 9) - rust-lang#78856 (Explicitly checking for or-pattern before test) - rust-lang#78948 (test: add `()=()=()=...` to weird-exprs.rs) - rust-lang#78962 (Add a test for r# identifiers) - rust-lang#78963 (Added some unit tests as requested) - rust-lang#78966 (Never inline C variadics, cold functions, functions with incompatible attributes ...) - rust-lang#78968 (Include llvm-as in llvm-tools-preview component) - rust-lang#78969 (Normalize function type during validation) - rust-lang#78980 (Fix rustc_ast_pretty print_qpath resulting in invalid macro input) - rust-lang#78986 (Avoid installing external LLVM dylibs) - rust-lang#78988 (Fix an intrinsic invocation on threaded wasm) - rust-lang#78993 (rustc_target: Fix dash vs underscore mismatches in option names) - rust-lang#79013 (Clean up outdated `use_once_payload` pretty printer comment) Failed merges: r? `@ghost` `@rustbot` modify labels: rollup
2 parents 361c4ea + 96515cc commit 7504256

Some content is hidden

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

56 files changed

+1732
-694
lines changed

Diff for: .github/workflows/ci.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ jobs:
4343
- name: mingw-check
4444
os: ubuntu-latest-xl
4545
env: {}
46-
- name: x86_64-gnu-llvm-8
46+
- name: x86_64-gnu-llvm-9
4747
os: ubuntu-latest-xl
4848
env: {}
4949
- name: x86_64-gnu-tools
@@ -265,7 +265,7 @@ jobs:
265265
- name: x86_64-gnu-distcheck
266266
os: ubuntu-latest-xl
267267
env: {}
268-
- name: x86_64-gnu-llvm-8
268+
- name: x86_64-gnu-llvm-9
269269
env:
270270
RUST_BACKTRACE: 1
271271
os: ubuntu-latest-xl

Diff for: Cargo.lock

+8
Original file line numberDiff line numberDiff line change
@@ -721,6 +721,13 @@ version = "0.8.0"
721721
source = "registry+https://github.com/rust-lang/crates.io-index"
722722
checksum = "9a21fa21941700a3cd8fcb4091f361a6a712fac632f85d9f487cc892045d55c6"
723723

724+
[[package]]
725+
name = "coverage_test_macros"
726+
version = "0.0.0"
727+
dependencies = [
728+
"proc-macro2",
729+
]
730+
724731
[[package]]
725732
name = "cpuid-bool"
726733
version = "0.1.2"
@@ -3922,6 +3929,7 @@ dependencies = [
39223929
name = "rustc_mir"
39233930
version = "0.0.0"
39243931
dependencies = [
3932+
"coverage_test_macros",
39253933
"either",
39263934
"itertools 0.9.0",
39273935
"polonius-engine",

Diff for: compiler/rustc_ast_pretty/src/pprust/state.rs

+6-5
Original file line numberDiff line numberDiff line change
@@ -2327,11 +2327,12 @@ impl<'a> State<'a> {
23272327
self.print_path(path, false, depth);
23282328
}
23292329
self.s.word(">");
2330-
self.s.word("::");
2331-
let item_segment = path.segments.last().unwrap();
2332-
self.print_ident(item_segment.ident);
2333-
if let Some(ref args) = item_segment.args {
2334-
self.print_generic_args(args, colons_before_params)
2330+
for item_segment in &path.segments[qself.position..] {
2331+
self.s.word("::");
2332+
self.print_ident(item_segment.ident);
2333+
if let Some(ref args) = item_segment.args {
2334+
self.print_generic_args(args, colons_before_params)
2335+
}
23352336
}
23362337
}
23372338

Diff for: compiler/rustc_codegen_llvm/src/attributes.rs

+1-25
Original file line numberDiff line numberDiff line change
@@ -144,25 +144,6 @@ fn set_probestack(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {
144144
);
145145
}
146146

147-
fn translate_obsolete_target_features(feature: &str) -> &str {
148-
const LLVM9_FEATURE_CHANGES: &[(&str, &str)] =
149-
&[("+fp-only-sp", "-fp64"), ("-fp-only-sp", "+fp64"), ("+d16", "-d32"), ("-d16", "+d32")];
150-
if llvm_util::get_major_version() >= 9 {
151-
for &(old, new) in LLVM9_FEATURE_CHANGES {
152-
if feature == old {
153-
return new;
154-
}
155-
}
156-
} else {
157-
for &(old, new) in LLVM9_FEATURE_CHANGES {
158-
if feature == new {
159-
return old;
160-
}
161-
}
162-
}
163-
feature
164-
}
165-
166147
pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
167148
const RUSTC_SPECIFIC_FEATURES: &[&str] = &["crt-static"];
168149

@@ -172,12 +153,7 @@ pub fn llvm_target_features(sess: &Session) -> impl Iterator<Item = &str> {
172153
.target_feature
173154
.split(',')
174155
.filter(|f| !RUSTC_SPECIFIC_FEATURES.iter().any(|s| f.contains(s)));
175-
sess.target
176-
.features
177-
.split(',')
178-
.chain(cmdline)
179-
.filter(|l| !l.is_empty())
180-
.map(translate_obsolete_target_features)
156+
sess.target.features.split(',').chain(cmdline).filter(|l| !l.is_empty())
181157
}
182158

183159
pub fn apply_target_cpu_attr(cx: &CodegenCx<'ll, '_>, llfn: &'ll Value) {

Diff for: compiler/rustc_codegen_llvm/src/back/write.rs

-5
Original file line numberDiff line numberDiff line change
@@ -377,11 +377,6 @@ fn get_pgo_use_path(config: &ModuleConfig) -> Option<CString> {
377377
}
378378

379379
pub(crate) fn should_use_new_llvm_pass_manager(config: &ModuleConfig) -> bool {
380-
// We only support the new pass manager starting with LLVM 9.
381-
if llvm_util::get_major_version() < 9 {
382-
return false;
383-
}
384-
385380
// The new pass manager is disabled by default.
386381
config.new_llvm_pass_manager
387382
}

Diff for: compiler/rustc_codegen_llvm/src/context.rs

-8
Original file line numberDiff line numberDiff line change
@@ -100,11 +100,6 @@ fn to_llvm_tls_model(tls_model: TlsModel) -> llvm::ThreadLocalMode {
100100
}
101101
}
102102

103-
fn strip_function_ptr_alignment(data_layout: String) -> String {
104-
// FIXME: Make this more general.
105-
data_layout.replace("-Fi8-", "-")
106-
}
107-
108103
fn strip_x86_address_spaces(data_layout: String) -> String {
109104
data_layout.replace("-p270:32:32-p271:32:32-p272:64:64-", "-")
110105
}
@@ -119,9 +114,6 @@ pub unsafe fn create_module(
119114
let llmod = llvm::LLVMModuleCreateWithNameInContext(mod_name.as_ptr(), llcx);
120115

121116
let mut target_data_layout = sess.target.data_layout.clone();
122-
if llvm_util::get_major_version() < 9 {
123-
target_data_layout = strip_function_ptr_alignment(target_data_layout);
124-
}
125117
if llvm_util::get_major_version() < 10
126118
&& (sess.target.arch == "x86" || sess.target.arch == "x86_64")
127119
{

Diff for: compiler/rustc_codegen_llvm/src/llvm_util.rs

+3-5
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ unsafe fn configure_llvm(sess: &Session) {
104104
}
105105
}
106106

107-
if sess.opts.debugging_opts.llvm_time_trace && get_major_version() >= 9 {
107+
if sess.opts.debugging_opts.llvm_time_trace {
108108
// time-trace is not thread safe and running it in parallel will cause seg faults.
109109
if !sess.opts.debugging_opts.no_parallel_llvm {
110110
bug!("`-Z llvm-time-trace` requires `-Z no-parallel-llvm")
@@ -122,10 +122,8 @@ unsafe fn configure_llvm(sess: &Session) {
122122

123123
pub fn time_trace_profiler_finish(file_name: &str) {
124124
unsafe {
125-
if get_major_version() >= 9 {
126-
let file_name = CString::new(file_name).unwrap();
127-
llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
128-
}
125+
let file_name = CString::new(file_name).unwrap();
126+
llvm::LLVMTimeTraceProfilerFinish(file_name.as_ptr());
129127
}
130128
}
131129

Diff for: compiler/rustc_driver/src/pretty.rs

-3
Original file line numberDiff line numberDiff line change
@@ -32,9 +32,6 @@ use crate::abort_on_err;
3232
// Note that since the `&PrinterSupport` is freshly constructed on each
3333
// call, it would not make sense to try to attach the lifetime of `self`
3434
// to the lifetime of the `&PrinterObject`.
35-
//
36-
// (The `use_once_payload` is working around the current lack of once
37-
// functions in the compiler.)
3835

3936
/// Constructs a `PrinterSupport` object and passes it to `f`.
4037
fn call_with_pp_support<'tcx, A, F>(

Diff for: compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

+2-30
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,7 @@
1616
#include "llvm/Object/ObjectFile.h"
1717
#include "llvm/Object/IRObjectFile.h"
1818
#include "llvm/Passes/PassBuilder.h"
19-
#if LLVM_VERSION_GE(9, 0)
2019
#include "llvm/Passes/StandardInstrumentations.h"
21-
#endif
2220
#include "llvm/Support/CBindingWrapping.h"
2321
#include "llvm/Support/FileSystem.h"
2422
#include "llvm/Support/Host.h"
@@ -31,15 +29,11 @@
3129
#include "llvm-c/Transforms/PassManagerBuilder.h"
3230

3331
#include "llvm/Transforms/Instrumentation.h"
34-
#if LLVM_VERSION_GE(9, 0)
3532
#include "llvm/Transforms/Instrumentation/AddressSanitizer.h"
3633
#include "llvm/Support/TimeProfiler.h"
37-
#endif
3834
#include "llvm/Transforms/Instrumentation/ThreadSanitizer.h"
3935
#include "llvm/Transforms/Instrumentation/MemorySanitizer.h"
40-
#if LLVM_VERSION_GE(9, 0)
4136
#include "llvm/Transforms/Utils/CanonicalizeAliases.h"
42-
#endif
4337
#include "llvm/Transforms/Utils/NameAnonGlobals.h"
4438

4539
using namespace llvm;
@@ -73,20 +67,18 @@ extern "C" void LLVMTimeTraceProfilerInitialize() {
7367
timeTraceProfilerInitialize(
7468
/* TimeTraceGranularity */ 0,
7569
/* ProcName */ "rustc");
76-
#elif LLVM_VERSION_GE(9, 0)
70+
#else
7771
timeTraceProfilerInitialize();
7872
#endif
7973
}
8074

8175
extern "C" void LLVMTimeTraceProfilerFinish(const char* FileName) {
82-
#if LLVM_VERSION_GE(9, 0)
8376
StringRef FN(FileName);
8477
std::error_code EC;
8578
raw_fd_ostream OS(FN, EC, sys::fs::CD_CreateAlways);
8679

8780
timeTraceProfilerWrite(OS);
8881
timeTraceProfilerCleanup();
89-
#endif
9082
}
9183

9284
enum class LLVMRustPassKind {
@@ -127,22 +119,14 @@ extern "C" LLVMPassRef LLVMRustCreateAddressSanitizerFunctionPass(bool Recover)
127119
extern "C" LLVMPassRef LLVMRustCreateModuleAddressSanitizerPass(bool Recover) {
128120
const bool CompileKernel = false;
129121

130-
#if LLVM_VERSION_GE(9, 0)
131122
return wrap(createModuleAddressSanitizerLegacyPassPass(CompileKernel, Recover));
132-
#else
133-
return wrap(createAddressSanitizerModulePass(CompileKernel, Recover));
134-
#endif
135123
}
136124

137125
extern "C" LLVMPassRef LLVMRustCreateMemorySanitizerPass(int TrackOrigins, bool Recover) {
138-
#if LLVM_VERSION_GE(9, 0)
139126
const bool CompileKernel = false;
140127

141128
return wrap(createMemorySanitizerLegacyPassPass(
142129
MemorySanitizerOptions{TrackOrigins, Recover, CompileKernel}));
143-
#else
144-
return wrap(createMemorySanitizerLegacyPassPass(TrackOrigins, Recover));
145-
#endif
146130
}
147131

148132
extern "C" LLVMPassRef LLVMRustCreateThreadSanitizerPass() {
@@ -657,8 +641,6 @@ extern "C" typedef void (*LLVMRustSelfProfileBeforePassCallback)(void*, // LlvmS
657641
const char*); // IR name
658642
extern "C" typedef void (*LLVMRustSelfProfileAfterPassCallback)(void*); // LlvmSelfProfiler
659643

660-
#if LLVM_VERSION_GE(9, 0)
661-
662644
std::string LLVMRustwrappedIrGetName(const llvm::Any &WrappedIr) {
663645
if (any_isa<const Module *>(WrappedIr))
664646
return any_cast<const Module *>(WrappedIr)->getName().str();
@@ -706,7 +688,6 @@ void LLVMSelfProfileInitializeCallbacks(
706688
AfterPassCallback(LlvmSelfProfiler);
707689
});
708690
}
709-
#endif
710691

711692
enum class LLVMRustOptStage {
712693
PreLinkNoLTO,
@@ -739,7 +720,6 @@ LLVMRustOptimizeWithNewPassManager(
739720
void* LlvmSelfProfiler,
740721
LLVMRustSelfProfileBeforePassCallback BeforePassCallback,
741722
LLVMRustSelfProfileAfterPassCallback AfterPassCallback) {
742-
#if LLVM_VERSION_GE(9, 0)
743723
Module *TheModule = unwrap(ModuleRef);
744724
TargetMachine *TM = unwrap(TMRef);
745725
PassBuilder::OptimizationLevel OptLevel = fromRust(OptLevelRust);
@@ -970,11 +950,6 @@ LLVMRustOptimizeWithNewPassManager(
970950
UpgradeCallsToIntrinsic(&*I++); // must be post-increment, as we remove
971951

972952
MPM.run(*TheModule, MAM);
973-
#else
974-
// The new pass manager has been available for a long time,
975-
// but we don't bother supporting it on old LLVM versions.
976-
report_fatal_error("New pass manager only supported since LLVM 9");
977-
#endif
978953
}
979954

980955
// Callback to demangle function name
@@ -1325,12 +1300,9 @@ LLVMRustCreateThinLTOData(LLVMRustThinLTOModule *modules,
13251300
GlobalValue::LinkageTypes NewLinkage) {
13261301
Ret->ResolvedODR[ModuleIdentifier][GUID] = NewLinkage;
13271302
};
1328-
#if LLVM_VERSION_GE(9, 0)
1303+
13291304
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage,
13301305
Ret->GUIDPreservedSymbols);
1331-
#else
1332-
thinLTOResolvePrevailingInIndex(Ret->Index, isPrevailing, recordNewLinkage);
1333-
#endif
13341306

13351307
// Here we calculate an `ExportedGUIDs` set for use in the `isExported`
13361308
// callback below. This callback below will dictate the linkage for all

Diff for: compiler/rustc_llvm/llvm-wrapper/RustWrapper.cpp

-16
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,7 @@ extern "C" LLVMValueRef LLVMRustGetOrInsertFunction(LLVMModuleRef M,
124124
return wrap(unwrap(M)
125125
->getOrInsertFunction(StringRef(Name, NameLen),
126126
unwrap<FunctionType>(FunctionTy))
127-
#if LLVM_VERSION_GE(9, 0)
128127
.getCallee()
129-
#endif
130128
);
131129
}
132130

@@ -251,11 +249,7 @@ extern "C" void LLVMRustAddDereferenceableOrNullCallSiteAttr(LLVMValueRef Instr,
251249
extern "C" void LLVMRustAddByValCallSiteAttr(LLVMValueRef Instr, unsigned Index,
252250
LLVMTypeRef Ty) {
253251
CallBase *Call = unwrap<CallBase>(Instr);
254-
#if LLVM_VERSION_GE(9, 0)
255252
Attribute Attr = Attribute::getWithByValType(Call->getContext(), unwrap(Ty));
256-
#else
257-
Attribute Attr = Attribute::get(Call->getContext(), Attribute::ByVal);
258-
#endif
259253
Call->addAttribute(Index, Attr);
260254
}
261255

@@ -296,11 +290,7 @@ extern "C" void LLVMRustAddDereferenceableOrNullAttr(LLVMValueRef Fn,
296290
extern "C" void LLVMRustAddByValAttr(LLVMValueRef Fn, unsigned Index,
297291
LLVMTypeRef Ty) {
298292
Function *F = unwrap<Function>(Fn);
299-
#if LLVM_VERSION_GE(9, 0)
300293
Attribute Attr = Attribute::getWithByValType(F->getContext(), unwrap(Ty));
301-
#else
302-
Attribute Attr = Attribute::get(F->getContext(), Attribute::ByVal);
303-
#endif
304294
F->addAttribute(Index, Attr);
305295
}
306296

@@ -616,11 +606,9 @@ static DISubprogram::DISPFlags fromRust(LLVMRustDISPFlags SPFlags) {
616606
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagOptimized)) {
617607
Result |= DISubprogram::DISPFlags::SPFlagOptimized;
618608
}
619-
#if LLVM_VERSION_GE(9, 0)
620609
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagMainSubprogram)) {
621610
Result |= DISubprogram::DISPFlags::SPFlagMainSubprogram;
622611
}
623-
#endif
624612

625613
return Result;
626614
}
@@ -744,10 +732,6 @@ extern "C" LLVMMetadataRef LLVMRustDIBuilderCreateFunction(
744732
DITemplateParameterArray(unwrap<MDTuple>(TParam));
745733
DISubprogram::DISPFlags llvmSPFlags = fromRust(SPFlags);
746734
DINode::DIFlags llvmFlags = fromRust(Flags);
747-
#if LLVM_VERSION_LT(9, 0)
748-
if (isSet(SPFlags & LLVMRustDISPFlags::SPFlagMainSubprogram))
749-
llvmFlags |= DINode::DIFlags::FlagMainSubprogram;
750-
#endif
751735
DISubprogram *Sub = Builder->createFunction(
752736
unwrapDI<DIScope>(Scope),
753737
StringRef(Name, NameLen),

Diff for: compiler/rustc_middle/src/ty/mod.rs

+12
Original file line numberDiff line numberDiff line change
@@ -611,6 +611,18 @@ pub struct TyS<'tcx> {
611611
outer_exclusive_binder: ty::DebruijnIndex,
612612
}
613613

614+
impl<'tcx> TyS<'tcx> {
615+
/// A constructor used only for internal testing.
616+
#[allow(rustc::usage_of_ty_tykind)]
617+
pub fn make_for_test(
618+
kind: TyKind<'tcx>,
619+
flags: TypeFlags,
620+
outer_exclusive_binder: ty::DebruijnIndex,
621+
) -> TyS<'tcx> {
622+
TyS { kind, flags, outer_exclusive_binder }
623+
}
624+
}
625+
614626
// `TyS` is used a lot. Make sure it doesn't unintentionally get bigger.
615627
#[cfg(target_arch = "x86_64")]
616628
static_assert_size!(TyS<'_>, 32);

Diff for: compiler/rustc_mir/Cargo.toml

+3
Original file line numberDiff line numberDiff line change
@@ -31,3 +31,6 @@ rustc_ast = { path = "../rustc_ast" }
3131
rustc_span = { path = "../rustc_span" }
3232
rustc_apfloat = { path = "../rustc_apfloat" }
3333
smallvec = { version = "1.0", features = ["union", "may_dangle"] }
34+
35+
[dev-dependencies]
36+
coverage_test_macros = { path = "src/transform/coverage/test_macros" }

Diff for: compiler/rustc_mir/src/transform/coverage/counters.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use rustc_middle::mir::coverage::*;
1414

1515
/// Manages the counter and expression indexes/IDs to generate `CoverageKind` components for MIR
1616
/// `Coverage` statements.
17-
pub(crate) struct CoverageCounters {
17+
pub(super) struct CoverageCounters {
1818
function_source_hash: u64,
1919
next_counter_id: u32,
2020
num_expressions: u32,
@@ -37,7 +37,7 @@ impl CoverageCounters {
3737
self.debug_counters.enable();
3838
}
3939

40-
/// Makes `CoverageKind` `Counter`s and `Expressions` for the `BasicCoverageBlocks` directly or
40+
/// Makes `CoverageKind` `Counter`s and `Expressions` for the `BasicCoverageBlock`s directly or
4141
/// indirectly associated with `CoverageSpans`, and returns additional `Expression`s
4242
/// representing intermediate values.
4343
pub fn make_bcb_counters(
@@ -120,7 +120,6 @@ struct BcbCounters<'a> {
120120
basic_coverage_blocks: &'a mut CoverageGraph,
121121
}
122122

123-
// FIXME(richkadel): Add unit tests for `BcbCounters` functions/algorithms.
124123
impl<'a> BcbCounters<'a> {
125124
fn new(
126125
coverage_counters: &'a mut CoverageCounters,

0 commit comments

Comments
 (0)