Skip to content

Commit bff9677

Browse files
author
z1_cciauto
authored
merge main into amd-staging (llvm#3529)
2 parents 69246a0 + f888f22 commit bff9677

File tree

140 files changed

+7233
-3424
lines changed

Some content is hidden

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

140 files changed

+7233
-3424
lines changed

clang/docs/ReleaseNotes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -538,6 +538,7 @@ Crash and bug fixes
538538
^^^^^^^^^^^^^^^^^^^
539539
- Fixed a crash in the static analyzer that when the expression in an
540540
``[[assume(expr)]]`` attribute was enclosed in parentheses. (#GH151529)
541+
- Fixed a crash when parsing ``#embed`` parameters with unmatched closing brackets. (#GH152829)
541542

542543
Improvements
543544
^^^^^^^^^^^^

clang/include/clang/Driver/CommonArgs.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,8 @@ const char *RelocationModelName(llvm::Reloc::Model Model);
9898
std::tuple<llvm::Reloc::Model, unsigned, bool>
9999
ParsePICArgs(const ToolChain &ToolChain, const llvm::opt::ArgList &Args);
100100

101+
bool getStaticPIE(const llvm::opt::ArgList &Args, const ToolChain &TC);
102+
101103
unsigned ParseFunctionAlignment(const ToolChain &TC,
102104
const llvm::opt::ArgList &Args);
103105

clang/lib/Basic/Targets/AVR.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ class LLVM_LIBRARY_VISIBILITY AVRTargetInfo : public TargetInfo {
5757
Int16Type = SignedInt;
5858
Char32Type = UnsignedLong;
5959
SigAtomicType = SignedChar;
60-
resetDataLayout(
61-
"e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8-n16:8-a:8");
60+
resetDataLayout("e-P1-p:16:8-i8:8-i16:8-i32:8-i64:8-f32:8-f64:8-n8:16-a:8");
6261
}
6362

6463
void getTargetDefines(const LangOptions &Opts,

clang/lib/CIR/CodeGen/CIRGenCall.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,17 +42,17 @@ CIRGenFunctionInfo::create(CanQualType resultType,
4242
return fi;
4343
}
4444

45-
cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &fi) {
46-
mlir::Type resultType = convertType(fi.getReturnType());
45+
cir::FuncType CIRGenTypes::getFunctionType(const CIRGenFunctionInfo &info) {
46+
mlir::Type resultType = convertType(info.getReturnType());
4747
SmallVector<mlir::Type, 8> argTypes;
48-
argTypes.reserve(fi.getNumRequiredArgs());
48+
argTypes.reserve(info.getNumRequiredArgs());
4949

50-
for (const CanQualType &argType : fi.requiredArguments())
50+
for (const CanQualType &argType : info.requiredArguments())
5151
argTypes.push_back(convertType(argType));
5252

5353
return cir::FuncType::get(argTypes,
5454
(resultType ? resultType : builder.getVoidTy()),
55-
fi.isVariadic());
55+
info.isVariadic());
5656
}
5757

5858
CIRGenCallee CIRGenCallee::prepareConcreteCallee(CIRGenFunction &cgf) const {

clang/lib/CIR/CodeGen/CIRGenExpr.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1169,7 +1169,8 @@ static void pushTemporaryCleanup(CIRGenFunction &cgf,
11691169
->getBaseElementTypeUnsafe()
11701170
->getAs<clang::RecordType>()) {
11711171
// Get the destructor for the reference temporary.
1172-
auto *classDecl = cast<CXXRecordDecl>(rt->getOriginalDecl());
1172+
auto *classDecl =
1173+
cast<CXXRecordDecl>(rt->getOriginalDecl()->getDefinitionOrSelf());
11731174
if (!classDecl->hasTrivialDestructor())
11741175
referenceTemporaryDtor =
11751176
classDecl->getDefinitionOrSelf()->getDestructor();

clang/lib/CIR/CodeGen/CIRGenFunction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ static bool mayDropFunctionReturn(const ASTContext &astContext,
356356
// destructor or a non-trivially copyable type.
357357
if (const RecordType *recordType =
358358
returnType.getCanonicalType()->getAs<RecordType>()) {
359-
if (const auto *classDecl =
360-
dyn_cast<CXXRecordDecl>(recordType->getOriginalDecl()))
359+
if (const auto *classDecl = dyn_cast<CXXRecordDecl>(
360+
recordType->getOriginalDecl()->getDefinitionOrSelf()))
361361
return classDecl->hasTrivialDestructor();
362362
}
363363
return returnType.isTriviallyCopyableType(astContext);

clang/lib/CIR/CodeGen/CIRGenTypes.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ isSafeToConvert(const RecordDecl *rd, CIRGenTypes &cgt,
139139
if (!alreadyChecked.insert(rd).second)
140140
return true;
141141

142+
assert(rd->isCompleteDefinition() &&
143+
"Expect RecordDecl to be CompleteDefinition");
142144
const Type *key = cgt.getASTContext().getCanonicalTagType(rd).getTypePtr();
143145

144146
// If this type is already laid out, converting it is a noop.

clang/lib/CIR/CodeGen/TargetInfo.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,13 @@ bool clang::CIRGen::isEmptyRecordForLayout(const ASTContext &context,
1717
if (cxxrd->isDynamicClass())
1818
return false;
1919

20-
for (const auto &I : cxxrd->bases())
21-
if (!isEmptyRecordForLayout(context, I.getType()))
20+
for (const auto &i : cxxrd->bases())
21+
if (!isEmptyRecordForLayout(context, i.getType()))
2222
return false;
2323
}
2424

25-
for (const auto *I : rd->fields())
26-
if (!isEmptyFieldForLayout(context, I))
25+
for (const auto *i : rd->fields())
26+
if (!isEmptyFieldForLayout(context, i))
2727
return false;
2828

2929
return true;

clang/lib/Driver/ToolChains/Arch/AArch64.cpp

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,22 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
5252
return "apple-m1";
5353
}
5454

55+
if (Triple.getOS() == llvm::Triple::IOS) {
56+
assert(!Triple.isSimulatorEnvironment() && "iossim should be mac-like");
57+
// iOS 26 only runs on apple-a12 and later CPUs.
58+
if (!Triple.isOSVersionLT(26))
59+
return "apple-a12";
60+
}
61+
62+
if (Triple.isWatchOS()) {
63+
assert(!Triple.isSimulatorEnvironment() && "watchossim should be mac-like");
64+
// arm64_32/arm64e watchOS requires S4 before watchOS 26, S6 after.
65+
if (Triple.getArch() == llvm::Triple::aarch64_32 || Triple.isArm64e())
66+
return Triple.isOSVersionLT(26) ? "apple-s4" : "apple-s6";
67+
// arm64 (non-e, non-32) watchOS comes later, and requires S6 anyway.
68+
return "apple-s6";
69+
}
70+
5571
if (Triple.isXROS()) {
5672
// The xrOS simulator runs on M1 as well, it should have been covered above.
5773
assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");

clang/lib/Driver/ToolChains/BareMetal.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -586,11 +586,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
586586
const Driver &D = getToolChain().getDriver();
587587
const llvm::Triple::ArchType Arch = TC.getArch();
588588
const llvm::Triple &Triple = getToolChain().getEffectiveTriple();
589+
const bool IsStaticPIE = getStaticPIE(Args, TC);
589590

590591
if (!D.SysRoot.empty())
591592
CmdArgs.push_back(Args.MakeArgString("--sysroot=" + D.SysRoot));
592593

593594
CmdArgs.push_back("-Bstatic");
595+
if (IsStaticPIE) {
596+
CmdArgs.push_back("-pie");
597+
CmdArgs.push_back("--no-dynamic-linker");
598+
CmdArgs.push_back("-z");
599+
CmdArgs.push_back("text");
600+
}
594601

595602
if (const char *LDMOption = getLDMOption(TC.getTriple(), Args)) {
596603
CmdArgs.push_back("-m");
@@ -620,14 +627,18 @@ void baremetal::Linker::ConstructJob(Compilation &C, const JobAction &JA,
620627

621628
const char *CRTBegin, *CRTEnd;
622629
if (NeedCRTs) {
623-
if (!Args.hasArg(options::OPT_r))
624-
CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath("crt0.o")));
630+
if (!Args.hasArg(options::OPT_r)) {
631+
const char *crt = "crt0.o";
632+
if (IsStaticPIE)
633+
crt = "rcrt1.o";
634+
CmdArgs.push_back(Args.MakeArgString(TC.GetFilePath(crt)));
635+
}
625636
if (TC.hasValidGCCInstallation() || detectGCCToolchainAdjacent(D)) {
626637
auto RuntimeLib = TC.GetRuntimeLibType(Args);
627638
switch (RuntimeLib) {
628639
case (ToolChain::RLT_Libgcc): {
629-
CRTBegin = "crtbegin.o";
630-
CRTEnd = "crtend.o";
640+
CRTBegin = IsStaticPIE ? "crtbeginS.o" : "crtbegin.o";
641+
CRTEnd = IsStaticPIE ? "crtendS.o" : "crtend.o";
631642
break;
632643
}
633644
case (ToolChain::RLT_CompilerRT): {

0 commit comments

Comments
 (0)