Skip to content

Commit

Permalink
Merge branch 'stable/20230725' into coro_noinline
Browse files Browse the repository at this point in the history
  • Loading branch information
aschwaighofer committed Feb 8, 2024
2 parents 4a51a10 + d404017 commit 41c7cea
Show file tree
Hide file tree
Showing 273 changed files with 2,118 additions and 2,244 deletions.
47 changes: 27 additions & 20 deletions clang/lib/Analysis/UnsafeBufferUsage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2864,34 +2864,41 @@ void clang::checkUnsafeBufferUsage(const Decl *D,
it->first->getNameAsString() +
"' : has a reference type"));
#endif
it = FixablesForAllVars.byVar.erase(it);
} else if (Tracker.hasUnclaimedUses(it->first)) {
#ifndef NDEBUG
auto AllUnclaimed = Tracker.getUnclaimedUses(it->first);
for (auto UnclaimedDRE : AllUnclaimed) {
std::string UnclaimedUseTrace =
getDREAncestorString(UnclaimedDRE, D->getASTContext());

Handler.addDebugNoteForVar(
it->first, UnclaimedDRE->getBeginLoc(),
("failed to produce fixit for '" + it->first->getNameAsString() +
"' : has an unclaimed use\nThe unclaimed DRE trace: " +
UnclaimedUseTrace));
}
#endif
it = FixablesForAllVars.byVar.erase(it);
} else if (it->first->isInitCapture()) {
it = FixablesForAllVars.byVar.erase(it);
} else if (Tracker.hasUnclaimedUses(it->first)) {
it = FixablesForAllVars.byVar.erase(it);
} else if (it->first->isInitCapture()) {
#ifndef NDEBUG
Handler.addDebugNoteForVar(it->first, it->first->getBeginLoc(),
("failed to produce fixit for '" +
it->first->getNameAsString() +
"' : init capture"));
#endif
it = FixablesForAllVars.byVar.erase(it);
} else {
++it;
it = FixablesForAllVars.byVar.erase(it);
} else {
++it;
}
}

#ifndef NDEBUG
for (const auto &it : UnsafeOps.byVar) {
const VarDecl *const UnsafeVD = it.first;
auto UnclaimedDREs = Tracker.getUnclaimedUses(UnsafeVD);
if (UnclaimedDREs.empty())
continue;
const auto UnfixedVDName = UnsafeVD->getNameAsString();
for (const clang::DeclRefExpr *UnclaimedDRE : UnclaimedDREs) {
std::string UnclaimedUseTrace =
getDREAncestorString(UnclaimedDRE, D->getASTContext());

Handler.addDebugNoteForVar(
UnsafeVD, UnclaimedDRE->getBeginLoc(),
("failed to produce fixit for '" + UnfixedVDName +
"' : has an unclaimed use\nThe unclaimed DRE trace: " +
UnclaimedUseTrace));
}
}
#endif

// Fixpoint iteration for pointer assignments
using DepMapTy = DenseMap<const VarDecl *, llvm::SetVector<const VarDecl *>>;
Expand Down
6 changes: 5 additions & 1 deletion clang/lib/Basic/Targets/OSTargets.h
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
this->TLSSupported = !Triple.isOSVersionLT(3);
} else if (Triple.isDriverKit()) {
// No TLS on DriverKit.
}
} else if (Triple.isXROS())
this->TLSSupported = true;

this->MCountName = "\01mcount";
}
Expand Down Expand Up @@ -139,6 +140,9 @@ class LLVM_LIBRARY_VISIBILITY DarwinTargetInfo : public OSTargetInfo<Target> {
case llvm::Triple::WatchOS: // Earliest supporting version is 5.0.0.
MinVersion = llvm::VersionTuple(5U);
break;
case llvm::Triple::XROS:
MinVersion = llvm::VersionTuple(0);
break;
default:
// Conservatively return 8 bytes if OS is unknown.
return 64;
Expand Down
17 changes: 4 additions & 13 deletions clang/lib/CodeGen/CGCoroutine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -402,11 +402,8 @@ struct CallCoroEnd final : public EHScopeStack::Cleanup {
llvm::Function *CoroEndFn = CGM.getIntrinsic(llvm::Intrinsic::coro_end);
// See if we have a funclet bundle to associate coro.end with. (WinEH)
auto Bundles = getBundlesForCoroEnd(CGF);
auto *CoroEnd =
CGF.Builder.CreateCall(CoroEndFn,
{NullPtr, CGF.Builder.getTrue(),
llvm::ConstantTokenNone::get(CoroEndFn->getContext())},
Bundles);
auto *CoroEnd = CGF.Builder.CreateCall(
CoroEndFn, {NullPtr, CGF.Builder.getTrue()}, Bundles);
if (Bundles.empty()) {
// Otherwise, (landingpad model), create a conditional branch that leads
// either to a cleanup block or a block with EH resume instruction.
Expand Down Expand Up @@ -757,9 +754,7 @@ void CodeGenFunction::EmitCoroutineBody(const CoroutineBodyStmt &S) {
// Emit coro.end before getReturnStmt (and parameter destructors), since
// resume and destroy parts of the coroutine should not include them.
llvm::Function *CoroEnd = CGM.getIntrinsic(llvm::Intrinsic::coro_end);
Builder.CreateCall(CoroEnd,
{NullPtr, Builder.getFalse(),
llvm::ConstantTokenNone::get(CoroEnd->getContext())});
Builder.CreateCall(CoroEnd, {NullPtr, Builder.getFalse()});

if (Stmt *Ret = S.getReturnStmt()) {
// Since we already emitted the return value above, so we shouldn't
Expand Down Expand Up @@ -828,11 +823,7 @@ RValue CodeGenFunction::EmitCoroutineIntrinsic(const CallExpr *E,
}
for (const Expr *Arg : E->arguments())
Args.push_back(EmitScalarExpr(Arg));
// @llvm.coro.end takes a token parameter. Add token 'none' as the last
// argument.
if (IID == llvm::Intrinsic::coro_end)
Args.push_back(llvm::ConstantTokenNone::get(getLLVMContext()));


llvm::Function *F = CGM.getIntrinsic(IID);
llvm::CallInst *Call = Builder.CreateCall(F, Args);

Expand Down
7 changes: 6 additions & 1 deletion clang/lib/CodeGen/CGObjC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3967,10 +3967,12 @@ static unsigned getBaseMachOPlatformID(const llvm::Triple &TT) {
return llvm::MachO::PLATFORM_TVOS;
case llvm::Triple::WatchOS:
return llvm::MachO::PLATFORM_WATCHOS;
case llvm::Triple::XROS:
return llvm::MachO::PLATFORM_XROS;
case llvm::Triple::DriverKit:
return llvm::MachO::PLATFORM_DRIVERKIT;
default:
return /*Unknown platform*/ 0;
return llvm::MachO::PLATFORM_UNKNOWN;
}
}

Expand Down Expand Up @@ -4050,6 +4052,9 @@ static bool isFoundationNeededForDarwinAvailabilityCheck(
case llvm::Triple::MacOSX:
FoundationDroppedInVersion = VersionTuple(/*Major=*/10, /*Minor=*/15);
break;
case llvm::Triple::XROS:
// XROS doesn't need Foundation.
return false;
case llvm::Triple::DriverKit:
// DriverKit doesn't need Foundation.
return false;
Expand Down
1 change: 1 addition & 0 deletions clang/lib/Driver/Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6212,6 +6212,7 @@ const ToolChain &Driver::getToolChain(const ArgList &Args,
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::WatchOS:
case llvm::Triple::XROS:
case llvm::Triple::DriverKit:
TC = std::make_unique<toolchains::DarwinClang>(*this, Target, Args);
break;
Expand Down
5 changes: 5 additions & 0 deletions clang/lib/Driver/ToolChains/Arch/AArch64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,11 @@ std::string aarch64::getAArch64TargetCPU(const ArgList &Args,
return "apple-m1";
}

if (Triple.isXROS()) {
// The xrOS simulator runs on M1 as well, it should have been covered above.
assert(!Triple.isSimulatorEnvironment() && "xrossim should be mac-like");
return "apple-a12";
}
// arm64e requires v8.3a and only runs on apple-a12 and later CPUs.
if (Triple.isArm64e())
return "apple-a12";
Expand Down
5 changes: 3 additions & 2 deletions clang/lib/Driver/ToolChains/Arch/ARM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -367,6 +367,7 @@ arm::FloatABI arm::getDefaultFloatABI(const llvm::Triple &Triple) {
case llvm::Triple::IOS:
case llvm::Triple::TvOS:
case llvm::Triple::DriverKit:
case llvm::Triple::XROS:
// Darwin defaults to "softfp" for v6 and v7.
if (Triple.isWatchABI())
return FloatABI::Hard;
Expand Down Expand Up @@ -830,8 +831,8 @@ llvm::ARM::FPUKind arm::getARMTargetFeatures(const Driver &D,
if (A->getOption().matches(options::OPT_mlong_calls))
Features.push_back("+long-calls");
} else if (KernelOrKext && (!Triple.isiOS() || Triple.isOSVersionLT(6)) &&
!Triple.isWatchOS()) {
Features.push_back("+long-calls");
!Triple.isWatchOS() && !Triple.isXROS()) {
Features.push_back("+long-calls");
}

// Generate execute-only output (no data access to code sections).
Expand Down
Loading

0 comments on commit 41c7cea

Please sign in to comment.