Skip to content

Commit 1d4c3cc

Browse files
SC llvm teamSC llvm team
SC llvm team
authored and
SC llvm team
committed
Merged main:503bc5f66111 into amd-gfx:2a4e1350d643
Local branch amd-gfx 2a4e135 Merged main:7e856d18943f into amd-gfx:696586eb9f42 Remote branch main 503bc5f [LLD] [COFF] Fix handling of comdat .drectve sections (llvm#68116)
2 parents 2a4e135 + 503bc5f commit 1d4c3cc

File tree

31 files changed

+160
-147
lines changed

31 files changed

+160
-147
lines changed

lld/COFF/InputFiles.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -661,6 +661,8 @@ std::optional<Symbol *> ObjFile::createDefined(
661661
if (prevailing) {
662662
SectionChunk *c = readSection(sectionNumber, def, getName());
663663
sparseChunks[sectionNumber] = c;
664+
if (!c)
665+
return nullptr;
664666
c->sym = cast<DefinedRegular>(leader);
665667
c->selection = selection;
666668
cast<DefinedRegular>(leader)->data = &c->repl;

lld/test/COFF/comdat-drectve.s

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# REQUIRES: x86
2+
3+
# RUN: llvm-mc -triple=x86_64-windows-gnu %s -filetype=obj -o %t.obj
4+
5+
# RUN: lld-link %t.obj -out:%t.exe -debug:symtab -subsystem:console
6+
# RUN: llvm-readobj --coff-exports %t.exe | FileCheck %s
7+
8+
# CHECK: Name: exportedFunc
9+
10+
## This assembly snippet has been reduced from what Clang generates from
11+
## this C snippet, with -fsanitize=address. Normally, the .drectve
12+
## section would be a regular section - but when compiled with
13+
## -fsanitize=address, it becomes a comdat section.
14+
##
15+
# void exportedFunc(void) {}
16+
# void mainCRTStartup(void) {}
17+
# static __attribute__((section(".drectve"), used)) const char export_chkstk[] =
18+
# "-export:exportedFunc";
19+
20+
.text
21+
.globl exportedFunc
22+
exportedFunc:
23+
retq
24+
25+
.globl mainCRTStartup
26+
mainCRTStartup:
27+
retq
28+
29+
.section .drectve,"dr",one_only,export_chkstk
30+
export_chkstk:
31+
.asciz "-export:exportedFunc"

llvm/include/llvm/Config/llvm-config.h.cmake

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
/* Indicate that this is LLVM compiled from the amd-gfx branch. */
1818
#define LLVM_HAVE_BRANCH_AMD_GFX
19-
#define LLVM_MAIN_REVISION 476726
19+
#define LLVM_MAIN_REVISION 476733
2020

2121
/* Define if LLVM_ENABLE_DUMP is enabled */
2222
#cmakedefine LLVM_ENABLE_DUMP

llvm/lib/Target/AArch64/GISel/AArch64InstructionSelector.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2251,7 +2251,7 @@ bool AArch64InstructionSelector::earlySelect(MachineInstr &I) {
22512251
// Before selecting a DUP instruction, check if it is better selected as a
22522252
// MOV or load from a constant pool.
22532253
Register Src = I.getOperand(1).getReg();
2254-
auto ValAndVReg = getIConstantVRegValWithLookThrough(Src, MRI);
2254+
auto ValAndVReg = getAnyConstantVRegValWithLookThrough(Src, MRI);
22552255
if (!ValAndVReg)
22562256
return false;
22572257
LLVMContext &Ctx = MF.getFunction().getContext();
@@ -5600,8 +5600,7 @@ MachineInstr *AArch64InstructionSelector::tryAdvSIMDModImmFP(
56005600
if (DstSize == 128) {
56015601
if (Bits.getHiBits(64) != Bits.getLoBits(64))
56025602
return nullptr;
5603-
// Need to deal with 4f32
5604-
Op = AArch64::FMOVv2f64_ns;
5603+
Op = AArch64::FMOVv4f32_ns;
56055604
IsWide = true;
56065605
} else {
56075606
Op = AArch64::FMOVv2f32_ns;
@@ -5610,9 +5609,10 @@ MachineInstr *AArch64InstructionSelector::tryAdvSIMDModImmFP(
56105609
uint64_t Val = Bits.zextOrTrunc(64).getZExtValue();
56115610

56125611
if (AArch64_AM::isAdvSIMDModImmType11(Val)) {
5613-
Val = AArch64_AM::encodeAdvSIMDModImmType7(Val);
5612+
Val = AArch64_AM::encodeAdvSIMDModImmType11(Val);
56145613
} else if (IsWide && AArch64_AM::isAdvSIMDModImmType12(Val)) {
56155614
Val = AArch64_AM::encodeAdvSIMDModImmType12(Val);
5615+
Op = AArch64::FMOVv2f64_ns;
56165616
} else
56175617
return nullptr;
56185618

llvm/test/CodeGen/AArch64/GlobalISel/select-to-fmin-fmax.ll

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,7 @@ entry:
3939
define <4 x half> @test_v4s16(<4 x half> %a) #0 {
4040
; CHECK-LABEL: test_v4s16:
4141
; CHECK: // %bb.0: // %entry
42-
; CHECK-NEXT: movi d1, #0000000000000000
43-
; CHECK-NEXT: dup v1.4h, v1.h[0]
42+
; CHECK-NEXT: movi v1.2d, #0000000000000000
4443
; CHECK-NEXT: fmax v0.4h, v1.4h, v0.4h
4544
; CHECK-NEXT: ret
4645
entry:
@@ -52,8 +51,7 @@ entry:
5251
define <8 x half> @test_v8s16(<8 x half> %a) #0 {
5352
; CHECK-LABEL: test_v8s16:
5453
; CHECK: // %bb.0: // %entry
55-
; CHECK-NEXT: movi d1, #0000000000000000
56-
; CHECK-NEXT: dup v1.8h, v1.h[0]
54+
; CHECK-NEXT: movi v1.2d, #0000000000000000
5755
; CHECK-NEXT: fmax v0.8h, v1.8h, v0.8h
5856
; CHECK-NEXT: ret
5957
entry:
@@ -65,8 +63,7 @@ entry:
6563
define <2 x float> @test_v2s32(<2 x float> %a) #0 {
6664
; CHECK-LABEL: test_v2s32:
6765
; CHECK: // %bb.0: // %entry
68-
; CHECK-NEXT: movi d1, #0000000000000000
69-
; CHECK-NEXT: dup v1.2s, v1.s[0]
66+
; CHECK-NEXT: movi v1.2d, #0000000000000000
7067
; CHECK-NEXT: fmax v0.2s, v1.2s, v0.2s
7168
; CHECK-NEXT: ret
7269
entry:
@@ -78,8 +75,7 @@ entry:
7875
define <4 x float> @test_v4s32(<4 x float> %a) #0 {
7976
; CHECK-LABEL: test_v4s32:
8077
; CHECK: // %bb.0: // %entry
81-
; CHECK-NEXT: movi d1, #0000000000000000
82-
; CHECK-NEXT: dup v1.4s, v1.s[0]
78+
; CHECK-NEXT: movi v1.2d, #0000000000000000
8379
; CHECK-NEXT: fmax v0.4s, v1.4s, v0.4s
8480
; CHECK-NEXT: ret
8581
entry:
@@ -91,8 +87,7 @@ entry:
9187
define <2 x double> @test_v2s64(<2 x double> %a) #0 {
9288
; CHECK-LABEL: test_v2s64:
9389
; CHECK: // %bb.0: // %entry
94-
; CHECK-NEXT: movi d1, #0000000000000000
95-
; CHECK-NEXT: dup v1.2d, v1.d[0]
90+
; CHECK-NEXT: movi v1.2d, #0000000000000000
9691
; CHECK-NEXT: fmax v0.2d, v1.2d, v0.2d
9792
; CHECK-NEXT: ret
9893
entry:

llvm/test/CodeGen/AArch64/neon-mov.ll

Lines changed: 12 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -305,44 +305,26 @@ define <1 x i64> @movid() {
305305
}
306306

307307
define <2 x float> @fmov2s() {
308-
; CHECK-SD-LABEL: fmov2s:
309-
; CHECK-SD: // %bb.0:
310-
; CHECK-SD-NEXT: fmov v0.2s, #-12.00000000
311-
; CHECK-SD-NEXT: ret
312-
;
313-
; CHECK-GI-LABEL: fmov2s:
314-
; CHECK-GI: // %bb.0:
315-
; CHECK-GI-NEXT: fmov s0, #-12.00000000
316-
; CHECK-GI-NEXT: dup v0.2s, v0.s[0]
317-
; CHECK-GI-NEXT: ret
308+
; CHECK-LABEL: fmov2s:
309+
; CHECK: // %bb.0:
310+
; CHECK-NEXT: fmov v0.2s, #-12.00000000
311+
; CHECK-NEXT: ret
318312
ret <2 x float> < float -1.2e1, float -1.2e1>
319313
}
320314

321315
define <4 x float> @fmov4s() {
322-
; CHECK-SD-LABEL: fmov4s:
323-
; CHECK-SD: // %bb.0:
324-
; CHECK-SD-NEXT: fmov v0.4s, #-12.00000000
325-
; CHECK-SD-NEXT: ret
326-
;
327-
; CHECK-GI-LABEL: fmov4s:
328-
; CHECK-GI: // %bb.0:
329-
; CHECK-GI-NEXT: fmov s0, #-12.00000000
330-
; CHECK-GI-NEXT: dup v0.4s, v0.s[0]
331-
; CHECK-GI-NEXT: ret
316+
; CHECK-LABEL: fmov4s:
317+
; CHECK: // %bb.0:
318+
; CHECK-NEXT: fmov v0.4s, #-12.00000000
319+
; CHECK-NEXT: ret
332320
ret <4 x float> < float -1.2e1, float -1.2e1, float -1.2e1, float -1.2e1>
333321
}
334322

335323
define <2 x double> @fmov2d() {
336-
; CHECK-SD-LABEL: fmov2d:
337-
; CHECK-SD: // %bb.0:
338-
; CHECK-SD-NEXT: fmov v0.2d, #-12.00000000
339-
; CHECK-SD-NEXT: ret
340-
;
341-
; CHECK-GI-LABEL: fmov2d:
342-
; CHECK-GI: // %bb.0:
343-
; CHECK-GI-NEXT: fmov d0, #-12.00000000
344-
; CHECK-GI-NEXT: dup v0.2d, v0.d[0]
345-
; CHECK-GI-NEXT: ret
324+
; CHECK-LABEL: fmov2d:
325+
; CHECK: // %bb.0:
326+
; CHECK-NEXT: fmov v0.2d, #-12.00000000
327+
; CHECK-NEXT: ret
346328
ret <2 x double> < double -1.2e1, double -1.2e1>
347329
}
348330

llvm/unittests/DebugInfo/DWARF/DWARFDebugInfoTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@
3737
using namespace llvm;
3838
using namespace dwarf;
3939
using namespace utils;
40-
using ::testing::HasSubstr;
4140

4241
namespace {
4342

llvm/unittests/DebugInfo/DWARF/DWARFDieTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
using namespace llvm;
1717
using namespace llvm::dwarf;
18-
using object::SectionedAddress;
1918

2019
namespace {
2120

llvm/unittests/DebugInfo/DWARF/DWARFLocationExpressionTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
#include "gtest/gtest.h"
1212

1313
using namespace llvm;
14-
using object::SectionedAddress;
1514

1615
TEST(DWARFLocationExpression, Equality) {
1716
EXPECT_EQ((DWARFLocationExpression{std::nullopt, {}}),

llvm/unittests/FuzzMutate/OperationsTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,6 @@ using testing::Each;
4848
using testing::ElementsAre;
4949
using testing::Eq;
5050
using testing::Ge;
51-
using testing::NotNull;
5251
using testing::PrintToString;
5352
using testing::SizeIs;
5453
using testing::Truly;

llvm/unittests/Support/YAMLIOTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ using llvm::yaml::Hex32;
2323
using llvm::yaml::Hex64;
2424
using llvm::yaml::Hex8;
2525
using llvm::yaml::Input;
26-
using llvm::yaml::IO;
2726
using llvm::yaml::isNumeric;
2827
using llvm::yaml::MappingNormalization;
2928
using llvm::yaml::MappingTraits;

llvm/unittests/Transforms/Scalar/LoopPassManagerTest.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ namespace {
3333

3434
using testing::DoDefault;
3535
using testing::Return;
36-
using testing::Expectation;
3736
using testing::Invoke;
3837
using testing::InvokeWithoutArgs;
3938
using testing::_;

llvm/unittests/XRay/FDRBlockVerifierTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ namespace llvm {
1717
namespace xray {
1818
namespace {
1919

20-
using ::testing::ElementsAre;
21-
using ::testing::Not;
2220
using ::testing::SizeIs;
2321

2422
TEST(FDRBlockVerifierTest, ValidBlocksV3) {

llvm/unittests/tools/llvm-cfi-verify/GraphBuilder.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,10 +49,8 @@ using ::testing::IsEmpty;
4949
using ::testing::Matches;
5050
using ::testing::Pair;
5151
using ::testing::PrintToString;
52-
using ::testing::Property;
5352
using ::testing::SizeIs;
5453
using ::testing::UnorderedElementsAre;
55-
using ::testing::Value;
5654

5755
namespace llvm {
5856
namespace cfi_verify {

mlir/include/mlir/IR/Value.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,9 @@ class OpOperand : public IROperand<OpOperand, Value> {
268268
/// Return which operand this is in the OpOperand list of the Operation.
269269
unsigned getOperandNumber();
270270

271+
/// Set the current value being used by this operand.
272+
void assign(Value value) { set(value); }
273+
271274
private:
272275
/// Keep the constructor private and accessible to the OperandStorage class
273276
/// only to avoid hard-to-debug typo/programming mistakes.

mlir/include/mlir/IR/ValueRange.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,9 @@ class MutableOperandRange {
126126
ArrayRef<OperandSegment> operandSegments = std::nullopt);
127127
MutableOperandRange(Operation *owner);
128128

129+
/// Construct a new mutable range for the given OpOperand.
130+
MutableOperandRange(OpOperand &opOperand);
131+
129132
/// Slice this range into a sub range, with the additional operand segment.
130133
MutableOperandRange
131134
slice(unsigned subStart, unsigned subLen,

mlir/lib/Dialect/Bufferization/IR/BufferizationOps.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -537,18 +537,18 @@ LogicalResult DeallocTensorOp::bufferize(RewriterBase &rewriter,
537537

538538
bool MaterializeInDestinationOp::bufferizesToMemoryRead(
539539
OpOperand &opOperand, const AnalysisState &state) {
540-
return &opOperand == &getSourceMutable()[0];
540+
return &opOperand == &getSourceMutable();
541541
}
542542

543543
bool MaterializeInDestinationOp::bufferizesToMemoryWrite(
544544
OpOperand &opOperand, const AnalysisState &state) {
545-
return &opOperand == &getDestMutable()[0];
545+
return &opOperand == &getDestMutable();
546546
}
547547

548548
AliasingValueList
549549
MaterializeInDestinationOp::getAliasingValues(OpOperand &opOperand,
550550
const AnalysisState &state) {
551-
if (&opOperand == &getDestMutable()[0])
551+
if (&opOperand == &getDestMutable())
552552
return {{getOperation()->getResult(0), BufferRelation::Equivalent}};
553553
return {};
554554
}

mlir/lib/Dialect/Linalg/Transforms/ElementwiseOpFusion.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -949,7 +949,7 @@ struct FoldReshapeWithGenericOpByExpansion
949949
reshapeOp, "failed preconditions of fusion with producer generic op");
950950
}
951951

952-
if (!controlFoldingReshapes(&reshapeOp.getSrcMutable()[0])) {
952+
if (!controlFoldingReshapes(&reshapeOp.getSrcMutable())) {
953953
return rewriter.notifyMatchFailure(reshapeOp,
954954
"fusion blocked by control function");
955955
}

mlir/lib/Dialect/SCF/Transforms/TileUsingInterface.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -526,7 +526,7 @@ mlir::scf::tileAndFuseProducerOfSlice(RewriterBase &rewriter,
526526
// 1. Get the producer of the source (potentially walking through
527527
// `iter_args` of nested `scf.for`)
528528
auto [fusableProducer, destinationInitArg] =
529-
getUntiledProducerFromSliceSource(&candidateSliceOp.getSourceMutable()[0],
529+
getUntiledProducerFromSliceSource(&candidateSliceOp.getSourceMutable(),
530530
loops);
531531
if (!fusableProducer)
532532
return std::nullopt;

mlir/lib/Dialect/Tensor/Transforms/BufferizableOpInterfaceImpl.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,11 +636,11 @@ struct InsertSliceOpInterface
636636
RankedTensorType destType = insertSliceOp.getDestType();
637637

638638
// The source is always read.
639-
if (&opOperand == &insertSliceOp.getSourceMutable()[0])
639+
if (&opOperand == &insertSliceOp.getSourceMutable())
640640
return true;
641641

642642
// For the destination, it depends...
643-
assert(&opOperand == &insertSliceOp.getDestMutable()[0] && "expected dest");
643+
assert(&opOperand == &insertSliceOp.getDestMutable() && "expected dest");
644644

645645
// Dest is not read if it is entirely overwritten. E.g.:
646646
// tensor.insert_slice %a into %t[0][10][1] : ... into tensor<10xf32>
@@ -840,7 +840,7 @@ struct ReshapeOpInterface
840840
bool bufferizesToMemoryRead(Operation *op, OpOperand &opOperand,
841841
const AnalysisState &state) const {
842842
auto reshapeOp = cast<tensor::ReshapeOp>(op);
843-
return &opOperand == &reshapeOp.getShapeMutable()[0];
843+
return &opOperand == &reshapeOp.getShapeMutable();
844844
}
845845

846846
bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand,
@@ -917,7 +917,7 @@ struct ParallelInsertSliceOpInterface
917917
bool bufferizesToMemoryWrite(Operation *op, OpOperand &opOperand,
918918
const AnalysisState &state) const {
919919
auto parallelInsertSliceOp = cast<ParallelInsertSliceOp>(op);
920-
return &opOperand == &parallelInsertSliceOp.getDestMutable()[0];
920+
return &opOperand == &parallelInsertSliceOp.getDestMutable();
921921
}
922922

923923
LogicalResult bufferize(Operation *op, RewriterBase &rewriter,

mlir/lib/Dialect/Tensor/Transforms/SubsetInsertionOpInterfaceImpl.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ struct InsertSliceOpInterface
6363
: public SubsetInsertionOpInterface::ExternalModel<InsertSliceOpInterface,
6464
tensor::InsertSliceOp> {
6565
OpOperand &getSourceOperand(Operation *op) const {
66-
return op->getOpOperand(0);
66+
return cast<tensor::InsertSliceOp>(op).getSourceMutable();
6767
}
6868

6969
bool
@@ -91,11 +91,11 @@ struct ParallelInsertSliceOpInterface
9191
: public SubsetInsertionOpInterface::ExternalModel<
9292
ParallelInsertSliceOpInterface, tensor::ParallelInsertSliceOp> {
9393
OpOperand &getSourceOperand(Operation *op) const {
94-
return op->getOpOperand(0);
94+
return cast<tensor::ParallelInsertSliceOp>(op).getSourceMutable();
9595
}
9696

9797
OpOperand &getDestinationOperand(Operation *op) const {
98-
return op->getOpOperand(1);
98+
return cast<tensor::ParallelInsertSliceOp>(op).getDestMutable();
9999
}
100100

101101
bool

0 commit comments

Comments
 (0)