Skip to content

Commit d7302b5

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3715)
2 parents fff2aa6 + 95843b4 commit d7302b5

File tree

38 files changed

+1118
-321
lines changed

38 files changed

+1118
-321
lines changed

clang/lib/CodeGen/Targets/RISCV.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -955,7 +955,6 @@ void RISCVABIInfo::createCoercedStore(llvm::Value *Val, Address Dst,
955955
cast<llvm::FixedVectorType>(EltTy), Val, uint64_t(0));
956956
auto *I = CGF.Builder.CreateStore(Coerced, Dst, DestIsVolatile);
957957
CGF.addInstToCurrentSourceAtom(I, Val);
958-
return;
959958
}
960959

961960
namespace {

clang/lib/Driver/Driver.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4691,7 +4691,6 @@ void Driver::BuildDriverManagedModuleBuildActions(
46914691
Compilation &C, llvm::opt::DerivedArgList &Args, const InputList &Inputs,
46924692
ActionList &Actions) const {
46934693
Diags.Report(diag::remark_performing_driver_managed_module_build);
4694-
return;
46954694
}
46964695

46974696
/// Returns the canonical name for the offloading architecture when using a HIP

clang/lib/Driver/ToolChains/HLSL.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,6 @@ void getSpirvExtOperand(StringRef SpvExtensionArg, raw_ostream &out) {
215215
return;
216216
}
217217
out << SpvExtensionArg;
218-
return;
219218
}
220219

221220
SmallString<1024> getSpirvExtArg(ArrayRef<std::string> SpvExtensionArgs) {

clang/unittests/Analysis/FlowSensitive/FormulaTest.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ using namespace dataflow;
2222
using ::llvm::Failed;
2323
using ::llvm::HasValue;
2424
using ::llvm::Succeeded;
25-
using ::testing::ElementsAre;
26-
using ::testing::IsEmpty;
2725

2826
class SerializeFormulaTest : public ::testing::Test {
2927
protected:

llvm/include/llvm/IR/ConstantRange.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -381,6 +381,7 @@ class [[nodiscard]] ConstantRange {
381381
/// strictly smaller than the current type. The returned range will
382382
/// correspond to the possible range of values if the source range had been
383383
/// truncated to the specified type with wrap type \p NoWrapKind.
384+
/// Note that the result of trunc nuw is exact.
384385
LLVM_ABI ConstantRange truncate(uint32_t BitWidth,
385386
unsigned NoWrapKind = 0) const;
386387

llvm/include/llvm/MC/MCAsmBackend.h

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -166,12 +166,8 @@ class LLVM_ABI MCAsmBackend {
166166
// Return false to use default handling. Otherwise, set `Size` to the number
167167
// of padding bytes.
168168
virtual bool relaxAlign(MCFragment &F, unsigned &Size) { return false; }
169-
virtual bool relaxDwarfLineAddr(MCFragment &, bool &WasRelaxed) const {
170-
return false;
171-
}
172-
virtual bool relaxDwarfCFA(MCFragment &, bool &WasRelaxed) const {
173-
return false;
174-
}
169+
virtual bool relaxDwarfLineAddr(MCFragment &) const { return false; }
170+
virtual bool relaxDwarfCFA(MCFragment &) const { return false; }
175171

176172
// Defined by linker relaxation targets to possibly emit LEB128 relocations
177173
// and set Value at the relocated location.

llvm/include/llvm/MC/MCAssembler.h

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -112,15 +112,11 @@ class MCAssembler {
112112

113113
/// Perform relaxation on a single fragment.
114114
bool relaxFragment(MCFragment &F);
115-
bool relaxInstruction(MCFragment &F);
116-
bool relaxLEB(MCFragment &F);
117-
bool relaxBoundaryAlign(MCBoundaryAlignFragment &BF);
118-
bool relaxDwarfLineAddr(MCFragment &F);
119-
bool relaxDwarfCallFrameFragment(MCFragment &F);
120-
bool relaxCVInlineLineTable(MCCVInlineLineTableFragment &DF);
121-
bool relaxCVDefRange(MCCVDefRangeFragment &DF);
122-
bool relaxFill(MCFillFragment &F);
123-
bool relaxOrg(MCOrgFragment &F);
115+
void relaxInstruction(MCFragment &F);
116+
void relaxLEB(MCFragment &F);
117+
void relaxBoundaryAlign(MCBoundaryAlignFragment &BF);
118+
void relaxDwarfLineAddr(MCFragment &F);
119+
void relaxDwarfCallFrameFragment(MCFragment &F);
124120

125121
public:
126122
/// Construct a new assembler instance.

llvm/include/llvm/MC/MCSection.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,6 @@ class MCFillFragment : public MCFragment {
307307
uint64_t Value;
308308
/// The number of bytes to insert.
309309
const MCExpr &NumValues;
310-
uint64_t Size = 0;
311310

312311
/// Source location of the directive that this fragment was created for.
313312
SMLoc Loc;
@@ -321,8 +320,6 @@ class MCFillFragment : public MCFragment {
321320
uint64_t getValue() const { return Value; }
322321
uint8_t getValueSize() const { return ValueSize; }
323322
const MCExpr &getNumValues() const { return NumValues; }
324-
uint64_t getSize() const { return Size; }
325-
void setSize(uint64_t Value) { Size = Value; }
326323

327324
SMLoc getLoc() const { return Loc; }
328325

@@ -371,16 +368,12 @@ class MCOrgFragment : public MCFragment {
371368
/// Source location of the directive that this fragment was created for.
372369
SMLoc Loc;
373370

374-
uint64_t Size = 0;
375-
376371
public:
377372
MCOrgFragment(const MCExpr &Offset, int8_t Value, SMLoc Loc)
378373
: MCFragment(FT_Org), Value(Value), Offset(&Offset), Loc(Loc) {}
379374

380375
const MCExpr &getOffset() const { return *Offset; }
381376
uint8_t getValue() const { return Value; }
382-
uint64_t getSize() const { return Size; }
383-
void setSize(uint64_t Value) { Size = Value; }
384377

385378
SMLoc getLoc() const { return Loc; }
386379

llvm/include/llvm/Transforms/Utils/LoopUtils.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ LLVM_ABI bool canSinkOrHoistInst(Instruction &I, AAResults *AA,
371371
/// Returns the llvm.vector.reduce intrinsic that corresponds to the recurrence
372372
/// kind.
373373
LLVM_ABI constexpr Intrinsic::ID getReductionIntrinsicID(RecurKind RK);
374+
/// Returns the llvm.vector.reduce min/max intrinsic that corresponds to the
375+
/// intrinsic op.
376+
LLVM_ABI Intrinsic::ID getMinMaxReductionIntrinsicID(Intrinsic::ID IID);
374377

375378
/// Returns the arithmetic instruction opcode used when expanding a reduction.
376379
LLVM_ABI unsigned getArithmeticReductionInstruction(Intrinsic::ID RdxID);

llvm/lib/MC/MCAssembler.cpp

Lines changed: 37 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ uint64_t MCAssembler::computeFragmentSize(const MCFragment &F) const {
203203
case MCFragment::FT_CVDefRange:
204204
return F.getSize();
205205
case MCFragment::FT_Fill: {
206-
auto &FF = cast<MCFillFragment>(F);
206+
auto &FF = static_cast<const MCFillFragment &>(F);
207207
int64_t NumValues = 0;
208208
if (!FF.getNumValues().evaluateKnownAbsolute(NumValues, *this)) {
209209
recordError(FF.getLoc(), "expected assembly-time absolute expression");
@@ -748,22 +748,22 @@ bool MCAssembler::fixupNeedsRelaxation(const MCFragment &F,
748748
Resolved);
749749
}
750750

751-
bool MCAssembler::relaxInstruction(MCFragment &F) {
751+
void MCAssembler::relaxInstruction(MCFragment &F) {
752752
assert(getEmitterPtr() &&
753753
"Expected CodeEmitter defined for relaxInstruction");
754754
// If this inst doesn't ever need relaxation, ignore it. This occurs when we
755755
// are intentionally pushing out inst fragments, or because we relaxed a
756756
// previous instruction to one that doesn't need relaxation.
757757
if (!getBackend().mayNeedRelaxation(F.getOpcode(), F.getOperands(),
758758
*F.getSubtargetInfo()))
759-
return false;
759+
return;
760760

761761
bool DoRelax = false;
762762
for (const MCFixup &Fixup : F.getVarFixups())
763763
if ((DoRelax = fixupNeedsRelaxation(F, Fixup)))
764764
break;
765765
if (!DoRelax)
766-
return false;
766+
return;
767767

768768
++stats::RelaxedInstructions;
769769

@@ -779,12 +779,10 @@ bool MCAssembler::relaxInstruction(MCFragment &F) {
779779
getEmitter().encodeInstruction(Relaxed, Data, Fixups, *F.getSubtargetInfo());
780780
F.setVarContents(Data);
781781
F.setVarFixups(Fixups);
782-
return true;
783782
}
784783

785-
bool MCAssembler::relaxLEB(MCFragment &F) {
786-
const unsigned OldSize = F.getVarSize();
787-
unsigned PadTo = OldSize;
784+
void MCAssembler::relaxLEB(MCFragment &F) {
785+
unsigned PadTo = F.getVarSize();
788786
int64_t Value;
789787
F.clearVarFixups();
790788
// Use evaluateKnownAbsolute for Mach-O as a hack: .subsections_via_symbols
@@ -818,7 +816,6 @@ bool MCAssembler::relaxLEB(MCFragment &F) {
818816
else
819817
Size = encodeULEB128(Value, Data, PadTo);
820818
F.setVarContents({reinterpret_cast<char *>(Data), Size});
821-
return OldSize != Size;
822819
}
823820

824821
/// Check if the branch crosses the boundary.
@@ -858,11 +855,11 @@ static bool needPadding(uint64_t StartAddr, uint64_t Size,
858855
isAgainstBoundary(StartAddr, Size, BoundaryAlignment);
859856
}
860857

861-
bool MCAssembler::relaxBoundaryAlign(MCBoundaryAlignFragment &BF) {
858+
void MCAssembler::relaxBoundaryAlign(MCBoundaryAlignFragment &BF) {
862859
// BoundaryAlignFragment that doesn't need to align any fragment should not be
863860
// relaxed.
864861
if (!BF.getLastFragment())
865-
return false;
862+
return;
866863

867864
uint64_t AlignedOffset = getFragmentOffset(BF);
868865
uint64_t AlignedSize = 0;
@@ -877,18 +874,15 @@ bool MCAssembler::relaxBoundaryAlign(MCBoundaryAlignFragment &BF) {
877874
? offsetToAlignment(AlignedOffset, BoundaryAlignment)
878875
: 0U;
879876
if (NewSize == BF.getSize())
880-
return false;
877+
return;
881878
BF.setSize(NewSize);
882-
return true;
883879
}
884880

885-
bool MCAssembler::relaxDwarfLineAddr(MCFragment &F) {
886-
bool WasRelaxed;
887-
if (getBackend().relaxDwarfLineAddr(F, WasRelaxed))
888-
return WasRelaxed;
881+
void MCAssembler::relaxDwarfLineAddr(MCFragment &F) {
882+
if (getBackend().relaxDwarfLineAddr(F))
883+
return;
889884

890885
MCContext &Context = getContext();
891-
auto OldSize = F.getVarSize();
892886
int64_t AddrDelta;
893887
bool Abs = F.getDwarfAddrDelta().evaluateKnownAbsolute(AddrDelta, *this);
894888
assert(Abs && "We created a line delta with an invalid expression");
@@ -898,13 +892,11 @@ bool MCAssembler::relaxDwarfLineAddr(MCFragment &F) {
898892
F.getDwarfLineDelta(), AddrDelta, Data);
899893
F.setVarContents(Data);
900894
F.clearVarFixups();
901-
return OldSize != Data.size();
902895
}
903896

904-
bool MCAssembler::relaxDwarfCallFrameFragment(MCFragment &F) {
905-
bool WasRelaxed;
906-
if (getBackend().relaxDwarfCFA(F, WasRelaxed))
907-
return WasRelaxed;
897+
void MCAssembler::relaxDwarfCallFrameFragment(MCFragment &F) {
898+
if (getBackend().relaxDwarfCFA(F))
899+
return;
908900

909901
MCContext &Context = getContext();
910902
int64_t Value;
@@ -913,69 +905,49 @@ bool MCAssembler::relaxDwarfCallFrameFragment(MCFragment &F) {
913905
reportError(F.getDwarfAddrDelta().getLoc(),
914906
"invalid CFI advance_loc expression");
915907
F.setDwarfAddrDelta(MCConstantExpr::create(0, Context));
916-
return false;
908+
return;
917909
}
918910

919-
auto OldSize = F.getVarContents().size();
920911
SmallVector<char, 8> Data;
921912
MCDwarfFrameEmitter::encodeAdvanceLoc(Context, Value, Data);
922913
F.setVarContents(Data);
923914
F.clearVarFixups();
924-
return OldSize != Data.size();
925-
}
926-
927-
bool MCAssembler::relaxCVInlineLineTable(MCCVInlineLineTableFragment &F) {
928-
unsigned OldSize = F.getVarContents().size();
929-
getContext().getCVContext().encodeInlineLineTable(*this, F);
930-
return OldSize != F.getVarContents().size();
931-
}
932-
933-
bool MCAssembler::relaxCVDefRange(MCCVDefRangeFragment &F) {
934-
unsigned OldSize = F.getVarContents().size();
935-
getContext().getCVContext().encodeDefRange(*this, F);
936-
return OldSize != F.getVarContents().size();
937-
}
938-
939-
bool MCAssembler::relaxFill(MCFillFragment &F) {
940-
uint64_t Size = computeFragmentSize(F);
941-
if (F.getSize() == Size)
942-
return false;
943-
F.setSize(Size);
944-
return true;
945-
}
946-
947-
bool MCAssembler::relaxOrg(MCOrgFragment &F) {
948-
uint64_t Size = computeFragmentSize(F);
949-
if (F.getSize() == Size)
950-
return false;
951-
F.setSize(Size);
952-
return true;
953915
}
954916

955917
bool MCAssembler::relaxFragment(MCFragment &F) {
956-
switch(F.getKind()) {
918+
auto Size = computeFragmentSize(F);
919+
switch (F.getKind()) {
957920
default:
958921
return false;
959922
case MCFragment::FT_Relaxable:
960923
assert(!getRelaxAll() && "Did not expect a FT_Relaxable in RelaxAll mode");
961-
return relaxInstruction(F);
924+
relaxInstruction(F);
925+
break;
962926
case MCFragment::FT_LEB:
963-
return relaxLEB(F);
927+
relaxLEB(F);
928+
break;
964929
case MCFragment::FT_Dwarf:
965-
return relaxDwarfLineAddr(F);
930+
relaxDwarfLineAddr(F);
931+
break;
966932
case MCFragment::FT_DwarfFrame:
967-
return relaxDwarfCallFrameFragment(F);
933+
relaxDwarfCallFrameFragment(F);
934+
break;
968935
case MCFragment::FT_BoundaryAlign:
969-
return relaxBoundaryAlign(cast<MCBoundaryAlignFragment>(F));
936+
relaxBoundaryAlign(static_cast<MCBoundaryAlignFragment &>(F));
937+
break;
970938
case MCFragment::FT_CVInlineLines:
971-
return relaxCVInlineLineTable(cast<MCCVInlineLineTableFragment>(F));
939+
getContext().getCVContext().encodeInlineLineTable(
940+
*this, static_cast<MCCVInlineLineTableFragment &>(F));
941+
break;
972942
case MCFragment::FT_CVDefRange:
973-
return relaxCVDefRange(cast<MCCVDefRangeFragment>(F));
943+
getContext().getCVContext().encodeDefRange(
944+
*this, static_cast<MCCVDefRangeFragment &>(F));
945+
break;
974946
case MCFragment::FT_Fill:
975-
return relaxFill(cast<MCFillFragment>(F));
976947
case MCFragment::FT_Org:
977-
return relaxOrg(static_cast<MCOrgFragment &>(F));
948+
return F.getNext()->Offset - F.Offset != Size;
978949
}
950+
return computeFragmentSize(F) != Size;
979951
}
980952

981953
void MCAssembler::layoutSection(MCSection &Sec) {
@@ -1024,7 +996,7 @@ unsigned MCAssembler::relaxOnce(unsigned FirstStable) {
1024996
for (;;) {
1025997
bool Changed = false;
1026998
for (MCFragment &F : Sec)
1027-
if (relaxFragment(F))
999+
if (F.getKind() != MCFragment::FT_Data && relaxFragment(F))
10281000
Changed = true;
10291001

10301002
if (!Changed)

0 commit comments

Comments
 (0)