Skip to content

Commit da5f3ad

Browse files
SwSw
Sw
authored and
Sw
committed
Merged master:536ba6373f0 into amd-gfx:48333f64843
Local branch amd-gfx 48333f6 Merged master:332edcc6bd1 into amd-gfx:0e6fea325fb Remote branch master 536ba63 [Object] Change ELFObjectFile<ELFT>::getFileFormatName() to use BFD names
2 parents 48333f6 + 536ba63 commit da5f3ad

File tree

76 files changed

+1561
-1517
lines changed

Some content is hidden

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

76 files changed

+1561
-1517
lines changed

lld/test/ELF/basic-ppc.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
li 3,1
1010
sc
1111

12-
// CHECK: Format: ELF32-ppc
12+
// CHECK: Format: elf32-powerpc
1313
// CHECK-NEXT: Arch: powerpc
1414
// CHECK-NEXT: AddressSize: 32bit
1515
// CHECK-NEXT: LoadName:

lld/test/ELF/basic-ppc64.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
li 3,55
1515
sc
1616

17-
// CHECK:Format: ELF64-ppc64
17+
// CHECK: Format: elf64-powerpc
1818
// LE-NEXT: Arch: powerpc64le
1919
// BE-NEXT: Arch: powerpc64{{$}}
2020
// CHECK-NEXT: AddressSize: 64bit

lld/test/ELF/format-binary.test

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@
6060
# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
6161
# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64 %s
6262

63-
# X86-64: Format: ELF64-x86-64
63+
# X86-64: Format: elf64-x86-64
6464

6565
# RUN: echo 'OUTPUT_FORMAT("elf64-x86-64")' > %t.script
6666
# RUN: ld.lld -b binary %t.binary -T %t.script -o %t.out
6767
# RUN: llvm-readobj %t.out -sections -section-data -symbols | FileCheck -check-prefix=X86-64-in-quotes %s
6868

69-
# X86-64-in-quotes: Format: ELF64-x86-64
69+
# X86-64-in-quotes: Format: elf64-x86-64

lld/test/ELF/gnu-hash-table.s

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@
6868
# EMPTY-NEXT: Values: []
6969
# EMPTY-NEXT: }
7070

71-
# I386: Format: ELF32-i386
71+
# I386: Format: elf32-i386
7272
# I386: Arch: i386
7373
# I386: AddressSize: 32bit
7474
# I386: Sections [
@@ -127,7 +127,7 @@
127127
# I386-NEXT: Values: [0xB8860BA, 0xB887389]
128128
# I386-NEXT: }
129129

130-
# X86_64: Format: ELF64-x86-64
130+
# X86_64: Format: elf64-x86-64
131131
# X86_64: Arch: x86_64
132132
# X86_64: AddressSize: 64bit
133133
# X86_64: Sections [
@@ -187,7 +187,7 @@
187187
# X86_64-NEXT: Values: [0xB8860BA, 0xB887389]
188188
# X86_64-NEXT: }
189189

190-
# PPC64: Format: ELF64-ppc64
190+
# PPC64: Format: elf64-powerpc
191191
# PPC64: Arch: powerpc64
192192
# PPC64: AddressSize: 64bit
193193
# PPC64: Sections [

lld/test/ELF/linkerscript/linker-script-in-search-path.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
# RUN: echo 'OUTPUT("%t.out")' > %t.dir/script
88
# RUN: ld.lld -T%t.dir/script %t.o
99
# RUN: llvm-readobj %t.out | FileCheck %s
10-
# CHECK: Format: ELF64-x86-64
10+
# CHECK: Format: elf64-x86-64
1111

1212
# If the linker script specified with -T is missing we should emit an error
1313
# RUN: not ld.lld -Tscript %t.o 2>&1 | FileCheck %s -check-prefix ERROR

lld/test/ELF/lto/lto-start.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
; RUN: ld.lld %t.o -o %t2
44
; RUN: llvm-readobj --symbols %t2 | FileCheck %s
55

6-
; CHECK: Format: ELF64-x86-64
6+
; CHECK: Format: elf64-x86-64
77
; CHECK-NEXT: Arch: x86_64
88
; CHECK-NEXT: AddressSize: 64bit
99

lld/test/ELF/lto/obj-path.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,10 +16,10 @@
1616
; CHECK-NEXT: T g
1717

1818
; NM1: T f
19-
; ELF1: Format: ELF64-x86-64
19+
; ELF1: Format: elf64-x86-64
2020

2121
; NM2: T g
22-
; ELF2: Format: ELF64-x86-64
22+
; ELF2: Format: elf64-x86-64
2323

2424
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2525
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/lto/thinlto-debug-fission.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
; RUN: ld.lld --plugin-opt=dwo_dir=%t.dir -shared %t1.o -o /dev/null
88
; RUN: llvm-readobj -h %t.dir/0.dwo | FileCheck %s
99

10-
; CHECK: Format: ELF64-x86-64
10+
; CHECK: Format: elf64-x86-64
1111

1212
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
1313
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/lto/thinlto-obj-path.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
; RUN: ld.lld -thinlto-index-only -lto-obj-path=%t4.o -shared %t1.o %t2.o -o /dev/null
1515
; RUN: llvm-readobj -h %t4.o | FileCheck %s
1616

17-
; CHECK: Format: ELF64-x86-64
17+
; CHECK: Format: elf64-x86-64
1818

1919
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2020
target triple = "x86_64-unknown-linux-gnu"

lld/test/ELF/relocatable-empty-archive.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
# RUN: ld.lld -m elf_x86_64 %t.a -o %t -r
55
# RUN: llvm-readobj --file-headers %t | FileCheck %s
66

7-
# CHECK: Format: ELF64-x86-64
7+
# CHECK: Format: elf64-x86-64
88
# CHECK: Arch: x86_64
99
# CHECK: AddressSize: 64bit
1010
# CHECK: Type: Relocatable

lld/test/ELF/relocatable.s

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@
7575
# CHECKTEXT-NEXT: 40: c7 04 25 00 00 00 00 08 00 00 00 movl $8, 0
7676
# CHECKTEXT-NEXT: 4b: c7 04 25 00 00 00 00 09 00 00 00 movl $9, 0
7777

78-
# CHECKEXE: Format: ELF64-x86-64
78+
# CHECKEXE: Format: elf64-x86-64
7979
# CHECKEXE-NEXT: Arch: x86_64
8080
# CHECKEXE-NEXT: AddressSize: 64bit
8181
# CHECKEXE-NEXT: LoadName:

llvm/include/llvm/CodeGen/GlobalISel/LegalizationArtifactCombiner.h

Lines changed: 63 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,8 @@ class LegalizationArtifactCombiner {
167167

168168
bool tryCombineTrunc(MachineInstr &MI,
169169
SmallVectorImpl<MachineInstr *> &DeadInsts,
170-
SmallVectorImpl<Register> &UpdatedDefs) {
170+
SmallVectorImpl<Register> &UpdatedDefs,
171+
GISelObserverWrapper &Observer) {
171172
assert(MI.getOpcode() == TargetOpcode::G_TRUNC);
172173

173174
Builder.setInstr(MI);
@@ -189,6 +190,66 @@ class LegalizationArtifactCombiner {
189190
}
190191
}
191192

193+
// Try to fold trunc(merge) to directly use the source of the merge.
194+
// This gets rid of large, difficult to legalize, merges
195+
if (SrcMI->getOpcode() == TargetOpcode::G_MERGE_VALUES) {
196+
const Register MergeSrcReg = SrcMI->getOperand(1).getReg();
197+
const LLT MergeSrcTy = MRI.getType(MergeSrcReg);
198+
const LLT DstTy = MRI.getType(DstReg);
199+
200+
// We can only fold if the types are scalar
201+
const unsigned DstSize = DstTy.getSizeInBits();
202+
const unsigned MergeSrcSize = MergeSrcTy.getSizeInBits();
203+
if (!DstTy.isScalar() || !MergeSrcTy.isScalar())
204+
return false;
205+
206+
if (DstSize < MergeSrcSize) {
207+
// When the merge source is larger than the destination, we can just
208+
// truncate the merge source directly
209+
if (isInstUnsupported({TargetOpcode::G_TRUNC, {DstTy, MergeSrcTy}}))
210+
return false;
211+
212+
LLVM_DEBUG(dbgs() << "Combining G_TRUNC(G_MERGE_VALUES) to G_TRUNC: "
213+
<< MI);
214+
215+
Builder.buildTrunc(DstReg, MergeSrcReg);
216+
UpdatedDefs.push_back(DstReg);
217+
} else if (DstSize == MergeSrcSize) {
218+
// If the sizes match we can simply try to replace the register
219+
LLVM_DEBUG(
220+
dbgs() << "Replacing G_TRUNC(G_MERGE_VALUES) with merge input: "
221+
<< MI);
222+
replaceRegOrBuildCopy(DstReg, MergeSrcReg, MRI, Builder, UpdatedDefs,
223+
Observer);
224+
} else if (DstSize % MergeSrcSize == 0) {
225+
// If the trunc size is a multiple of the merge source size we can use
226+
// a smaller merge instead
227+
if (isInstUnsupported(
228+
{TargetOpcode::G_MERGE_VALUES, {DstTy, MergeSrcTy}}))
229+
return false;
230+
231+
LLVM_DEBUG(
232+
dbgs() << "Combining G_TRUNC(G_MERGE_VALUES) to G_MERGE_VALUES: "
233+
<< MI);
234+
235+
const unsigned NumSrcs = DstSize / MergeSrcSize;
236+
assert(NumSrcs < SrcMI->getNumOperands() - 1 &&
237+
"trunc(merge) should require less inputs than merge");
238+
SmallVector<Register, 2> SrcRegs(NumSrcs);
239+
for (unsigned i = 0; i < NumSrcs; ++i)
240+
SrcRegs[i] = SrcMI->getOperand(i + 1).getReg();
241+
242+
Builder.buildMerge(DstReg, SrcRegs);
243+
UpdatedDefs.push_back(DstReg);
244+
} else {
245+
// Unable to combine
246+
return false;
247+
}
248+
249+
markInstAndDefDead(MI, *SrcMI, DeadInsts);
250+
return true;
251+
}
252+
192253
return false;
193254
}
194255

@@ -533,7 +594,7 @@ class LegalizationArtifactCombiner {
533594
Changed = tryCombineExtract(MI, DeadInsts, UpdatedDefs);
534595
break;
535596
case TargetOpcode::G_TRUNC:
536-
Changed = tryCombineTrunc(MI, DeadInsts, UpdatedDefs);
597+
Changed = tryCombineTrunc(MI, DeadInsts, UpdatedDefs, WrapperObserver);
537598
if (!Changed) {
538599
// Try to combine truncates away even if they are legal. As all artifact
539600
// combines at the moment look only "up" the def-use chains, we achieve

llvm/include/llvm/Object/ELFObjectFile.h

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,59 +1060,59 @@ StringRef ELFObjectFile<ELFT>::getFileFormatName() const {
10601060
case ELF::ELFCLASS32:
10611061
switch (EF.getHeader()->e_machine) {
10621062
case ELF::EM_386:
1063-
return "ELF32-i386";
1063+
return "elf32-i386";
10641064
case ELF::EM_IAMCU:
1065-
return "ELF32-iamcu";
1065+
return "elf32-iamcu";
10661066
case ELF::EM_X86_64:
1067-
return "ELF32-x86-64";
1067+
return "elf32-x86-64";
10681068
case ELF::EM_ARM:
1069-
return (IsLittleEndian ? "ELF32-arm-little" : "ELF32-arm-big");
1069+
return (IsLittleEndian ? "elf32-littlearm" : "elf32-bigarm");
10701070
case ELF::EM_AVR:
1071-
return "ELF32-avr";
1071+
return "elf32-avr";
10721072
case ELF::EM_HEXAGON:
1073-
return "ELF32-hexagon";
1073+
return "elf32-hexagon";
10741074
case ELF::EM_LANAI:
1075-
return "ELF32-lanai";
1075+
return "elf32-lanai";
10761076
case ELF::EM_MIPS:
1077-
return "ELF32-mips";
1077+
return "elf32-mips";
10781078
case ELF::EM_MSP430:
1079-
return "ELF32-msp430";
1079+
return "elf32-msp430";
10801080
case ELF::EM_PPC:
1081-
return "ELF32-ppc";
1081+
return "elf32-powerpc";
10821082
case ELF::EM_RISCV:
1083-
return "ELF32-riscv";
1083+
return "elf32-littleriscv";
10841084
case ELF::EM_SPARC:
10851085
case ELF::EM_SPARC32PLUS:
1086-
return "ELF32-sparc";
1086+
return "elf32-sparc";
10871087
case ELF::EM_AMDGPU:
1088-
return "ELF32-amdgpu";
1088+
return "elf32-amdgpu";
10891089
default:
1090-
return "ELF32-unknown";
1090+
return "elf32-unknown";
10911091
}
10921092
case ELF::ELFCLASS64:
10931093
switch (EF.getHeader()->e_machine) {
10941094
case ELF::EM_386:
1095-
return "ELF64-i386";
1095+
return "elf64-i386";
10961096
case ELF::EM_X86_64:
1097-
return "ELF64-x86-64";
1097+
return "elf64-x86-64";
10981098
case ELF::EM_AARCH64:
1099-
return (IsLittleEndian ? "ELF64-aarch64-little" : "ELF64-aarch64-big");
1099+
return (IsLittleEndian ? "elf64-littleaarch64" : "elf64-bigaarch64");
11001100
case ELF::EM_PPC64:
1101-
return "ELF64-ppc64";
1101+
return "elf64-powerpc";
11021102
case ELF::EM_RISCV:
1103-
return "ELF64-riscv";
1103+
return "elf64-littleriscv";
11041104
case ELF::EM_S390:
1105-
return "ELF64-s390";
1105+
return "elf64-s390";
11061106
case ELF::EM_SPARCV9:
1107-
return "ELF64-sparc";
1107+
return "elf64-sparc";
11081108
case ELF::EM_MIPS:
1109-
return "ELF64-mips";
1109+
return "elf64-mips";
11101110
case ELF::EM_AMDGPU:
1111-
return "ELF64-amdgpu";
1111+
return "elf64-amdgpu";
11121112
case ELF::EM_BPF:
1113-
return "ELF64-BPF";
1113+
return "elf64-bpf";
11141114
default:
1115-
return "ELF64-unknown";
1115+
return "elf64-unknown";
11161116
}
11171117
default:
11181118
// FIXME: Proper error handling.

llvm/lib/CodeGen/ExpandMemCmp.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,6 +273,8 @@ MemCmpExpansion::LoadPair MemCmpExpansion::getLoadPair(Type *LoadSizeType,
273273
// Get the memory source at offset `OffsetBytes`.
274274
Value *LhsSource = CI->getArgOperand(0);
275275
Value *RhsSource = CI->getArgOperand(1);
276+
Align LhsAlign = LhsSource->getPointerAlignment(DL).valueOrOne();
277+
Align RhsAlign = RhsSource->getPointerAlignment(DL).valueOrOne();
276278
if (OffsetBytes > 0) {
277279
auto *ByteType = Type::getInt8Ty(CI->getContext());
278280
LhsSource = Builder.CreateConstGEP1_64(
@@ -281,6 +283,8 @@ MemCmpExpansion::LoadPair MemCmpExpansion::getLoadPair(Type *LoadSizeType,
281283
RhsSource = Builder.CreateConstGEP1_64(
282284
ByteType, Builder.CreateBitCast(RhsSource, ByteType->getPointerTo()),
283285
OffsetBytes);
286+
LhsAlign = commonAlignment(LhsAlign, OffsetBytes);
287+
RhsAlign = commonAlignment(RhsAlign, OffsetBytes);
284288
}
285289
LhsSource = Builder.CreateBitCast(LhsSource, LoadSizeType->getPointerTo());
286290
RhsSource = Builder.CreateBitCast(RhsSource, LoadSizeType->getPointerTo());
@@ -290,13 +294,13 @@ MemCmpExpansion::LoadPair MemCmpExpansion::getLoadPair(Type *LoadSizeType,
290294
if (auto *C = dyn_cast<Constant>(LhsSource))
291295
Lhs = ConstantFoldLoadFromConstPtr(C, LoadSizeType, DL);
292296
if (!Lhs)
293-
Lhs = Builder.CreateLoad(LoadSizeType, LhsSource);
297+
Lhs = Builder.CreateAlignedLoad(LoadSizeType, LhsSource, LhsAlign);
294298

295299
Value *Rhs = nullptr;
296300
if (auto *C = dyn_cast<Constant>(RhsSource))
297301
Rhs = ConstantFoldLoadFromConstPtr(C, LoadSizeType, DL);
298302
if (!Rhs)
299-
Rhs = Builder.CreateLoad(LoadSizeType, RhsSource);
303+
Rhs = Builder.CreateAlignedLoad(LoadSizeType, RhsSource, RhsAlign);
300304

301305
// Swap bytes if required.
302306
if (NeedsBSwap) {

llvm/lib/CodeGen/SelectionDAG/TargetLowering.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1634,6 +1634,14 @@ bool TargetLowering::SimplifyDemandedBits(
16341634
Known.One |= Known2.One;
16351635
Known.Zero |= Known2.Zero;
16361636
}
1637+
1638+
// For pow-2 bitwidths we only demand the bottom modulo amt bits.
1639+
if (isPowerOf2_32(BitWidth)) {
1640+
APInt DemandedAmtBits(Op2.getScalarValueSizeInBits(), BitWidth - 1);
1641+
if (SimplifyDemandedBits(Op2, DemandedAmtBits, DemandedElts,
1642+
Known2, TLO, Depth + 1))
1643+
return true;
1644+
}
16371645
break;
16381646
}
16391647
case ISD::ROTL:

llvm/lib/ExecutionEngine/RuntimeDyld/RuntimeDyldELF.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -554,7 +554,7 @@ void RuntimeDyldELF::setMipsABI(const ObjectFile &Obj) {
554554
IsMipsO32ABI = AbiVariant & ELF::EF_MIPS_ABI_O32;
555555
IsMipsN32ABI = AbiVariant & ELF::EF_MIPS_ABI2;
556556
}
557-
IsMipsN64ABI = Obj.getFileFormatName().equals("ELF64-mips");
557+
IsMipsN64ABI = Obj.getFileFormatName().equals("elf64-mips");
558558
}
559559

560560
// Return the .TOC. section and offset.

llvm/test/CodeGen/AArch64/GlobalISel/legalize-undef.mir

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,7 @@ body: |
88
99
; CHECK-LABEL: name: test_implicit_def
1010
; CHECK: [[DEF:%[0-9]+]]:_(s64) = G_IMPLICIT_DEF
11-
; CHECK: [[MV:%[0-9]+]]:_(s128) = G_MERGE_VALUES [[DEF]](s64), [[DEF]](s64)
12-
; CHECK: [[TRUNC:%[0-9]+]]:_(s64) = G_TRUNC [[MV]](s128)
13-
; CHECK: $x0 = COPY [[TRUNC]](s64)
11+
; CHECK: $x0 = COPY [[DEF]](s64)
1412
%0:_(s128) = G_IMPLICIT_DEF
1513
%1:_(s64) = G_TRUNC %0(s128)
1614
$x0 = COPY %1(s64)

llvm/test/CodeGen/AArch64/arm64-simplest-elf.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ define void @foo() nounwind {
1111

1212
; Similarly make sure ELF output works and is vaguely sane: aarch64 target
1313
; machine with correct section & symbol names.
14-
; CHECK-ELF: file format elf64-aarch64
14+
; CHECK-ELF: file format elf64-littleaarch64
1515

1616
; CHECK-ELF: Disassembly of section .text
1717
; CHECK-ELF-LABEL: <foo>:

0 commit comments

Comments
 (0)