From df4bafc360064cc6d0dea8dccf083313f5e37280 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Mon, 20 Jul 2020 16:55:56 -0700 Subject: [PATCH 1/6] Don't make clang use gcc's include-fixed This was breaking `#include_next `, such that we weren't getting definitions of `PATH_MAX` and `_POSIX_ARG_MAX`. --- .../docker/host-x86_64/dist-x86_64-linux/build-clang.sh | 9 --------- 1 file changed, 9 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh index 2c00a628a1d35..0df30f96c2299 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh @@ -18,16 +18,7 @@ cd clang-build # For whatever reason the default set of include paths for clang is different # than that of gcc. As a result we need to manually include our sysroot's # include path, /rustroot/include, to clang's default include path. -# -# Alsow there's this weird oddity with gcc where there's an 'include-fixed' -# directory that it generates. It turns out [1] that Centos 5's headers are so -# old that they're incompatible with modern C semantics. While gcc automatically -# fixes that clang doesn't account for this. Tell clang to manually include the -# fixed headers so we can successfully compile code later on. -# -# [1]: https://sourceware.org/ml/crossgcc/2008-11/msg00028.html INC="/rustroot/include" -INC="$INC:/rustroot/lib/gcc/x86_64-unknown-linux-gnu/5.5.0/include-fixed" INC="$INC:/usr/include" hide_output \ From 636ca7a4129d0e46483a41fc2687999067b45f8f Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 28 Jul 2020 12:16:41 -0700 Subject: [PATCH 2/6] Upgrade to LLVM 11 (rc2) --- .gitmodules | 2 +- src/llvm-project | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitmodules b/.gitmodules index a327aaa8d5a34..8f4d3768c21e8 100644 --- a/.gitmodules +++ b/.gitmodules @@ -37,7 +37,7 @@ [submodule "src/llvm-project"] path = src/llvm-project url = https://github.com/rust-lang/llvm-project.git - branch = rustc/10.0-2020-05-05 + branch = rustc/11.0-2020-08-20 [submodule "src/doc/embedded-book"] path = src/doc/embedded-book url = https://github.com/rust-embedded/book.git diff --git a/src/llvm-project b/src/llvm-project index 86b120e6f302d..45790d79496be 160000 --- a/src/llvm-project +++ b/src/llvm-project @@ -1 +1 @@ -Subproject commit 86b120e6f302d39cd6973b6391fb299d7bc22122 +Subproject commit 45790d79496be37fbce6ec57abad5af8fa7a34d7 From a210a293032ed29a92183e80ee1052ac23d04fa1 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Wed, 5 Aug 2020 11:34:58 -0700 Subject: [PATCH 3/6] Expand RISCV pseudo-instructions to match LLVM 11 --- src/test/assembly/asm/riscv-types.rs | 31 ++++++++++++++-------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/test/assembly/asm/riscv-types.rs b/src/test/assembly/asm/riscv-types.rs index 6b6e582442cbc..67dda1024fc24 100644 --- a/src/test/assembly/asm/riscv-types.rs +++ b/src/test/assembly/asm/riscv-types.rs @@ -55,7 +55,8 @@ pub unsafe fn sym_fn() { // CHECK-LABEL: sym_static: // CHECK: #APP -// CHECK: lb t0, extern_static +// CHECK: auipc t0, %pcrel_hi(extern_static) +// CHECK: lb t0, %pcrel_lo(.Lpcrel_hi0)(t0) // CHECK: #NO_APP #[no_mangle] pub unsafe fn sym_static() { @@ -98,45 +99,45 @@ macro_rules! check_reg { // CHECK-LABEL: reg_i8: // CHECK: #APP -// CHECK: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// CHECK: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // CHECK: #NO_APP check!(reg_i8 i8 reg "mv"); // CHECK-LABEL: reg_i16: // CHECK: #APP -// CHECK: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// CHECK: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // CHECK: #NO_APP check!(reg_i16 i16 reg "mv"); // CHECK-LABEL: reg_i32: // CHECK: #APP -// CHECK: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// CHECK: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // CHECK: #NO_APP check!(reg_i32 i32 reg "mv"); // CHECK-LABEL: reg_f32: // CHECK: #APP -// CHECK: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// CHECK: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // CHECK: #NO_APP check!(reg_f32 f32 reg "mv"); // riscv64-LABEL: reg_i64: // riscv64: #APP -// riscv64: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// riscv64: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // riscv64: #NO_APP #[cfg(riscv64)] check!(reg_i64 i64 reg "mv"); // riscv64-LABEL: reg_f64: // riscv64: #APP -// riscv64: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// riscv64: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // riscv64: #NO_APP #[cfg(riscv64)] check!(reg_f64 f64 reg "mv"); // CHECK-LABEL: reg_ptr: // CHECK: #APP -// CHECK: mv {{[a-z0-9]+}}, {{[a-z0-9]+}} +// CHECK: add {{[a-z0-9]+}}, zero, {{[a-z0-9]+}} // CHECK: #NO_APP check!(reg_ptr ptr reg "mv"); @@ -154,45 +155,45 @@ check!(freg_f64 f64 freg "fmv.d"); // CHECK-LABEL: a0_i8: // CHECK: #APP -// CHECK: mv a0, a0 +// CHECK: add a0, zero, a0 // CHECK: #NO_APP check_reg!(a0_i8 i8 "a0" "mv"); // CHECK-LABEL: a0_i16: // CHECK: #APP -// CHECK: mv a0, a0 +// CHECK: add a0, zero, a0 // CHECK: #NO_APP check_reg!(a0_i16 i16 "a0" "mv"); // CHECK-LABEL: a0_i32: // CHECK: #APP -// CHECK: mv a0, a0 +// CHECK: add a0, zero, a0 // CHECK: #NO_APP check_reg!(a0_i32 i32 "a0" "mv"); // CHECK-LABEL: a0_f32: // CHECK: #APP -// CHECK: mv a0, a0 +// CHECK: add a0, zero, a0 // CHECK: #NO_APP check_reg!(a0_f32 f32 "a0" "mv"); // riscv64-LABEL: a0_i64: // riscv64: #APP -// riscv64: mv a0, a0 +// riscv64: add a0, zero, a0 // riscv64: #NO_APP #[cfg(riscv64)] check_reg!(a0_i64 i64 "a0" "mv"); // riscv64-LABEL: a0_f64: // riscv64: #APP -// riscv64: mv a0, a0 +// riscv64: add a0, zero, a0 // riscv64: #NO_APP #[cfg(riscv64)] check_reg!(a0_f64 f64 "a0" "mv"); // CHECK-LABEL: a0_ptr: // CHECK: #APP -// CHECK: mv a0, a0 +// CHECK: add a0, zero, a0 // CHECK: #NO_APP check_reg!(a0_ptr ptr "a0" "mv"); From 5c87749a271f82ab269603ade13867ffd50778ec Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Thu, 6 Aug 2020 10:52:23 -0700 Subject: [PATCH 4/6] Apply suggestions from code review Flatten the INC definition to one line. Co-authored-by: lzutao --- src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh index 0df30f96c2299..d6ce2806e390f 100755 --- a/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh +++ b/src/ci/docker/host-x86_64/dist-x86_64-linux/build-clang.sh @@ -18,8 +18,7 @@ cd clang-build # For whatever reason the default set of include paths for clang is different # than that of gcc. As a result we need to manually include our sysroot's # include path, /rustroot/include, to clang's default include path. -INC="/rustroot/include" -INC="$INC:/usr/include" +INC="/rustroot/include:/usr/include" hide_output \ cmake ../llvm \ From fb05be00df385ed216fcb9f6712206ec64fed72e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 18 Aug 2020 15:11:02 -0700 Subject: [PATCH 5/6] Match scalar-pair-bool more flexibly for LLVM 11 LLVM 11 started using `phi` and `select` for `fn pair_i32_bool`, which is still valid, but harder to match than the simple instructions we were getting before. We'll just check that the unpacked args are directly referenced in any way, and call it good. --- src/test/codegen/scalar-pair-bool.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/test/codegen/scalar-pair-bool.rs b/src/test/codegen/scalar-pair-bool.rs index d91ee7f816ded..4704c8ad797d8 100644 --- a/src/test/codegen/scalar-pair-bool.rs +++ b/src/test/codegen/scalar-pair-bool.rs @@ -24,8 +24,9 @@ pub fn pair_i32_bool(pair: (i32, bool)) -> (i32, bool) { #[no_mangle] pub fn pair_and_or((a, b): (bool, bool)) -> (bool, bool) { // Make sure it can operate directly on the unpacked args - // CHECK: and i1 %_1.0, %_1.1 - // CHECK: or i1 %_1.0, %_1.1 + // (but it might not be using simple and/or instructions) + // CHECK-DAG: %_1.0 + // CHECK-DAG: %_1.1 (a && b, a || b) } From b450c0c86ccdc836272feeac6e1312c1a168b343 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Fri, 21 Aug 2020 12:07:52 -0700 Subject: [PATCH 6/6] Write coverage filenames in Version3 format --- src/rustllvm/CoverageMappingWrapper.cpp | 16 +++++++++------- .../expected_export_coverage.json | 2 +- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/rustllvm/CoverageMappingWrapper.cpp b/src/rustllvm/CoverageMappingWrapper.cpp index 4d15e31df15a3..81aba0cbf7d42 100644 --- a/src/rustllvm/CoverageMappingWrapper.cpp +++ b/src/rustllvm/CoverageMappingWrapper.cpp @@ -3,6 +3,7 @@ #include "llvm/ProfileData/Coverage/CoverageMappingWriter.h" #include "llvm/ProfileData/InstrProf.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/Support/LEB128.h" #include @@ -12,14 +13,15 @@ extern "C" void LLVMRustCoverageWriteFilenamesSectionToBuffer( const char* const Filenames[], size_t FilenamesLen, RustStringRef BufferOut) { - SmallVector FilenameRefs; + // LLVM 11's CoverageFilenamesSectionWriter uses its new `Version4` format, + // so we're manually writing the `Version3` format ourselves. + RawRustStringOstream OS(BufferOut); + encodeULEB128(FilenamesLen, OS); for (size_t i = 0; i < FilenamesLen; i++) { - FilenameRefs.push_back(StringRef(Filenames[i])); + StringRef Filename(Filenames[i]); + encodeULEB128(Filename.size(), OS); + OS << Filename; } - auto FilenamesWriter = coverage::CoverageFilenamesSectionWriter( - makeArrayRef(FilenameRefs)); - RawRustStringOstream OS(BufferOut); - FilenamesWriter.write(OS); } extern "C" void LLVMRustCoverageWriteMappingToBuffer( @@ -64,5 +66,5 @@ extern "C" void LLVMRustCoverageWriteMappingVarNameToString(RustStringRef Str) { } extern "C" uint32_t LLVMRustCoverageMappingVersion() { - return coverage::CovMapVersion::CurrentVersion; + return coverage::CovMapVersion::Version3; } diff --git a/src/test/run-make-fulldeps/instrument-coverage/expected_export_coverage.json b/src/test/run-make-fulldeps/instrument-coverage/expected_export_coverage.json index 5881cf4b7dbbc..75bec80bdf886 100644 --- a/src/test/run-make-fulldeps/instrument-coverage/expected_export_coverage.json +++ b/src/test/run-make-fulldeps/instrument-coverage/expected_export_coverage.json @@ -55,5 +55,5 @@ } ], "type": "llvm.coverage.json.export", - "version": "2.0.0" + "version": "2.0.1" }