Skip to content

Commit 7c6c334

Browse files
authored
Merge pull request llvm#579 from AMD-Lightning-Internal/amd/merge/upstream_merge_20250209183016
merge main into amd-staging
2 parents ac65db8 + 0af2f78 commit 7c6c334

File tree

90 files changed

+3216
-2153
lines changed

Some content is hidden

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

90 files changed

+3216
-2153
lines changed

clang/lib/AST/VTableBuilder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,12 +1169,13 @@ void ItaniumVTableBuilder::ComputeThisAdjustments() {
11691169
//
11701170
// Do not set ThunkInfo::Method if Idx is already in VTableThunks. This
11711171
// can happen when covariant return adjustment is required too.
1172-
if (!VTableThunks.count(Idx)) {
1172+
auto [It, Inserted] = VTableThunks.try_emplace(Idx);
1173+
if (Inserted) {
11731174
const CXXMethodDecl *Method = VTables.findOriginalMethodInMap(MD);
1174-
VTableThunks[Idx].Method = Method;
1175-
VTableThunks[Idx].ThisType = Method->getThisType().getTypePtr();
1175+
It->second.Method = Method;
1176+
It->second.ThisType = Method->getThisType().getTypePtr();
11761177
}
1177-
VTableThunks[Idx].This = ThisAdjustment;
1178+
It->second.This = ThisAdjustment;
11781179
};
11791180

11801181
SetThisAdjustmentThunk(VTableIndex);
@@ -1653,8 +1654,9 @@ void ItaniumVTableBuilder::AddMethods(
16531654
// findOriginalMethod to find the method that created the entry if the
16541655
// method in the entry requires adjustment.
16551656
if (!ReturnAdjustment.isEmpty()) {
1656-
VTableThunks[Components.size()].Method = MD;
1657-
VTableThunks[Components.size()].ThisType = MD->getThisType().getTypePtr();
1657+
auto &VTT = VTableThunks[Components.size()];
1658+
VTT.Method = MD;
1659+
VTT.ThisType = MD->getThisType().getTypePtr();
16581660
}
16591661

16601662
AddMethod(Overrider.Method, ReturnAdjustment);

clang/lib/Driver/ToolChains/Clang.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1426,6 +1426,7 @@ static bool isSignedCharDefault(const llvm::Triple &Triple) {
14261426
return true;
14271427
return false;
14281428

1429+
case llvm::Triple::csky:
14291430
case llvm::Triple::hexagon:
14301431
case llvm::Triple::msp430:
14311432
case llvm::Triple::ppcle:

clang/lib/Sema/JumpDiagnostics.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -786,8 +786,7 @@ void JumpScopeChecker::VerifyIndirectJumps() {
786786
if (CHECK_PERMISSIVE(!LabelAndGotoScopes.count(TheLabel->getStmt())))
787787
continue;
788788
unsigned LabelScope = LabelAndGotoScopes[TheLabel->getStmt()];
789-
if (!TargetScopes.contains(LabelScope))
790-
TargetScopes[LabelScope] = TheLabel;
789+
TargetScopes.try_emplace(LabelScope, TheLabel);
791790
}
792791

793792
// For each target scope, make sure it's trivially reachable from

clang/lib/Serialization/ASTReader.cpp

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -645,10 +645,11 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts,
645645

646646
// For an #undef'd macro, we only care about the name.
647647
if (IsUndef) {
648-
if (MacroNames && !Macros.count(MacroName))
648+
auto [It, Inserted] = Macros.try_emplace(MacroName);
649+
if (MacroNames && Inserted)
649650
MacroNames->push_back(MacroName);
650651

651-
Macros[MacroName] = std::make_pair("", true);
652+
It->second = std::make_pair("", true);
652653
continue;
653654
}
654655

@@ -661,9 +662,10 @@ collectMacroDefinitions(const PreprocessorOptions &PPOpts,
661662
MacroBody = MacroBody.substr(0, End);
662663
}
663664

664-
if (MacroNames && !Macros.count(MacroName))
665+
auto [It, Inserted] = Macros.try_emplace(MacroName);
666+
if (MacroNames && Inserted)
665667
MacroNames->push_back(MacroName);
666-
Macros[MacroName] = std::make_pair(MacroBody, false);
668+
It->second = std::make_pair(MacroBody, false);
667669
}
668670
}
669671

clang/test/Driver/csky-toolchain.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
// RUN: %clang -### %s --target=csky 2>&1 | FileCheck -check-prefix=CC1 %s
55
// CC1: "-cc1" "-triple" "csky"
6+
// CC1: "-fno-signed-char"
67

78
// In the below tests, --rtlib=platform is used so that the driver ignores
89
// the configure-time CLANG_DEFAULT_RTLIB option when choosing the runtime lib

libcxx/docs/Status/FormatPaper.csv

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Section,Description,Dependencies,Assignee,Status,First released version
22
`P1361 <https://wg21.link/P1361>`__ `P2372 <https://wg21.link/P2372>`__,"Formatting chrono"
33
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::duration<Rep, Period>``",,Mark de Wever,|Complete|,16
44
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::sys_time<Duration>``",,Mark de Wever,|Complete|,17
5-
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::utc_time<Duration>``",A ``<chrono>`` implementation,Mark de Wever,|Complete|,20
5+
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::utc_time<Duration>``",,Mark de Wever,|Complete|,20
66
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::tai_time<Duration>``",,Mark de Wever,|Complete|,21
77
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::gps_time<Duration>``",A ``<chrono>`` implementation,Mark de Wever,,,
88
`[time.syn] <https://wg21.link/time.syn>`_,"Formatter ``chrono::file_time<Duration>``",,Mark de Wever,|Complete|,17

libcxx/include/chrono

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,18 +922,18 @@ strong_ordering operator<=>(const time_zone_link& x, const time_zone_link& y);
922922
} // chrono
923923
924924
namespace std {
925+
template<class Rep, class Period, class charT>
926+
struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
925927
template<class Duration, class charT>
926928
struct formatter<chrono::sys_time<Duration>, charT>; // C++20
927929
template<class Duration, class charT>
928930
struct formatter<chrono::utc_time<Duration>, charT>; // C++20
929931
template<class Duration, class charT>
930932
struct formatter<chrono::tai_time<Duration>, charT>; // C++20
931933
template<class Duration, class charT>
932-
struct formatter<chrono::filetime<Duration>, charT>; // C++20
934+
struct formatter<chrono::file_time<Duration>, charT>; // C++20
933935
template<class Duration, class charT>
934936
struct formatter<chrono::local_time<Duration>, charT>; // C++20
935-
template<class Rep, class Period, class charT>
936-
struct formatter<chrono::duration<Rep, Period>, charT>; // C++20
937937
template<class charT> struct formatter<chrono::day, charT>; // C++20
938938
template<class charT> struct formatter<chrono::month, charT>; // C++20
939939
template<class charT> struct formatter<chrono::year, charT>; // C++20

lldb/test/API/api/command-return-object/TestSBCommandReturnObject.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,12 @@ def test_sb_command_return_object(self):
2424
# return exit code 0 to indicate success. We can let this exception go
2525
# - the test harness will recognize it as a test failure.
2626
subprocess.check_call([self.driver_exe, self.driver_exe])
27+
28+
def test_get_command(self):
29+
res = lldb.SBCommandReturnObject()
30+
self.assertEqual(res.GetCommand(), "")
31+
32+
ci = self.dbg.GetCommandInterpreter()
33+
ci.HandleCommand("help help", res)
34+
self.assertTrue(res.Succeeded())
35+
self.assertEqual(res.GetCommand(), "help help")

lldb/test/API/python_api/commandreturnobject/TestSBCommandReturnObject.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

llvm/include/llvm/Passes/DroppedVariableStats.h

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,9 +96,10 @@ class DroppedVariableStats {
9696
DenseSet<VarID> &DebugVariablesBeforeSet =
9797
DbgVariables.DebugVariablesBefore;
9898
DenseSet<VarID> &DebugVariablesAfterSet = DbgVariables.DebugVariablesAfter;
99-
if (InlinedAts.back().find(FuncName) == InlinedAts.back().end())
99+
auto It = InlinedAts.back().find(FuncName);
100+
if (It == InlinedAts.back().end())
100101
return;
101-
DenseMap<VarID, DILocation *> &InlinedAtsMap = InlinedAts.back()[FuncName];
102+
DenseMap<VarID, DILocation *> &InlinedAtsMap = It->second;
102103
// Find an Instruction that shares the same scope as the dropped #dbg_value
103104
// or has a scope that is the child of the scope of the #dbg_value, and has
104105
// an inlinedAt equal to the inlinedAt of the #dbg_value or it's inlinedAt

llvm/lib/Analysis/DependenceGraphBuilder.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,9 +240,7 @@ template <class G> void AbstractDependenceGraphBuilder<G>::createDefUseEdges() {
240240
Instruction *UI = dyn_cast<Instruction>(U);
241241
if (!UI)
242242
continue;
243-
NodeType *DstNode = nullptr;
244-
if (IMap.find(UI) != IMap.end())
245-
DstNode = IMap.find(UI)->second;
243+
NodeType *DstNode = IMap.lookup(UI);
246244

247245
// In the case of loops, the scope of the subgraph is all the
248246
// basic blocks (and instructions within them) belonging to the loop. We

llvm/lib/CodeGen/AsmPrinter/DbgEntityHistoryCalculator.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -414,9 +414,10 @@ static void handleNewDebugValue(InlinedEntity Var, const MachineInstr &DV,
414414
dropRegDescribedVar(RegVars, I.first, Var);
415415

416416
// Drop all entries that have ended, and mark the new entry as live.
417+
auto &Entries = LiveEntries[Var];
417418
for (auto Index : IndicesToErase)
418-
LiveEntries[Var].erase(Index);
419-
LiveEntries[Var].insert(NewIndex);
419+
Entries.erase(Index);
420+
Entries.insert(NewIndex);
420421
}
421422
}
422423

llvm/lib/CodeGen/StackColoring.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1115,9 +1115,10 @@ void StackColoring::remapInstructions(DenseMap<int, int> &SlotRemap) {
11151115
if (WinEHFuncInfo *EHInfo = MF->getWinEHFuncInfo())
11161116
for (WinEHTryBlockMapEntry &TBME : EHInfo->TryBlockMap)
11171117
for (WinEHHandlerType &H : TBME.HandlerArray)
1118-
if (H.CatchObj.FrameIndex != std::numeric_limits<int>::max() &&
1119-
SlotRemap.count(H.CatchObj.FrameIndex))
1120-
H.CatchObj.FrameIndex = SlotRemap[H.CatchObj.FrameIndex];
1118+
if (H.CatchObj.FrameIndex != std::numeric_limits<int>::max())
1119+
if (auto It = SlotRemap.find(H.CatchObj.FrameIndex);
1120+
It != SlotRemap.end())
1121+
H.CatchObj.FrameIndex = It->second;
11211122

11221123
LLVM_DEBUG(dbgs() << "Fixed " << FixedMemOp << " machine memory operands.\n");
11231124
LLVM_DEBUG(dbgs() << "Fixed " << FixedDbg << " debug locations.\n");

llvm/lib/Target/AMDGPU/AMDGPUPromoteAlloca.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,10 +835,9 @@ bool AMDGPUPromoteAllocaImpl::tryPromoteAllocaToVector(AllocaInst &Alloca) {
835835
return RejectUser(Inst, "mem transfer inst length is non-constant or "
836836
"not a multiple of the vector element size");
837837

838-
if (!TransferInfo.count(TransferInst)) {
838+
if (TransferInfo.try_emplace(TransferInst).second) {
839839
DeferredInsts.push_back(Inst);
840840
WorkList.push_back(Inst);
841-
TransferInfo[TransferInst] = MemTransferInfo();
842841
}
843842

844843
auto getPointerIndexOfAlloca = [&](Value *Ptr) -> ConstantInt * {

llvm/lib/Target/X86/X86ISelLowering.cpp

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12689,6 +12689,20 @@ static bool isShuffleMaskInputInPlace(int Input, ArrayRef<int> Mask) {
1268912689
return true;
1269012690
}
1269112691

12692+
/// Test whether the specified input (0 or 1) is a broadcast/splat blended by
12693+
/// the given mask.
12694+
///
12695+
static bool isShuffleMaskInputBroadcastable(int Input, ArrayRef<int> Mask,
12696+
int BroadcastableElement = 0) {
12697+
assert((Input == 0 || Input == 1) && "Only two inputs to shuffles.");
12698+
int Size = Mask.size();
12699+
for (int i = 0; i < Size; ++i)
12700+
if (Mask[i] >= 0 && Mask[i] / Size == Input &&
12701+
Mask[i] % Size != BroadcastableElement)
12702+
return false;
12703+
return true;
12704+
}
12705+
1269212706
/// If we are extracting two 128-bit halves of a vector and shuffling the
1269312707
/// result, match that to a 256-bit AVX2 vperm* instruction to avoid a
1269412708
/// multi-shuffle lowering.
@@ -16190,6 +16204,8 @@ static SDValue lowerV4F64Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
1619016204

1619116205
bool V1IsInPlace = isShuffleMaskInputInPlace(0, Mask);
1619216206
bool V2IsInPlace = isShuffleMaskInputInPlace(1, Mask);
16207+
bool V1IsSplat = isShuffleMaskInputBroadcastable(0, Mask);
16208+
bool V2IsSplat = isShuffleMaskInputBroadcastable(1, Mask);
1619316209

1619416210
// If we have lane crossing shuffles AND they don't all come from the lower
1619516211
// lane elements, lower to SHUFPD(VPERM2F128(V1, V2), VPERM2F128(V1, V2)).
@@ -16198,7 +16214,9 @@ static SDValue lowerV4F64Shuffle(const SDLoc &DL, ArrayRef<int> Mask,
1619816214
if (is128BitLaneCrossingShuffleMask(MVT::v4f64, Mask) &&
1619916215
!all_of(Mask, [](int M) { return M < 2 || (4 <= M && M < 6); }) &&
1620016216
(V1.getOpcode() != ISD::BUILD_VECTOR) &&
16201-
(V2.getOpcode() != ISD::BUILD_VECTOR))
16217+
(V2.getOpcode() != ISD::BUILD_VECTOR) &&
16218+
(!Subtarget.hasAVX2() ||
16219+
!((V1IsInPlace || V1IsSplat) && (V2IsInPlace || V2IsSplat))))
1620216220
return lowerShuffleAsLanePermuteAndSHUFP(DL, MVT::v4f64, V1, V2, Mask, DAG);
1620316221

1620416222
// If we have one input in place, then we can permute the other input and

llvm/lib/Transforms/Coroutines/CoroFrame.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -752,13 +752,14 @@ static void buildFrameDebugInfo(Function &F, coro::Shape &Shape,
752752
dwarf::DW_ATE_unsigned_char)});
753753

754754
for (auto *V : FrameData.getAllDefs()) {
755-
if (!DIVarCache.contains(V))
755+
auto It = DIVarCache.find(V);
756+
if (It == DIVarCache.end())
756757
continue;
757758

758759
auto Index = FrameData.getFieldIndex(V);
759760

760-
NameCache.insert({Index, DIVarCache[V]->getName()});
761-
TyCache.insert({Index, DIVarCache[V]->getType()});
761+
NameCache.insert({Index, It->second->getName()});
762+
TyCache.insert({Index, It->second->getType()});
762763
}
763764

764765
// Cache from index to (Align, Offset Pair)

llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3439,10 +3439,10 @@ bool LoopVectorizationCostModel::interleavedAccessCanBeWidened(
34393439
if (hasIrregularType(ScalarTy, DL))
34403440
return false;
34413441

3442-
// We currently only know how to emit interleave/deinterleave with
3443-
// Factor=2 for scalable vectors. This is purely an implementation
3444-
// limit.
3445-
if (VF.isScalable() && InterleaveFactor != 2)
3442+
// For scalable vectors, the only interleave factor currently supported
3443+
// must be power of 2 since we require the (de)interleave2 intrinsics
3444+
// instead of shufflevectors.
3445+
if (VF.isScalable() && !isPowerOf2_32(InterleaveFactor))
34463446
return false;
34473447

34483448
// If the group involves a non-integral pointer, we may not be able to
@@ -9311,9 +9311,9 @@ LoopVectorizationPlanner::tryToBuildVPlanWithVPRecipes(VFRange &Range) {
93119311
CM.getWideningDecision(IG->getInsertPos(), VF) ==
93129312
LoopVectorizationCostModel::CM_Interleave);
93139313
// For scalable vectors, the only interleave factor currently supported
9314-
// is 2 since we require the (de)interleave2 intrinsics instead of
9315-
// shufflevectors.
9316-
assert((!Result || !VF.isScalable() || IG->getFactor() == 2) &&
9314+
// must be power of 2 since we require the (de)interleave2 intrinsics
9315+
// instead of shufflevectors.
9316+
assert((!Result || !VF.isScalable() || isPowerOf2_32(IG->getFactor())) &&
93179317
"Unsupported interleave factor for scalable vectors");
93189318
return Result;
93199319
};

0 commit comments

Comments
 (0)