Skip to content

Commit e006345

Browse files
authored
Merge pull request llvm#574 from AMD-Lightning-Internal/upstream_merge_202502090124
merge main into amd-staging
2 parents 213543d + 0c284d5 commit e006345

File tree

11 files changed

+244
-69
lines changed

11 files changed

+244
-69
lines changed

lld/ELF/Driver.cpp

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -371,37 +371,56 @@ static void checkOptions(Ctx &ctx) {
371371
if (!ctx.arg.cmseOutputLib.empty())
372372
ErrAlways(ctx) << "--out-implib may not be used without --cmse-implib";
373373
}
374+
if (ctx.arg.fixCortexA8 && !ctx.arg.isLE)
375+
ErrAlways(ctx)
376+
<< "--fix-cortex-a8 is not supported on big endian targets";
374377
} else {
375378
if (ctx.arg.cmseImplib)
376379
ErrAlways(ctx) << "--cmse-implib is only supported on ARM targets";
377380
if (!ctx.arg.cmseInputLib.empty())
378381
ErrAlways(ctx) << "--in-implib is only supported on ARM targets";
379382
if (!ctx.arg.cmseOutputLib.empty())
380383
ErrAlways(ctx) << "--out-implib is only supported on ARM targets";
384+
if (ctx.arg.fixCortexA8)
385+
ErrAlways(ctx) << "--fix-cortex-a8 is only supported on ARM targets";
386+
if (ctx.arg.armBe8)
387+
ErrAlways(ctx) << "--be8 is only supported on ARM targets";
381388
}
382389

383-
if (ctx.arg.fixCortexA53Errata843419 && ctx.arg.emachine != EM_AARCH64)
384-
ErrAlways(ctx)
385-
<< "--fix-cortex-a53-843419 is only supported on AArch64 targets";
386-
387-
if (ctx.arg.fixCortexA8 && ctx.arg.emachine != EM_ARM)
388-
ErrAlways(ctx) << "--fix-cortex-a8 is only supported on ARM targets";
389-
390-
if (ctx.arg.armBe8 && ctx.arg.emachine != EM_ARM)
391-
ErrAlways(ctx) << "--be8 is only supported on ARM targets";
392-
393-
if (ctx.arg.fixCortexA8 && !ctx.arg.isLE)
394-
ErrAlways(ctx) << "--fix-cortex-a8 is not supported on big endian targets";
395-
396-
if (ctx.arg.tocOptimize && ctx.arg.emachine != EM_PPC64)
397-
ErrAlways(ctx) << "--toc-optimize is only supported on PowerPC64 targets";
390+
if (ctx.arg.emachine != EM_AARCH64) {
391+
if (ctx.arg.executeOnly)
392+
ErrAlways(ctx) << "--execute-only is only supported on AArch64 targets";
393+
if (ctx.arg.fixCortexA53Errata843419)
394+
ErrAlways(ctx) << "--fix-cortex-a53-843419 is only supported on AArch64";
395+
if (ctx.arg.zPacPlt)
396+
ErrAlways(ctx) << "-z pac-plt only supported on AArch64";
397+
if (ctx.arg.zForceBti)
398+
ErrAlways(ctx) << "-z force-bti only supported on AArch64";
399+
if (ctx.arg.zBtiReport != "none")
400+
ErrAlways(ctx) << "-z bti-report only supported on AArch64";
401+
if (ctx.arg.zPauthReport != "none")
402+
ErrAlways(ctx) << "-z pauth-report only supported on AArch64";
403+
if (ctx.arg.zGcsReport != "none")
404+
ErrAlways(ctx) << "-z gcs-report only supported on AArch64";
405+
if (ctx.arg.zGcs != GcsPolicy::Implicit)
406+
ErrAlways(ctx) << "-z gcs only supported on AArch64";
407+
}
398408

399-
if (ctx.arg.pcRelOptimize && ctx.arg.emachine != EM_PPC64)
400-
ErrAlways(ctx) << "--pcrel-optimize is only supported on PowerPC64 targets";
409+
if (ctx.arg.emachine != EM_PPC64) {
410+
if (ctx.arg.tocOptimize)
411+
ErrAlways(ctx) << "--toc-optimize is only supported on PowerPC64 targets";
412+
if (ctx.arg.pcRelOptimize)
413+
ErrAlways(ctx)
414+
<< "--pcrel-optimize is only supported on PowerPC64 targets";
415+
}
401416

402417
if (ctx.arg.relaxGP && ctx.arg.emachine != EM_RISCV)
403418
ErrAlways(ctx) << "--relax-gp is only supported on RISC-V targets";
404419

420+
if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
421+
ctx.arg.zCetReport != "none")
422+
ErrAlways(ctx) << "-z cet-report only supported on X86 and X86_64";
423+
405424
if (ctx.arg.pie && ctx.arg.shared)
406425
ErrAlways(ctx) << "-shared and -pie may not be used together";
407426

@@ -435,35 +454,13 @@ static void checkOptions(Ctx &ctx) {
435454
}
436455

437456
if (ctx.arg.executeOnly) {
438-
if (ctx.arg.emachine != EM_AARCH64)
439-
ErrAlways(ctx) << "--execute-only is only supported on AArch64 targets";
440-
441457
if (ctx.arg.singleRoRx && !ctx.script->hasSectionsCommand)
442458
ErrAlways(ctx)
443459
<< "--execute-only and --no-rosegment cannot be used together";
444460
}
445461

446462
if (ctx.arg.zRetpolineplt && ctx.arg.zForceIbt)
447463
ErrAlways(ctx) << "-z force-ibt may not be used with -z retpolineplt";
448-
449-
if (ctx.arg.emachine != EM_AARCH64) {
450-
if (ctx.arg.zPacPlt)
451-
ErrAlways(ctx) << "-z pac-plt only supported on AArch64";
452-
if (ctx.arg.zForceBti)
453-
ErrAlways(ctx) << "-z force-bti only supported on AArch64";
454-
if (ctx.arg.zBtiReport != "none")
455-
ErrAlways(ctx) << "-z bti-report only supported on AArch64";
456-
if (ctx.arg.zPauthReport != "none")
457-
ErrAlways(ctx) << "-z pauth-report only supported on AArch64";
458-
if (ctx.arg.zGcsReport != "none")
459-
ErrAlways(ctx) << "-z gcs-report only supported on AArch64";
460-
if (ctx.arg.zGcs != GcsPolicy::Implicit)
461-
ErrAlways(ctx) << "-z gcs only supported on AArch64";
462-
}
463-
464-
if (ctx.arg.emachine != EM_386 && ctx.arg.emachine != EM_X86_64 &&
465-
ctx.arg.zCetReport != "none")
466-
ErrAlways(ctx) << "-z cet-report only supported on X86 and X86_64";
467464
}
468465

469466
static const char *getReproduceOption(opt::InputArgList &args) {

lld/test/ELF/target-specific-options.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t
33

44
# RUN: not ld.lld %t --fix-cortex-a53-843419 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-843419
5-
# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64 targets
5+
# ERR-843419: error: --fix-cortex-a53-843419 is only supported on AArch64
66

77
# RUN: not ld.lld %t --be8 -o /dev/null 2>&1 | FileCheck %s --check-prefix=ERR-BE8
88
# ERR-BE8: error: --be8 is only supported on ARM targets

lldb/source/Plugins/ABI/X86/ABISysV_x86_64.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ ABISysV_x86_64::CreateInstance(lldb::ProcessSP process_sp, const ArchSpec &arch)
7979
case llvm::Triple::OSType::IOS:
8080
case llvm::Triple::OSType::TvOS:
8181
case llvm::Triple::OSType::WatchOS:
82+
case llvm::Triple::OSType::XROS:
8283
switch (os_env) {
8384
case llvm::Triple::EnvironmentType::MacABI:
8485
case llvm::Triple::EnvironmentType::Simulator:

lldb/source/Plugins/DynamicLoader/MacOSX-DYLD/DynamicLoaderDarwin.cpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,8 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
419419
image_infos[i].os_type = llvm::Triple::WatchOS;
420420
else if (os_name == "bridgeos")
421421
image_infos[i].os_type = llvm::Triple::BridgeOS;
422+
else if (os_name == "xros")
423+
image_infos[i].os_type = llvm::Triple::XROS;
422424
else if (os_name == "maccatalyst") {
423425
image_infos[i].os_type = llvm::Triple::IOS;
424426
image_infos[i].os_env = llvm::Triple::MacABI;
@@ -431,6 +433,9 @@ bool DynamicLoaderDarwin::JSONImageInformationIntoImageInfo(
431433
} else if (os_name == "watchossimulator") {
432434
image_infos[i].os_type = llvm::Triple::WatchOS;
433435
image_infos[i].os_env = llvm::Triple::Simulator;
436+
} else if (os_name == "xrsimulator") {
437+
image_infos[i].os_type = llvm::Triple::XROS;
438+
image_infos[i].os_env = llvm::Triple::Simulator;
434439
}
435440
}
436441
if (image->HasKey("min_version_os_sdk")) {
@@ -765,7 +770,8 @@ bool DynamicLoaderDarwin::AddModulesUsingPreloadedModules(
765770
(dyld_triple.getEnvironment() == llvm::Triple::Simulator &&
766771
(dyld_triple.getOS() == llvm::Triple::IOS ||
767772
dyld_triple.getOS() == llvm::Triple::TvOS ||
768-
dyld_triple.getOS() == llvm::Triple::WatchOS)))
773+
dyld_triple.getOS() == llvm::Triple::WatchOS ||
774+
dyld_triple.getOS() == llvm::Triple::XROS)))
769775
image_module_sp->MergeArchitecture(dyld_spec);
770776
}
771777
}
@@ -835,7 +841,7 @@ lldb_private::ArchSpec DynamicLoaderDarwin::ImageInfo::GetArchitecture() const {
835841
}
836842
if (os_env == llvm::Triple::Simulator &&
837843
(os_type == llvm::Triple::IOS || os_type == llvm::Triple::TvOS ||
838-
os_type == llvm::Triple::WatchOS)) {
844+
os_type == llvm::Triple::WatchOS || os_type == llvm::Triple::XROS)) {
839845
llvm::Triple triple(llvm::Twine(arch_spec.GetArchitectureName()) +
840846
"-apple-" + llvm::Triple::getOSTypeName(os_type) +
841847
min_version_os_sdk + "-simulator");

lldb/source/Plugins/ObjectFile/Mach-O/ObjectFileMachO.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2848,7 +2848,7 @@ void ObjectFileMachO::ParseSymtab(Symtab &symtab) {
28482848
"DSC unmapped local symbol[{0}] has invalid "
28492849
"string table offset {1:x} in {2}, ignoring symbol",
28502850
nlist_index, nlist.n_strx,
2851-
module_sp->GetFileSpec().GetPath());
2851+
module_sp->GetFileSpec().GetPath()));
28522852
continue;
28532853
}
28542854
if (symbol_name[0] == '\0')
@@ -6557,9 +6557,8 @@ bool ObjectFileMachO::SaveCore(const lldb::ProcessSP &process_sp,
65576557
target_triple.getOS() == llvm::Triple::IOS ||
65586558
target_triple.getOS() == llvm::Triple::WatchOS ||
65596559
target_triple.getOS() == llvm::Triple::TvOS ||
6560+
target_triple.getOS() == llvm::Triple::BridgeOS ||
65606561
target_triple.getOS() == llvm::Triple::XROS)) {
6561-
// NEED_BRIDGEOS_TRIPLE target_triple.getOS() == llvm::Triple::BridgeOS))
6562-
// {
65636562
bool make_core = false;
65646563
switch (target_arch.GetMachine()) {
65656564
case llvm::Triple::aarch64:

lldb/source/Plugins/Platform/MacOSX/PlatformDarwinKernel.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,7 @@ PlatformSP PlatformDarwinKernel::CreateInstance(bool force,
126126
case llvm::Triple::MacOSX:
127127
case llvm::Triple::IOS:
128128
case llvm::Triple::WatchOS:
129+
case llvm::Triple::XROS:
129130
case llvm::Triple::TvOS:
130131
case llvm::Triple::BridgeOS:
131132
break;
@@ -329,6 +330,8 @@ void PlatformDarwinKernel::CollectKextAndKernelDirectories() {
329330
"/Platforms/AppleTVOS.platform/Developer/SDKs");
330331
AddSDKSubdirsToSearchPaths(developer_dir +
331332
"/Platforms/WatchOS.platform/Developer/SDKs");
333+
AddSDKSubdirsToSearchPaths(developer_dir +
334+
"/Platforms/XROS.platform/Developer/SDKs");
332335
AddSDKSubdirsToSearchPaths(developer_dir +
333336
"/Platforms/BridgeOS.platform/Developer/SDKs");
334337
}

lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerCommon.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -212,6 +212,8 @@ GDBRemoteCommunicationServerCommon::Handle_qHostInfo(
212212
response.PutCString("ostype:tvos;");
213213
#elif defined(TARGET_OS_WATCH) && TARGET_OS_WATCH == 1
214214
response.PutCString("ostype:watchos;");
215+
#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
216+
response.PutCString("ostype:xros;");
215217
#elif defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE == 1
216218
response.PutCString("ostype:bridgeos;");
217219
#else

lldb/tools/debugserver/source/RNBRemote.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6369,6 +6369,8 @@ rnb_err_t RNBRemote::HandlePacket_qProcessInfo(const char *p) {
63696369
rep << "ostype:bridgeos;";
63706370
#elif defined(TARGET_OS_OSX) && TARGET_OS_OSX == 1
63716371
rep << "ostype:macosx;";
6372+
#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
6373+
rep << "ostype:xros;";
63726374
#else
63736375
rep << "ostype:ios;";
63746376
#endif
@@ -6422,6 +6424,8 @@ rnb_err_t RNBRemote::HandlePacket_qProcessInfo(const char *p) {
64226424
rep << "ostype:watchos;";
64236425
#elif defined(TARGET_OS_BRIDGE) && TARGET_OS_BRIDGE == 1
64246426
rep << "ostype:bridgeos;";
6427+
#elif defined(TARGET_OS_XR) && TARGET_OS_XR == 1
6428+
rep << "ostype:xros;";
64256429
#else
64266430
rep << "ostype:ios;";
64276431
#endif

llvm/lib/Target/RISCV/RISCVInstrInfo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,11 @@ void RISCVInstrInfo::copyPhysRegVector(
437437
MIB.addReg(RISCV::VL, RegState::Implicit);
438438
MIB.addReg(RISCV::VTYPE, RegState::Implicit);
439439
}
440+
// Add an implicit read of the original source to silence the verifier
441+
// in the cases where some of the smaller VRs we're copying from might be
442+
// undef, caused by the fact that the original, larger source VR might not
443+
// be fully initialized at the time this COPY happens.
444+
MIB.addReg(SrcReg, RegState::Implicit);
440445

441446
// If we are copying reversely, we should decrease the encoding.
442447
SrcEncoding += (ReversedCopy ? -NumCopied : NumCopied);
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 5
2+
# RUN: llc -mtriple=riscv64 -mattr=+v -run-pass=postrapseudos %s -o - | FileCheck %s
3+
4+
---
5+
name: copy
6+
isSSA: false
7+
noVRegs: true
8+
liveins:
9+
- { reg: '$v0', virtual-reg: '' }
10+
body: |
11+
bb.0:
12+
liveins: $v0
13+
14+
; CHECK-LABEL: name: copy
15+
; CHECK: liveins: $v0
16+
; CHECK-NEXT: {{ $}}
17+
; CHECK-NEXT: $v20m2 = VMV2R_V $v14m2, implicit $vtype, implicit $v14_v15_v16_v17_v18
18+
; CHECK-NEXT: $v22m2 = VMV2R_V $v16m2, implicit $vtype, implicit $v14_v15_v16_v17_v18
19+
; CHECK-NEXT: $v24 = VMV1R_V $v18, implicit $vtype, implicit $v14_v15_v16_v17_v18, implicit $vtype
20+
; CHECK-NEXT: PseudoRET implicit $v0
21+
renamable $v20_v21_v22_v23_v24 = COPY renamable $v14_v15_v16_v17_v18, implicit $vtype
22+
PseudoRET implicit $v0
23+
24+
...

0 commit comments

Comments
 (0)