Skip to content

Commit a467d7d

Browse files
authored
Merge pull request #205 from AMD-Lightning-Internal/upstream_merge_202501200707
merge main into amd-staging
2 parents 1f186a2 + caaed1e commit a467d7d

File tree

179 files changed

+2732
-601
lines changed

Some content is hidden

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

179 files changed

+2732
-601
lines changed

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 400 additions & 46 deletions
Large diffs are not rendered by default.

clang/docs/ReleaseNotes.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,8 @@ Improvements to Clang's diagnostics
690690

691691
- Don't emit bogus dangling diagnostics when ``[[gsl::Owner]]`` and `[[clang::lifetimebound]]` are used together (#GH108272).
692692

693+
- Don't emit bogus dignostic about an undefined behavior on ``reinterpret_cast<T>`` for non-instantiated template functions without sufficient knowledge whether it can actually lead to undefined behavior for ``T`` (#GH109430).
694+
693695
- The ``-Wreturn-stack-address`` warning now also warns about addresses of
694696
local variables passed to function calls using the ``[[clang::musttail]]``
695697
attribute.
@@ -892,7 +894,7 @@ Bug Fixes to C++ Support
892894
module imports in those situations. (#GH60336)
893895
- Fix init-capture packs having a size of one before being instantiated. (#GH63677)
894896
- Clang now preserves the unexpanded flag in a lambda transform used for pack expansion. (#GH56852), (#GH85667),
895-
(#GH99877).
897+
(#GH99877), (#GH122417).
896898
- Fixed a bug when diagnosing ambiguous explicit specializations of constrained member functions.
897899
- Fixed an assertion failure when selecting a function from an overload set that includes a
898900
specialization of a conversion function template.

clang/include/clang/Sema/Overload.h

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,7 +898,8 @@ class Sema;
898898
ConversionFixItGenerator Fix;
899899

900900
/// Viable - True to indicate that this overload candidate is viable.
901-
bool Viable : 1;
901+
LLVM_PREFERRED_TYPE(bool)
902+
unsigned Viable : 1;
902903

903904
/// Whether this candidate is the best viable function, or tied for being
904905
/// the best viable function.
@@ -907,12 +908,14 @@ class Sema;
907908
/// was part of the ambiguity kernel: the minimal non-empty set of viable
908909
/// candidates such that all elements of the ambiguity kernel are better
909910
/// than all viable candidates not in the ambiguity kernel.
910-
bool Best : 1;
911+
LLVM_PREFERRED_TYPE(bool)
912+
unsigned Best : 1;
911913

912914
/// IsSurrogate - True to indicate that this candidate is a
913915
/// surrogate for a conversion to a function pointer or reference
914916
/// (C++ [over.call.object]).
915-
bool IsSurrogate : 1;
917+
LLVM_PREFERRED_TYPE(bool)
918+
unsigned IsSurrogate : 1;
916919

917920
/// IgnoreObjectArgument - True to indicate that the first
918921
/// argument's conversion, which for this function represents the
@@ -921,12 +924,15 @@ class Sema;
921924
/// implicit object argument is just a placeholder) or a
922925
/// non-static member function when the call doesn't have an
923926
/// object argument.
924-
bool IgnoreObjectArgument : 1;
927+
LLVM_PREFERRED_TYPE(bool)
928+
unsigned IgnoreObjectArgument : 1;
925929

926-
bool TookAddressOfOverload : 1;
930+
LLVM_PREFERRED_TYPE(bool)
931+
unsigned TookAddressOfOverload : 1;
927932

928933
/// True if the candidate was found using ADL.
929-
CallExpr::ADLCallKind IsADLCandidate : 1;
934+
LLVM_PREFERRED_TYPE(CallExpr::ADLCallKind)
935+
unsigned IsADLCandidate : 1;
930936

931937
/// Whether this is a rewritten candidate, and if so, of what kind?
932938
LLVM_PREFERRED_TYPE(OverloadCandidateRewriteKind)
@@ -999,7 +1005,8 @@ class Sema;
9991005
friend class OverloadCandidateSet;
10001006
OverloadCandidate()
10011007
: IsSurrogate(false), IgnoreObjectArgument(false),
1002-
TookAddressOfOverload(false), IsADLCandidate(CallExpr::NotADL),
1008+
TookAddressOfOverload(false),
1009+
IsADLCandidate(llvm::to_underlying(CallExpr::NotADL)),
10031010
RewriteKind(CRK_None) {}
10041011
};
10051012

clang/lib/AST/ByteCode/Compiler.cpp

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -253,6 +253,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
253253

254254
case CK_UncheckedDerivedToBase:
255255
case CK_DerivedToBase: {
256+
if (DiscardResult)
257+
return this->discard(SubExpr);
258+
256259
if (!this->delegate(SubExpr))
257260
return false;
258261

@@ -282,6 +285,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
282285
}
283286

284287
case CK_BaseToDerived: {
288+
if (DiscardResult)
289+
return this->discard(SubExpr);
290+
285291
if (!this->delegate(SubExpr))
286292
return false;
287293

@@ -689,20 +695,18 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
689695
if (!this->visit(SubExpr))
690696
return false;
691697

692-
auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
693-
uint32_t I;
694-
std::memcpy(&I, &Sem, sizeof(Sem));
695-
return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()), I,
696-
CE);
698+
auto Sem =
699+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
700+
return this->emitCastIntegralFixedPoint(classifyPrim(SubExpr->getType()),
701+
Sem, CE);
697702
}
698703
case CK_FloatingToFixedPoint: {
699704
if (!this->visit(SubExpr))
700705
return false;
701706

702-
auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
703-
uint32_t I;
704-
std::memcpy(&I, &Sem, sizeof(Sem));
705-
return this->emitCastFloatingFixedPoint(I, CE);
707+
auto Sem =
708+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
709+
return this->emitCastFloatingFixedPoint(Sem, CE);
706710
}
707711
case CK_FixedPointToFloating: {
708712
if (!this->visit(SubExpr))
@@ -718,10 +722,9 @@ bool Compiler<Emitter>::VisitCastExpr(const CastExpr *CE) {
718722
case CK_FixedPointCast: {
719723
if (!this->visit(SubExpr))
720724
return false;
721-
auto Sem = Ctx.getASTContext().getFixedPointSemantics(CE->getType());
722-
uint32_t I;
723-
std::memcpy(&I, &Sem, sizeof(Sem));
724-
return this->emitCastFixedPoint(I, CE);
725+
auto Sem =
726+
Ctx.getASTContext().getFixedPointSemantics(CE->getType()).toOpaqueInt();
727+
return this->emitCastFixedPoint(Sem, CE);
725728
}
726729

727730
case CK_ToVoid:
@@ -1522,42 +1525,40 @@ template <class Emitter>
15221525
bool Compiler<Emitter>::VisitFixedPointBinOp(const BinaryOperator *E) {
15231526
const Expr *LHS = E->getLHS();
15241527
const Expr *RHS = E->getRHS();
1528+
const ASTContext &ASTCtx = Ctx.getASTContext();
15251529

15261530
assert(LHS->getType()->isFixedPointType() ||
15271531
RHS->getType()->isFixedPointType());
15281532

1529-
auto LHSSema = Ctx.getASTContext().getFixedPointSemantics(LHS->getType());
1530-
auto RHSSema = Ctx.getASTContext().getFixedPointSemantics(RHS->getType());
1533+
auto LHSSema = ASTCtx.getFixedPointSemantics(LHS->getType());
1534+
auto LHSSemaInt = LHSSema.toOpaqueInt();
1535+
auto RHSSema = ASTCtx.getFixedPointSemantics(RHS->getType());
1536+
auto RHSSemaInt = RHSSema.toOpaqueInt();
15311537

15321538
if (!this->visit(LHS))
15331539
return false;
15341540
if (!LHS->getType()->isFixedPointType()) {
1535-
uint32_t I;
1536-
std::memcpy(&I, &LHSSema, sizeof(llvm::FixedPointSemantics));
1537-
if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()), I, E))
1541+
if (!this->emitCastIntegralFixedPoint(classifyPrim(LHS->getType()),
1542+
LHSSemaInt, E))
15381543
return false;
15391544
}
15401545

15411546
if (!this->visit(RHS))
15421547
return false;
15431548
if (!RHS->getType()->isFixedPointType()) {
1544-
uint32_t I;
1545-
std::memcpy(&I, &RHSSema, sizeof(llvm::FixedPointSemantics));
1546-
if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()), I, E))
1549+
if (!this->emitCastIntegralFixedPoint(classifyPrim(RHS->getType()),
1550+
RHSSemaInt, E))
15471551
return false;
15481552
}
15491553

15501554
// Convert the result to the target semantics.
15511555
auto ConvertResult = [&](bool R) -> bool {
15521556
if (!R)
15531557
return false;
1554-
auto ResultSema = Ctx.getASTContext().getFixedPointSemantics(E->getType());
1555-
auto CommonSema = LHSSema.getCommonSemantics(RHSSema);
1556-
if (ResultSema != CommonSema) {
1557-
uint32_t I;
1558-
std::memcpy(&I, &ResultSema, sizeof(ResultSema));
1559-
return this->emitCastFixedPoint(I, E);
1560-
}
1558+
auto ResultSema = ASTCtx.getFixedPointSemantics(E->getType()).toOpaqueInt();
1559+
auto CommonSema = LHSSema.getCommonSemantics(RHSSema).toOpaqueInt();
1560+
if (ResultSema != CommonSema)
1561+
return this->emitCastFixedPoint(ResultSema, E);
15611562
return true;
15621563
};
15631564

clang/lib/AST/ByteCode/Interp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ bool CheckLive(InterpState &S, CodePtr OpPC, const Pointer &Ptr,
321321

322322
if (Ptr.isDynamic()) {
323323
S.FFDiag(Src, diag::note_constexpr_access_deleted_object) << AK;
324-
} else {
324+
} else if (!S.checkingPotentialConstantExpression()) {
325325
bool IsTemp = Ptr.isTemporary();
326326
S.FFDiag(Src, diag::note_constexpr_lifetime_ended, 1) << AK << !IsTemp;
327327

clang/lib/AST/ByteCode/Interp.h

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2141,9 +2141,8 @@ inline bool CastFP(InterpState &S, CodePtr OpPC, const llvm::fltSemantics *Sem,
21412141
}
21422142

21432143
inline bool CastFixedPoint(InterpState &S, CodePtr OpPC, uint32_t FPS) {
2144-
FixedPointSemantics TargetSemantics(0, 0, false, false, false);
2145-
std::memcpy(&TargetSemantics, &FPS, sizeof(TargetSemantics));
2146-
2144+
FixedPointSemantics TargetSemantics =
2145+
FixedPointSemantics::getFromOpaqueInt(FPS);
21472146
const auto &Source = S.Stk.pop<FixedPoint>();
21482147

21492148
bool Overflow;
@@ -2271,8 +2270,7 @@ static inline bool CastIntegralFixedPoint(InterpState &S, CodePtr OpPC,
22712270
uint32_t FPS) {
22722271
const T &Int = S.Stk.pop<T>();
22732272

2274-
FixedPointSemantics Sem(0, 0, false, false, false);
2275-
std::memcpy(&Sem, &FPS, sizeof(Sem));
2273+
FixedPointSemantics Sem = FixedPointSemantics::getFromOpaqueInt(FPS);
22762274

22772275
bool Overflow;
22782276
FixedPoint Result = FixedPoint::from(Int.toAPSInt(), Sem, &Overflow);
@@ -2288,8 +2286,7 @@ static inline bool CastFloatingFixedPoint(InterpState &S, CodePtr OpPC,
22882286
uint32_t FPS) {
22892287
const auto &Float = S.Stk.pop<Floating>();
22902288

2291-
FixedPointSemantics Sem(0, 0, false, false, false);
2292-
std::memcpy(&Sem, &FPS, sizeof(Sem));
2289+
FixedPointSemantics Sem = FixedPointSemantics::getFromOpaqueInt(FPS);
22932290

22942291
bool Overflow;
22952292
FixedPoint Result = FixedPoint::from(Float.getAPFloat(), Sem, &Overflow);

clang/lib/Basic/Targets.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -743,9 +743,6 @@ std::unique_ptr<TargetInfo> AllocateTarget(const llvm::Triple &Triple,
743743
case llvm::Triple::Linux:
744744
return std::make_unique<LinuxTargetInfo<LoongArch32TargetInfo>>(Triple,
745745
Opts);
746-
case llvm::Triple::FreeBSD:
747-
return std::make_unique<FreeBSDTargetInfo<LoongArch32TargetInfo>>(Triple,
748-
Opts);
749746
default:
750747
return std::make_unique<LoongArch32TargetInfo>(Triple, Opts);
751748
}

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -250,11 +250,8 @@ class LLVM_LIBRARY_VISIBILITY FreeBSDTargetInfo : public OSTargetInfo<Target> {
250250
case llvm::Triple::arm:
251251
this->MCountName = "__mcount";
252252
break;
253-
case llvm::Triple::riscv32:
254-
case llvm::Triple::riscv64:
255-
break;
256-
case llvm::Triple::loongarch32:
257253
case llvm::Triple::loongarch64:
254+
case llvm::Triple::riscv64:
258255
break;
259256
}
260257
}

clang/lib/CodeGen/CodeGenModule.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,8 @@ createTargetCodeGenInfo(CodeGenModule &CGM) {
124124
case llvm::Triple::mipsel:
125125
if (Triple.getOS() == llvm::Triple::NaCl)
126126
return createPNaClTargetCodeGenInfo(CGM);
127+
else if (Triple.getOS() == llvm::Triple::Win32)
128+
return createWindowsMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
127129
return createMIPSTargetCodeGenInfo(CGM, /*IsOS32=*/true);
128130

129131
case llvm::Triple::mips64:

clang/lib/CodeGen/TargetInfo.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,9 @@ createM68kTargetCodeGenInfo(CodeGenModule &CGM);
522522
std::unique_ptr<TargetCodeGenInfo>
523523
createMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
524524

525+
std::unique_ptr<TargetCodeGenInfo>
526+
createWindowsMIPSTargetCodeGenInfo(CodeGenModule &CGM, bool IsOS32);
527+
525528
std::unique_ptr<TargetCodeGenInfo>
526529
createMSP430TargetCodeGenInfo(CodeGenModule &CGM);
527530

0 commit comments

Comments
 (0)