Skip to content

Commit 41c7cea

Browse files
Merge branch 'stable/20230725' into coro_noinline
2 parents 4a51a10 + d404017 commit 41c7cea

File tree

273 files changed

+2118
-2244
lines changed

Some content is hidden

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

273 files changed

+2118
-2244
lines changed

clang/lib/Analysis/UnsafeBufferUsage.cpp

Lines changed: 27 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2864,34 +2864,41 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
28642864
it->first->getNameAsString() +
28652865
"' : has a reference type"));
28662866
#endif
2867-
it = FixablesForAllVars.byVar.erase(it);
2868-
} else if (Tracker.hasUnclaimedUses(it->first)) {
2869-
#ifndef NDEBUG
2870-
auto AllUnclaimed = Tracker.getUnclaimedUses(it->first);
2871-
for (auto UnclaimedDRE : AllUnclaimed) {
2872-
std::string UnclaimedUseTrace =
2873-
getDREAncestorString(UnclaimedDRE, D->getASTContext());
2874-
2875-
Handler.addDebugNoteForVar(
2876-
it->first, UnclaimedDRE->getBeginLoc(),
2877-
("failed to produce fixit for '" + it->first->getNameAsString() +
2878-
"' : has an unclaimed use\nThe unclaimed DRE trace: " +
2879-
UnclaimedUseTrace));
2880-
}
2881-
#endif
2882-
it = FixablesForAllVars.byVar.erase(it);
2883-
} else if (it->first->isInitCapture()) {
2867+
it = FixablesForAllVars.byVar.erase(it);
2868+
} else if (Tracker.hasUnclaimedUses(it->first)) {
2869+
it = FixablesForAllVars.byVar.erase(it);
2870+
} else if (it->first->isInitCapture()) {
28842871
#ifndef NDEBUG
28852872
Handler.addDebugNoteForVar(it->first, it->first->getBeginLoc(),
28862873
("failed to produce fixit for '" +
28872874
it->first->getNameAsString() +
28882875
"' : init capture"));
28892876
#endif
2890-
it = FixablesForAllVars.byVar.erase(it);
2891-
} else {
2892-
++it;
2877+
it = FixablesForAllVars.byVar.erase(it);
2878+
} else {
2879+
++it;
2880+
}
2881+
}
2882+
2883+
#ifndef NDEBUG
2884+
for (const auto &it : UnsafeOps.byVar) {
2885+
const VarDecl *const UnsafeVD = it.first;
2886+
auto UnclaimedDREs = Tracker.getUnclaimedUses(UnsafeVD);
2887+
if (UnclaimedDREs.empty())
2888+
continue;
2889+
const auto UnfixedVDName = UnsafeVD->getNameAsString();
2890+
for (const clang::DeclRefExpr *UnclaimedDRE : UnclaimedDREs) {
2891+
std::string UnclaimedUseTrace =
2892+
getDREAncestorString(UnclaimedDRE, D->getASTContext());
2893+
2894+
Handler.addDebugNoteForVar(
2895+
UnsafeVD, UnclaimedDRE->getBeginLoc(),
2896+
("failed to produce fixit for '" + UnfixedVDName +
2897+
"' : has an unclaimed use\nThe unclaimed DRE trace: " +
2898+
UnclaimedUseTrace));
28932899
}
28942900
}
2901+
#endif
28952902

28962903
// Fixpoint iteration for pointer assignments
28972904
using DepMapTy = DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;

clang/lib/Basic/Targets/OSTargets.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
104104
this->TLSSupported = !Triple.isOSVersionLT(3);
105105
} else if (Triple.isDriverKit()) {
106106
// No TLS on DriverKit.
107-
}
107+
} else if (Triple.isXROS())
108+
this->TLSSupported = true;
108109

109110
this->MCountName = "\01mcount";
110111
}
@@ -139,6 +140,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
139140
case llvm::Triple::WatchOS: // Earliest supporting version is 5.0.0.
140141
MinVersion = llvm::VersionTuple(5U);
141142
break;
143+
case llvm::Triple::XROS:
144+
MinVersion = llvm::VersionTuple(0);
145+
break;
142146
default:
143147
// Conservatively return 8 bytes if OS is unknown.
144148
return 64;

clang/lib/CodeGen/CGCoroutine.cpp

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -402,11 +402,8 @@ struct CallCoroEnd final : public EHScopeStack::Cleanup {
402402
llvm::Function *CoroEndFn = CGM.getIntrinsic(llvm::Intrinsic::coro_end);
403403
// See if we have a funclet bundle to associate coro.end with. (WinEH)
404404
auto Bundles = getBundlesForCoroEnd(CGF);
405-
auto *CoroEnd =
406-
CGF.Builder.CreateCall(CoroEndFn,
407-
{NullPtr, CGF.Builder.getTrue(),
408-
llvm::ConstantTokenNone::get(CoroEndFn->getContext())},
409-
Bundles);
405+
auto *CoroEnd = CGF.Builder.CreateCall(
406+
CoroEndFn, {NullPtr, CGF.Builder.getTrue()}, Bundles);
410407
if (Bundles.empty()) {
411408
// Otherwise, (landingpad model), create a conditional branch that leads
412409
// either to a cleanup block or a block with EH resume instruction.
@@ -757,9 +754,7 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
757754
// Emit coro.end before getReturnStmt (and parameter destructors), since
758755
// resume and destroy parts of the coroutine should not include them.
759756
llvm::Function *CoroEnd = CGM.getIntrinsic(llvm::Intrinsic::coro_end);
760-
Builder.CreateCall(CoroEnd,
761-
{NullPtr, Builder.getFalse(),
762-
llvm::ConstantTokenNone::get(CoroEnd->getContext())});
757+
Builder.CreateCall(CoroEnd, {NullPtr, Builder.getFalse()});
763758

764759
if (Stmt *Ret = S.getReturnStmt()) {
765760
// Since we already emitted the return value above, so we shouldn't
@@ -828,11 +823,7 @@ RValue CodeGenFunction::EmitCoroutineIntrinsic(const CallExpr *E,
828823
}
829824
for (const Expr *Arg : E->arguments())
830825
Args.push_back(EmitScalarExpr(Arg));
831-
// @llvm.coro.end takes a token parameter. Add token 'none' as the last
832-
// argument.
833-
if (IID == llvm::Intrinsic::coro_end)
834-
Args.push_back(llvm::ConstantTokenNone::get(getLLVMContext()));
835-
826+
836827
llvm::Function *F = CGM.getIntrinsic(IID);
837828
llvm::CallInst *Call = Builder.CreateCall(F, Args);
838829

clang/lib/CodeGen/CGObjC.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3967,10 +3967,12 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple &TT) {
39673967
return llvm::MachO::PLATFORM_TVOS;
39683968
case llvm::Triple::WatchOS:
39693969
return llvm::MachO::PLATFORM_WATCHOS;
3970+
case llvm::Triple::XROS:
3971+
return llvm::MachO::PLATFORM_XROS;
39703972
case llvm::Triple::DriverKit:
39713973
return llvm::MachO::PLATFORM_DRIVERKIT;
39723974
default:
3973-
return /*Unknown platform*/ 0;
3975+
return llvm::MachO::PLATFORM_UNKNOWN;
39743976
}
39753977
}
39763978

@@ -4050,6 +4052,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
40504052
case llvm::Triple::MacOSX:
40514053
FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
40524054
break;
4055+
case llvm::Triple::XROS:
4056+
// XROS doesn't need Foundation.
4057+
return false;
40534058
case llvm::Triple::DriverKit:
40544059
// DriverKit doesn't need Foundation.
40554060
return false;

clang/lib/Driver/Driver.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,6 +6212,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
62126212
case llvm::Triple::IOS:
62136213
case llvm::Triple::TvOS:
62146214
case llvm::Triple::WatchOS:
6215+
case llvm::Triple::XROS:
62156216
case llvm::Triple::DriverKit:
62166217
TC = std::make_unique<toolchains::DarwinClang>(*this, Target, Args);
62176218
break;

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

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

56+
if (Triple.isXROS()) {
57+
// The xrOS simulator runs on M1 as well, it should have been covered above.
58+
assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
59+
return "apple-a12";
60+
}
5661
// arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
5762
if (Triple.isArm64e())
5863
return "apple-a12";

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

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) {
367367
case llvm::Triple::IOS:
368368
case llvm::Triple::TvOS:
369369
case llvm::Triple::DriverKit:
370+
case llvm::Triple::XROS:
370371
// Darwin defaults to "softfp" for v6 and v7.
371372
if (Triple.isWatchABI())
372373
return FloatABI::Hard;
@@ -830,8 +831,8 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
830831
if (A->getOption().matches(options::OPT_mlong_calls))
831832
Features.push_back("+long-calls");
832833
} else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
833-
!Triple.isWatchOS()) {
834-
Features.push_back("+long-calls");
834+
!Triple.isWatchOS() && !Triple.isXROS()) {
835+
Features.push_back("+long-calls");
835836
}
836837

837838
// Generate execute-only output (no data access to code sections).

0 commit comments

Comments
 (0)