Skip to content

Commit 38798c6

Browse files
committed
Auto merge of #62592 - nikic:actually-update-llvm, r=alexcrichton
Update to LLVM 9 trunk Following the preparatory changes in #62474, this updates the LLVM submodule to https://github.com/rust-lang/llvm-project/tree/rustc/9.0-2019-07-12 and: * Changes the LLVM Rust bindings to account for the new SubtargetSubTypeKV. * Adjusts a codegen test for the new form of the byval attribute that takes a type. * Makes a PGO codegen test more liberal with regard to order and linkage. * Builds InstrProfilingPlatformWindows.c as part of libprofiler_builtins. * Moves registration of additional passes (in particular sanitizers) to the end of the module pass manager. * Disables LLDB on builders. r? @alexcrichton
2 parents 07e0c36 + d2c1d1b commit 38798c6

File tree

11 files changed

+95
-63
lines changed

11 files changed

+95
-63
lines changed

.azure-pipelines/auto.yml

+3-3
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ jobs:
174174

175175
dist-x86_64-apple:
176176
SCRIPT: ./x.py dist
177-
RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc
177+
RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
178178
DEPLOY: 1
179179
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
180180
MACOSX_DEPLOYMENT_TARGET: 10.7
@@ -184,7 +184,7 @@ jobs:
184184

185185
dist-x86_64-apple-alt:
186186
SCRIPT: ./x.py dist
187-
RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --enable-lldb --set rust.jemalloc
187+
RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
188188
DEPLOY_ALT: 1
189189
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
190190
MACOSX_DEPLOYMENT_TARGET: 10.7
@@ -202,7 +202,7 @@ jobs:
202202

203203
dist-i686-apple:
204204
SCRIPT: ./x.py dist
205-
RUST_CONFIGURE_ARGS: --build=i686-apple-darwin --enable-full-tools --enable-profiler --enable-lldb --set rust.jemalloc
205+
RUST_CONFIGURE_ARGS: --build=i686-apple-darwin --enable-full-tools --enable-profiler --set rust.jemalloc
206206
DEPLOY: 1
207207
RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
208208
MACOSX_DEPLOYMENT_TARGET: 10.7

.azure-pipelines/try.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ jobs:
3636
# matrix:
3737
# dist-x86_64-apple:
3838
# SCRIPT: ./x.py dist
39-
# RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --enable-lldb --set rust.jemalloc
39+
# RUST_CONFIGURE_ARGS: --target=aarch64-apple-ios,armv7-apple-ios,armv7s-apple-ios,i386-apple-ios,x86_64-apple-ios --enable-full-tools --enable-sanitizers --enable-profiler --set rust.jemalloc
4040
# DEPLOY: 1
4141
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
4242
# MACOSX_DEPLOYMENT_TARGET: 10.7
@@ -46,7 +46,7 @@ jobs:
4646
#
4747
# dist-x86_64-apple-alt:
4848
# SCRIPT: ./x.py dist
49-
# RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --enable-lldb --set rust.jemalloc
49+
# RUST_CONFIGURE_ARGS: --enable-extended --enable-profiler --set rust.jemalloc
5050
# DEPLOY_ALT: 1
5151
# RUSTC_RETRY_LINKER_ON_SEGFAULT: 1
5252
# MACOSX_DEPLOYMENT_TARGET: 10.7

.gitmodules

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@
4343
[submodule "src/llvm-project"]
4444
path = src/llvm-project
4545
url = https://github.com/rust-lang/llvm-project.git
46-
branch = rustc/8.0-2019-03-18
46+
branch = rustc/9.0-2019-07-12
4747
[submodule "src/doc/embedded-book"]
4848
path = src/doc/embedded-book
4949
url = https://github.com/rust-embedded/book.git

src/ci/docker/x86_64-gnu-debug/Dockerfile

-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ ENV RUST_CONFIGURE_ARGS \
3333
--build=x86_64-unknown-linux-gnu \
3434
--enable-debug \
3535
--enable-lld \
36-
--enable-lldb \
3736
--enable-optimize \
3837
--set llvm.use-linker=lld \
3938
--set target.x86_64-unknown-linux-gnu.linker=clang \

src/libprofiler_builtins/build.rs

+1
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ fn main() {
1919
"InstrProfilingPlatformDarwin.c",
2020
"InstrProfilingPlatformLinux.c",
2121
"InstrProfilingPlatformOther.c",
22+
"InstrProfilingPlatformWindows.c",
2223
"InstrProfilingRuntime.cc",
2324
"InstrProfilingUtil.c",
2425
"InstrProfilingValue.c",

src/librustc_codegen_llvm/back/write.rs

+49-39
Original file line numberDiff line numberDiff line change
@@ -329,33 +329,55 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
329329
let mpm = llvm::LLVMCreatePassManager();
330330

331331
{
332-
// If we're verifying or linting, add them to the function pass
333-
// manager.
334-
let addpass = |pass_name: &str| {
332+
let find_pass = |pass_name: &str| {
335333
let pass_name = SmallCStr::new(pass_name);
336-
let pass = match llvm::LLVMRustFindAndCreatePass(pass_name.as_ptr()) {
337-
Some(pass) => pass,
338-
None => return false,
339-
};
340-
let pass_manager = match llvm::LLVMRustPassKind(pass) {
341-
llvm::PassKind::Function => &*fpm,
342-
llvm::PassKind::Module => &*mpm,
343-
llvm::PassKind::Other => {
344-
diag_handler.err("Encountered LLVM pass kind we can't handle");
345-
return true
346-
},
347-
};
348-
llvm::LLVMRustAddPass(pass_manager, pass);
349-
true
334+
llvm::LLVMRustFindAndCreatePass(pass_name.as_ptr())
350335
};
351336

352-
if config.verify_llvm_ir { assert!(addpass("verify")); }
337+
if config.verify_llvm_ir {
338+
// Verification should run as the very first pass.
339+
llvm::LLVMRustAddPass(fpm, find_pass("verify").unwrap());
340+
}
341+
342+
let mut extra_passes = Vec::new();
343+
let mut have_name_anon_globals_pass = false;
344+
345+
for pass_name in &config.passes {
346+
if pass_name == "lint" {
347+
// Linting should also be performed early, directly on the generated IR.
348+
llvm::LLVMRustAddPass(fpm, find_pass("lint").unwrap());
349+
continue;
350+
}
351+
352+
if let Some(pass) = find_pass(pass_name) {
353+
extra_passes.push(pass);
354+
} else {
355+
diag_handler.warn(&format!("unknown pass `{}`, ignoring", pass_name));
356+
}
357+
358+
if pass_name == "name-anon-globals" {
359+
have_name_anon_globals_pass = true;
360+
}
361+
}
362+
363+
for pass_name in &cgcx.plugin_passes {
364+
if let Some(pass) = find_pass(pass_name) {
365+
extra_passes.push(pass);
366+
} else {
367+
diag_handler.err(&format!("a plugin asked for LLVM pass \
368+
`{}` but LLVM does not \
369+
recognize it", pass_name));
370+
}
371+
372+
if pass_name == "name-anon-globals" {
373+
have_name_anon_globals_pass = true;
374+
}
375+
}
353376

354377
// Some options cause LLVM bitcode to be emitted, which uses ThinLTOBuffers, so we need
355378
// to make sure we run LLVM's NameAnonGlobals pass when emitting bitcode; otherwise
356379
// we'll get errors in LLVM.
357380
let using_thin_buffers = config.bitcode_needed();
358-
let mut have_name_anon_globals_pass = false;
359381
if !config.no_prepopulate_passes {
360382
llvm::LLVMRustAddAnalysisPasses(tm, fpm, llmod);
361383
llvm::LLVMRustAddAnalysisPasses(tm, mpm, llmod);
@@ -364,34 +386,22 @@ pub(crate) unsafe fn optimize(cgcx: &CodegenContext<LlvmCodegenBackend>,
364386
let prepare_for_thin_lto = cgcx.lto == Lto::Thin || cgcx.lto == Lto::ThinLocal ||
365387
(cgcx.lto != Lto::Fat && cgcx.opts.cg.linker_plugin_lto.enabled());
366388
with_llvm_pmb(llmod, &config, opt_level, prepare_for_thin_lto, &mut |b| {
389+
llvm::LLVMRustAddLastExtensionPasses(
390+
b, extra_passes.as_ptr(), extra_passes.len() as size_t);
367391
llvm::LLVMPassManagerBuilderPopulateFunctionPassManager(b, fpm);
368392
llvm::LLVMPassManagerBuilderPopulateModulePassManager(b, mpm);
369393
});
370394

371395
have_name_anon_globals_pass = have_name_anon_globals_pass || prepare_for_thin_lto;
372396
if using_thin_buffers && !prepare_for_thin_lto {
373-
assert!(addpass("name-anon-globals"));
374-
have_name_anon_globals_pass = true;
375-
}
376-
}
377-
378-
for pass in &config.passes {
379-
if !addpass(pass) {
380-
diag_handler.warn(&format!("unknown pass `{}`, ignoring", pass));
381-
}
382-
if pass == "name-anon-globals" {
397+
llvm::LLVMRustAddPass(mpm, find_pass("name-anon-globals").unwrap());
383398
have_name_anon_globals_pass = true;
384399
}
385-
}
386-
387-
for pass in &cgcx.plugin_passes {
388-
if !addpass(pass) {
389-
diag_handler.err(&format!("a plugin asked for LLVM pass \
390-
`{}` but LLVM does not \
391-
recognize it", pass));
392-
}
393-
if pass == "name-anon-globals" {
394-
have_name_anon_globals_pass = true;
400+
} else {
401+
// If we don't use the standard pipeline, directly populate the MPM
402+
// with the extra passes.
403+
for pass in extra_passes {
404+
llvm::LLVMRustAddPass(mpm, pass);
395405
}
396406
}
397407

src/librustc_codegen_llvm/llvm/ffi.rs

+3
Original file line numberDiff line numberDiff line change
@@ -1668,6 +1668,9 @@ extern "C" {
16681668
pub fn LLVMRustPassKind(Pass: &Pass) -> PassKind;
16691669
pub fn LLVMRustFindAndCreatePass(Pass: *const c_char) -> Option<&'static mut Pass>;
16701670
pub fn LLVMRustAddPass(PM: &PassManager<'_>, Pass: &'static mut Pass);
1671+
pub fn LLVMRustAddLastExtensionPasses(PMB: &PassManagerBuilder,
1672+
Passes: *const &'static mut Pass,
1673+
NumPasses: size_t);
16711674

16721675
pub fn LLVMRustHasFeature(T: &TargetMachine, s: *const c_char) -> bool;
16731676

src/llvm-project

Submodule llvm-project updated 36629 files

src/rustllvm/PassWrapper.cpp

+21-4
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,23 @@ void LLVMRustPassManagerBuilderPopulateThinLTOPassManager(
9999
unwrap(PMBR)->populateThinLTOPassManager(*unwrap(PMR));
100100
}
101101

102+
extern "C"
103+
void LLVMRustAddLastExtensionPasses(
104+
LLVMPassManagerBuilderRef PMBR, LLVMPassRef *Passes, size_t NumPasses) {
105+
auto AddExtensionPasses = [Passes, NumPasses](
106+
const PassManagerBuilder &Builder, PassManagerBase &PM) {
107+
for (size_t I = 0; I < NumPasses; I++) {
108+
PM.add(unwrap(Passes[I]));
109+
}
110+
};
111+
// Add the passes to both of the pre-finalization extension points,
112+
// so they are run for optimized and non-optimized builds.
113+
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_OptimizerLast,
114+
AddExtensionPasses);
115+
unwrap(PMBR)->addExtension(PassManagerBuilder::EP_EnabledOnOptLevel0,
116+
AddExtensionPasses);
117+
}
118+
102119
#ifdef LLVM_COMPONENT_X86
103120
#define SUBTARGET_X86 SUBTARGET(X86)
104121
#else
@@ -266,8 +283,8 @@ static Optional<Reloc::Model> fromRust(LLVMRustRelocMode RustReloc) {
266283

267284
#ifdef LLVM_RUSTLLVM
268285
/// getLongestEntryLength - Return the length of the longest entry in the table.
269-
///
270-
static size_t getLongestEntryLength(ArrayRef<SubtargetFeatureKV> Table) {
286+
template<typename KV>
287+
static size_t getLongestEntryLength(ArrayRef<KV> Table) {
271288
size_t MaxLen = 0;
272289
for (auto &I : Table)
273290
MaxLen = std::max(MaxLen, std::strlen(I.Key));
@@ -279,7 +296,7 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
279296
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
280297
const Triple::ArchType HostArch = Triple(sys::getProcessTriple()).getArch();
281298
const Triple::ArchType TargetArch = Target->getTargetTriple().getArch();
282-
const ArrayRef<SubtargetFeatureKV> CPUTable = MCInfo->getCPUTable();
299+
const ArrayRef<SubtargetSubTypeKV> CPUTable = MCInfo->getCPUTable();
283300
unsigned MaxCPULen = getLongestEntryLength(CPUTable);
284301

285302
printf("Available CPUs for this target:\n");
@@ -289,7 +306,7 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM) {
289306
MaxCPULen, "native", (int)HostCPU.size(), HostCPU.data());
290307
}
291308
for (auto &CPU : CPUTable)
292-
printf(" %-*s - %s.\n", MaxCPULen, CPU.Key, CPU.Desc);
309+
printf(" %-*s\n", MaxCPULen, CPU.Key);
293310
printf("\n");
294311
}
295312

src/test/codegen/pgo-instrumentation.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@
55
// compile-flags: -Cprofile-generate -Ccodegen-units=1 -Cpanic=abort
66

77
// CHECK: @__llvm_profile_raw_version =
8-
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
9-
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = private global
10-
// CHECK: @__profc_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = private global
11-
// CHECK: @__profd_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = private global
8+
// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global
9+
// CHECK-DAG: @__profd_{{.*}}pgo_instrumentation{{.*}}some_function{{.*}} = {{.*}}global
10+
// CHECK-DAG: @__profc_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = {{.*}}global
11+
// CHECK-DAG: @__profd_{{.*}}pgo_instrumentation{{.*}}some_other_function{{.*}} = {{.*}}global
1212
// CHECK: @__llvm_profile_filename = {{.*}}"default_%m.profraw\00"{{.*}}
1313

1414
#![crate_type="lib"]

src/test/codegen/repr-transparent-aggregates-1.rs

+10-8
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
// compile-flags: -C no-prepopulate-passes
22
// ignore-tidy-linelength
33

4+
// min-system-llvm-version: 9.0
45
// ignore-arm
56
// ignore-mips
67
// ignore-mips64
78
// ignore-powerpc
89
// ignore-powerpc64
10+
// ignore-windows
911
// See repr-transparent.rs
1012

1113
#![feature(transparent_enums, transparent_unions)]
@@ -30,19 +32,19 @@ pub enum TeBigS {
3032
Variant(BigS),
3133
}
3234

33-
// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], %BigS* [[BIGS_ARG_ATTRS:.*]])
35+
// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS:.*]], %BigS* [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]])
3436
#[no_mangle]
3537
pub extern fn test_BigS(_: BigS) -> BigS { loop {} }
3638

37-
// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], %TsBigS* [[BIGS_ARG_ATTRS]])
39+
// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS]], %TsBigS* [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]])
3840
#[no_mangle]
3941
pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} }
4042

41-
// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], %TuBigS* [[BIGS_ARG_ATTRS]])
43+
// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS]], %TuBigS* [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]])
4244
#[no_mangle]
4345
pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} }
4446

45-
// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS]])
47+
// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS]], %"TeBigS::Variant"* [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]])
4648
#[no_mangle]
4749
pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} }
4850

@@ -66,18 +68,18 @@ pub enum TeBigU {
6668
Variant(BigU),
6769
}
6870

69-
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS:.*]])
71+
// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS:.*]], %BigU* [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]])
7072
#[no_mangle]
7173
pub extern fn test_BigU(_: BigU) -> BigU { loop {} }
7274

73-
// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], %TsBigU* [[BIGU_ARG_ATTRS]])
75+
// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS:.*]], %TsBigU* [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]])
7476
#[no_mangle]
7577
pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} }
7678

77-
// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], %TuBigU* [[BIGU_ARG_ATTRS]])
79+
// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS]], %TuBigU* [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]])
7880
#[no_mangle]
7981
pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} }
8082

81-
// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS]])
83+
// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS]], %"TeBigU::Variant"* [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]])
8284
#[no_mangle]
8385
pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} }

0 commit comments

Comments
 (0)