Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit b10e375

Browse files
committed
Auto merge of rust-lang#120055 - nikic:llvm-18, r=<try>
Update to LLVM 18 Blocked on rust-lang#116672. r? `@ghost`
2 parents 52790a9 + 0cd0ca9 commit b10e375

Some content is hidden

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

54 files changed

+110
-92
lines changed

.gitmodules

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,8 @@
3232
shallow = true
3333
[submodule "src/llvm-project"]
3434
path = src/llvm-project
35-
url = https://github.com/rust-lang/llvm-project.git
36-
branch = rustc/17.0-2023-12-14
35+
url = https://github.com/nikic/llvm-project.git
36+
branch = rust-llvm-18
3737
shallow = true
3838
[submodule "src/doc/embedded-book"]
3939
path = src/doc/embedded-book

compiler/rustc_ast/src/ast.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3300,9 +3300,13 @@ mod size_asserts {
33003300
static_assert_size!(Impl, 136);
33013301
static_assert_size!(Item, 136);
33023302
static_assert_size!(ItemKind, 64);
3303-
static_assert_size!(LitKind, 24);
3303+
// This can be removed after i128:128 is in the bootstrap compiler's target.
3304+
#[cfg(not(bootstrap))]
3305+
static_assert_size!(LitKind, 32);
33043306
static_assert_size!(Local, 72);
3305-
static_assert_size!(MetaItemLit, 40);
3307+
// This can be removed after i128:128 is in the bootstrap compiler's target.
3308+
#[cfg(not(bootstrap))]
3309+
static_assert_size!(MetaItemLit, 48);
33063310
static_assert_size!(Param, 40);
33073311
static_assert_size!(Pat, 72);
33083312
static_assert_size!(Path, 24);

compiler/rustc_codegen_llvm/src/context.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,14 @@ pub unsafe fn create_module<'ll>(
145145
.replace("-Fi64", "");
146146
}
147147
}
148+
if llvm_version < (18, 0, 0) {
149+
if sess.target.arch == "x86" || sess.target.arch == "x86_64" {
150+
// LLVM 18 adjusts i128 to be 128-bit aligned on x86 variants.
151+
// Earlier LLVMs leave this as default alignment, so remove it.
152+
// See https://reviews.llvm.org/D86310
153+
target_data_layout = target_data_layout.replace("-i128:128", "");
154+
}
155+
}
148156

149157
// Ensure the data-layout values hardcoded remain the defaults.
150158
if sess.target.is_builtin {

compiler/rustc_llvm/llvm-wrapper/PassWrapper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ extern "C" void LLVMRustPrintTargetCPUs(LLVMTargetMachineRef TM,
368368
}
369369

370370
extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
371-
#ifdef LLVM_RUSTLLVM
371+
#if LLVM_VERSION_GE(18, 0)
372372
const TargetMachine *Target = unwrap(TM);
373373
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
374-
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
374+
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getAllProcessorFeatures();
375375
return FeatTable.size();
376376
#else
377377
return 0;
@@ -380,10 +380,10 @@ extern "C" size_t LLVMRustGetTargetFeaturesCount(LLVMTargetMachineRef TM) {
380380

381381
extern "C" void LLVMRustGetTargetFeature(LLVMTargetMachineRef TM, size_t Index,
382382
const char** Feature, const char** Desc) {
383-
#ifdef LLVM_RUSTLLVM
383+
#if LLVM_VERSION_GE(18, 0)
384384
const TargetMachine *Target = unwrap(TM);
385385
const MCSubtargetInfo *MCInfo = Target->getMCSubtargetInfo();
386-
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getFeatureTable();
386+
const ArrayRef<SubtargetFeatureKV> FeatTable = MCInfo->getAllProcessorFeatures();
387387
const SubtargetFeatureKV Feat = FeatTable[Index];
388388
*Feature = Feat.Key;
389389
*Desc = Feat.Desc;

compiler/rustc_middle/src/mir/mod.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1672,13 +1672,19 @@ mod size_asserts {
16721672
use super::*;
16731673
use rustc_data_structures::static_assert_size;
16741674
// tidy-alphabetical-start
1675-
static_assert_size!(BasicBlockData<'_>, 136);
1675+
// This can be removed after i128:128 is in the bootstrap compiler's target.
1676+
#[cfg(not(bootstrap))]
1677+
static_assert_size!(BasicBlockData<'_>, 144);
16761678
static_assert_size!(LocalDecl<'_>, 40);
16771679
static_assert_size!(SourceScopeData<'_>, 72);
16781680
static_assert_size!(Statement<'_>, 32);
16791681
static_assert_size!(StatementKind<'_>, 16);
1680-
static_assert_size!(Terminator<'_>, 104);
1681-
static_assert_size!(TerminatorKind<'_>, 88);
1682+
// This can be removed after i128:128 is in the bootstrap compiler's target.
1683+
#[cfg(not(bootstrap))]
1684+
static_assert_size!(Terminator<'_>, 112);
1685+
// This can be removed after i128:128 is in the bootstrap compiler's target.
1686+
#[cfg(not(bootstrap))]
1687+
static_assert_size!(TerminatorKind<'_>, 96);
16821688
static_assert_size!(VarDebugInfo<'_>, 88);
16831689
// tidy-alphabetical-end
16841690
}

compiler/rustc_target/src/spec/targets/i386_apple_ios.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub fn target() -> Target {
1111
llvm_target: ios_sim_llvm_target(arch).into(),
1212
pointer_width: 32,
1313
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
14-
f64:32:64-f80:128-n8:16:32-S128"
14+
i128:128-f64:32:64-f80:128-n8:16:32-S128"
1515
.into(),
1616
arch: arch.target_arch(),
1717
options: TargetOptions { max_atomic_width: Some(64), ..opts("ios", arch) },

compiler/rustc_target/src/spec/targets/i686_apple_darwin.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn target() -> Target {
1818
llvm_target: macos_llvm_target(Arch::I686).into(),
1919
pointer_width: 32,
2020
data_layout: "e-m:o-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
21-
f64:32:64-f80:128-n8:16:32-S128"
21+
i128:128-f64:32:64-f80:128-n8:16:32-S128"
2222
.into(),
2323
arch: arch.target_arch(),
2424
options: TargetOptions { mcount: "\u{1}mcount".into(), ..base },

compiler/rustc_target/src/spec/targets/i686_linux_android.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub fn target() -> Target {
1717
llvm_target: "i686-linux-android".into(),
1818
pointer_width: 32,
1919
data_layout: "e-m:e-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
20-
f64:32:64-f80:32-n8:16:32-S128"
20+
i128:128-f64:32:64-f80:32-n8:16:32-S128"
2121
.into(),
2222
arch: "x86".into(),
2323
options: TargetOptions { supported_sanitizers: SanitizerSet::ADDRESS, ..base },

compiler/rustc_target/src/spec/targets/i686_pc_windows_gnu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pub fn target() -> Target {
1919
llvm_target: "i686-pc-windows-gnu".into(),
2020
pointer_width: 32,
2121
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
22-
i64:64-f80:32-n8:16:32-a:0:32-S32"
22+
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
2323
.into(),
2424
arch: "x86".into(),
2525
options: base,

compiler/rustc_target/src/spec/targets/i686_pc_windows_gnullvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ pub fn target() -> Target {
1818
llvm_target: "i686-pc-windows-gnu".into(),
1919
pointer_width: 32,
2020
data_layout: "e-m:x-p:32:32-p270:32:32-p271:32:32-p272:64:64-\
21-
i64:64-f80:32-n8:16:32-a:0:32-S32"
21+
i64:64-i128:128-f80:32-n8:16:32-a:0:32-S32"
2222
.into(),
2323
arch: "x86".into(),
2424
options: base,

0 commit comments

Comments
 (0)