Skip to content

Commit 86e38ef

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merged main:da24d3a79d73c725d1b672263e558a3de6cbcde9 into amd-gfx:7c11d09023ee
Local branch amd-gfx 7c11d09 Merged main:0a369b06e34495966c6c9db427ea52f77a82a0bf into amd-gfx:24ba96a84828 Remote branch main da24d3a [AsmParser] Use range-based for loops (NFC) (llvm#97499)
2 parents 7c11d09 + da24d3a commit 86e38ef

File tree

164 files changed

+26721
-4431
lines changed

Some content is hidden

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

164 files changed

+26721
-4431
lines changed

clang-tools-extra/clangd/index/remote/server/Server.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -499,8 +499,6 @@ int main(int argc, char *argv[]) {
499499
}
500500

501501
llvm::errs().SetBuffered();
502-
// Don't flush stdout when logging for thread safety.
503-
llvm::errs().tie(nullptr);
504502
auto Logger = makeLogger(LogPrefix.getValue(), llvm::errs());
505503
clang::clangd::LoggingSession LoggingSession(*Logger);
506504

clang-tools-extra/clangd/tool/ClangdMain.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -840,8 +840,6 @@ clangd accepts flags on the commandline, and in the CLANGD_FLAGS environment var
840840
// Use buffered stream to stderr (we still flush each log message). Unbuffered
841841
// stream can cause significant (non-deterministic) latency for the logger.
842842
llvm::errs().SetBuffered();
843-
// Don't flush stdout when logging, this would be both slow and racy!
844-
llvm::errs().tie(nullptr);
845843
StreamLogger Logger(llvm::errs(), LogLevel);
846844
LoggingSession LoggingSession(Logger);
847845
// Write some initial logs before we start doing any real work.

clang/include/clang/Driver/Options.td

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6319,9 +6319,9 @@ def mno_gather : Flag<["-"], "mno-gather">, Group<m_Group>,
63196319
def mno_scatter : Flag<["-"], "mno-scatter">, Group<m_Group>,
63206320
HelpText<"Disable generation of scatter instructions in auto-vectorization(x86 only)">;
63216321
def mapx_features_EQ : CommaJoined<["-"], "mapx-features=">, Group<m_x86_Features_Group>,
6322-
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">;
6322+
HelpText<"Enable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, CLOption, FlangOption]>;
63236323
def mno_apx_features_EQ : CommaJoined<["-"], "mno-apx-features=">, Group<m_x86_Features_Group>,
6324-
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">;
6324+
HelpText<"Disable features of APX">, Values<"egpr,push2pop2,ppx,ndd,ccmp,nf,cf,zu">, Visibility<[ClangOption, CLOption, FlangOption]>;
63256325
// For stability, we only add a feature to -mapxf after it passes the validation of llvm-test-suite && cpu2017 on Intel SDE.
63266326
def mapxf : Flag<["-"], "mapxf">, Alias<mapx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>;
63276327
def mno_apxf : Flag<["-"], "mno-apxf">, Alias<mno_apx_features_EQ>, AliasArgs<["egpr","push2pop2","ppx","ndd","ccmp","nf","cf"]>;

clang/lib/Basic/Targets/PPC.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -928,17 +928,18 @@ bool PPCTargetInfo::validateCpuSupports(StringRef FeatureStr) const {
928928

929929
bool PPCTargetInfo::validateCpuIs(StringRef CPUName) const {
930930
llvm::Triple Triple = getTriple();
931-
if (Triple.isOSAIX()) {
932-
#define PPC_AIX_CPU(NAME, SUPPORT_METHOD, INDEX, OP, VALUE) .Case(NAME, true)
933-
return llvm::StringSwitch<bool>(CPUName)
934-
#include "llvm/TargetParser/PPCTargetParser.def"
935-
.Default(false);
936-
}
937-
938-
assert(Triple.isOSLinux() &&
931+
assert((Triple.isOSAIX() || Triple.isOSLinux()) &&
939932
"__builtin_cpu_is() is only supported for AIX and Linux.");
940-
#define PPC_LNX_CPU(NAME, NUM) .Case(NAME, true)
941-
return llvm::StringSwitch<bool>(CPUName)
933+
934+
#define PPC_CPU(NAME, Linux_SUPPORT_METHOD, LinuxID, AIX_SUPPORT_METHOD, \
935+
AIXID) \
936+
.Case(NAME, {Linux_SUPPORT_METHOD, AIX_SUPPORT_METHOD})
937+
938+
std::pair<unsigned, unsigned> SuppportMethod =
939+
llvm::StringSwitch<std::pair<unsigned, unsigned>>(CPUName)
942940
#include "llvm/TargetParser/PPCTargetParser.def"
943-
.Default(false);
941+
.Default({BUILTIN_PPC_UNSUPPORTED, BUILTIN_PPC_UNSUPPORTED});
942+
return Triple.isOSLinux()
943+
? (SuppportMethod.first != BUILTIN_PPC_UNSUPPORTED)
944+
: (SuppportMethod.second != BUILTIN_PPC_UNSUPPORTED);
944945
}

clang/lib/CodeGen/CGBuiltin.cpp

Lines changed: 27 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16748,10 +16748,10 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1674816748
auto GenAIXPPCBuiltinCpuExpr = [&](unsigned SupportMethod, unsigned FieldIdx,
1674916749
unsigned Mask, CmpInst::Predicate CompOp,
1675016750
unsigned OpValue) -> Value * {
16751-
if (SupportMethod == AIX_BUILTIN_PPC_FALSE)
16751+
if (SupportMethod == BUILTIN_PPC_FALSE)
1675216752
return llvm::ConstantInt::getFalse(ConvertType(E->getType()));
1675316753

16754-
if (SupportMethod == AIX_BUILTIN_PPC_TRUE)
16754+
if (SupportMethod == BUILTIN_PPC_TRUE)
1675516755
return llvm::ConstantInt::getTrue(ConvertType(E->getType()));
1675616756

1675716757
assert(SupportMethod <= SYS_CALL && "Invalid value for SupportMethod.");
@@ -16803,34 +16803,39 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1680316803
StringRef CPUStr = cast<clang::StringLiteral>(CPUExpr)->getString();
1680416804
llvm::Triple Triple = getTarget().getTriple();
1680516805

16806-
if (Triple.isOSAIX()) {
16807-
unsigned SupportMethod, FieldIdx, CpuIdValue;
16808-
CmpInst::Predicate CompareOp;
16809-
typedef std::tuple<unsigned, unsigned, CmpInst::Predicate, unsigned>
16810-
CPUType;
16811-
std::tie(SupportMethod, FieldIdx, CompareOp, CpuIdValue) =
16812-
static_cast<CPUType>(StringSwitch<CPUType>(CPUStr)
16813-
#define PPC_AIX_CPU(NAME, SUPPORT_METHOD, INDEX, COMPARE_OP, VALUE) \
16814-
.Case(NAME, {SUPPORT_METHOD, INDEX, COMPARE_OP, VALUE})
16806+
unsigned LinuxSupportMethod, LinuxIDValue, AIXSupportMethod, AIXIDValue;
16807+
typedef std::tuple<unsigned, unsigned, unsigned, unsigned> CPUInfo;
16808+
16809+
std::tie(LinuxSupportMethod, LinuxIDValue, AIXSupportMethod, AIXIDValue) =
16810+
static_cast<CPUInfo>(StringSwitch<CPUInfo>(CPUStr)
16811+
#define PPC_CPU(NAME, Linux_SUPPORT_METHOD, LinuxID, AIX_SUPPORT_METHOD, \
16812+
AIXID) \
16813+
.Case(NAME, {Linux_SUPPORT_METHOD, LinuxID, AIX_SUPPORT_METHOD, AIXID})
1681516814
#include "llvm/TargetParser/PPCTargetParser.def"
16816-
.Default({AIX_BUILTIN_PPC_FALSE, 0,
16817-
CmpInst::Predicate(), 0}));
16818-
return GenAIXPPCBuiltinCpuExpr(SupportMethod, FieldIdx, 0, CompareOp,
16819-
CpuIdValue);
16815+
.Default({BUILTIN_PPC_UNSUPPORTED, 0,
16816+
BUILTIN_PPC_UNSUPPORTED, 0}));
16817+
16818+
if (Triple.isOSAIX()) {
16819+
assert((AIXSupportMethod != BUILTIN_PPC_UNSUPPORTED) &&
16820+
"Invalid CPU name. Missed by SemaChecking?");
16821+
return GenAIXPPCBuiltinCpuExpr(AIXSupportMethod, AIX_SYSCON_IMPL_IDX, 0,
16822+
ICmpInst::ICMP_EQ, AIXIDValue);
1682016823
}
1682116824

1682216825
assert(Triple.isOSLinux() &&
1682316826
"__builtin_cpu_is() is only supported for AIX and Linux.");
16824-
unsigned NumCPUID = StringSwitch<unsigned>(CPUStr)
16825-
#define PPC_LNX_CPU(Name, NumericID) .Case(Name, NumericID)
16826-
#include "llvm/TargetParser/PPCTargetParser.def"
16827-
.Default(-1U);
16828-
assert(NumCPUID < -1U && "Invalid CPU name. Missed by SemaChecking?");
16827+
16828+
assert((LinuxSupportMethod != BUILTIN_PPC_UNSUPPORTED) &&
16829+
"Invalid CPU name. Missed by SemaChecking?");
16830+
16831+
if (LinuxSupportMethod == BUILTIN_PPC_FALSE)
16832+
return llvm::ConstantInt::getFalse(ConvertType(E->getType()));
16833+
1682916834
Value *Op0 = llvm::ConstantInt::get(Int32Ty, PPC_FAWORD_CPUID);
1683016835
llvm::Function *F = CGM.getIntrinsic(Intrinsic::ppc_fixed_addr_ld);
1683116836
Value *TheCall = Builder.CreateCall(F, {Op0}, "cpu_is");
1683216837
return Builder.CreateICmpEQ(TheCall,
16833-
llvm::ConstantInt::get(Int32Ty, NumCPUID));
16838+
llvm::ConstantInt::get(Int32Ty, LinuxIDValue));
1683416839
}
1683516840
case Builtin::BI__builtin_cpu_supports: {
1683616841
llvm::Triple Triple = getTarget().getTriple();
@@ -16848,7 +16853,7 @@ Value *CodeGenFunction::EmitPPCBuiltinExpr(unsigned BuiltinID,
1684816853
VALUE) \
1684916854
.Case(NAME, {SUPPORT_METHOD, INDEX, MASK, COMP_OP, VALUE})
1685016855
#include "llvm/TargetParser/PPCTargetParser.def"
16851-
.Default({AIX_BUILTIN_PPC_FALSE, 0, 0,
16856+
.Default({BUILTIN_PPC_FALSE, 0, 0,
1685216857
CmpInst::Predicate(), 0}));
1685316858
return GenAIXPPCBuiltinCpuExpr(SupportMethod, FieldIdx, Mask, CompOp,
1685416859
Value);

clang/lib/Driver/ToolChains/AMDGPUOpenMP.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ void AMDGPUOpenMPToolChain::addClangTargetOptions(
4747
assert(DeviceOffloadingKind == Action::OFK_OpenMP &&
4848
"Only OpenMP offloading kinds are supported.");
4949

50+
CC1Args.push_back("-fcuda-is-device");
51+
5052
if (DriverArgs.hasArg(options::OPT_nogpulib))
5153
return;
5254

clang/lib/Driver/ToolChains/CommonArgs.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1469,6 +1469,8 @@ collectSanitizerRuntimes(const ToolChain &TC, const ArgList &Args,
14691469
if (SanArgs.linkCXXRuntimes())
14701470
StaticRuntimes.push_back("msan_cxx");
14711471
}
1472+
if (SanArgs.needsNsanRt())
1473+
StaticRuntimes.push_back("nsan");
14721474
if (!SanArgs.needsSharedRt() && SanArgs.needsTsanRt()) {
14731475
StaticRuntimes.push_back("tsan");
14741476
if (SanArgs.linkCXXRuntimes())

clang/lib/Interpreter/Interpreter.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -686,10 +686,12 @@ class InterfaceKindVisitor
686686
}
687687

688688
private:
689-
// Force cast these types to uint64 to reduce the number of overloads of
690-
// `__clang_Interpreter_SetValueNoAlloc`.
689+
// Force cast these types to the uint that fits the register size. That way we
690+
// reduce the number of overloads of `__clang_Interpreter_SetValueNoAlloc`.
691691
void HandleIntegralOrEnumType(const Type *Ty) {
692-
TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(Ctx.UnsignedLongLongTy);
692+
uint64_t PtrBits = Ctx.getTypeSize(Ctx.VoidPtrTy);
693+
QualType UIntTy = Ctx.getBitIntType(/*Unsigned=*/true, PtrBits);
694+
TypeSourceInfo *TSI = Ctx.getTrivialTypeSourceInfo(UIntTy);
693695
ExprResult CastedExpr =
694696
S.BuildCStyleCastExpr(SourceLocation(), TSI, SourceLocation(), E);
695697
assert(!CastedExpr.isInvalid() && "Cannot create cstyle cast expr");

clang/lib/StaticAnalyzer/Checkers/CheckObjCDealloc.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -247,8 +247,8 @@ void ObjCDeallocChecker::checkASTDecl(const ObjCImplementationDecl *D,
247247
PathDiagnosticLocation DLoc =
248248
PathDiagnosticLocation::createBegin(D, BR.getSourceManager());
249249

250-
BR.EmitBasicReport(D, this, Name, categories::CoreFoundationObjectiveC,
251-
OS.str(), DLoc);
250+
BR.EmitBasicReport(D, this, Name, categories::CoreFoundationObjectiveC, Buf,
251+
DLoc);
252252
return;
253253
}
254254
}
@@ -585,7 +585,7 @@ void ObjCDeallocChecker::diagnoseMissingReleases(CheckerContext &C) const {
585585
" before '[super dealloc]'";
586586

587587
auto BR = std::make_unique<PathSensitiveBugReport>(MissingReleaseBugType,
588-
OS.str(), ErrNode);
588+
Buf, ErrNode);
589589
C.emitReport(std::move(BR));
590590
}
591591

@@ -706,8 +706,8 @@ bool ObjCDeallocChecker::diagnoseExtraRelease(SymbolRef ReleasedValue,
706706
OS << " property but was released in 'dealloc'";
707707
}
708708

709-
auto BR = std::make_unique<PathSensitiveBugReport>(ExtraReleaseBugType,
710-
OS.str(), ErrNode);
709+
auto BR = std::make_unique<PathSensitiveBugReport>(ExtraReleaseBugType, Buf,
710+
ErrNode);
711711
BR->addRange(M.getOriginExpr()->getSourceRange());
712712

713713
C.emitReport(std::move(BR));
@@ -749,7 +749,7 @@ bool ObjCDeallocChecker::diagnoseMistakenDealloc(SymbolRef DeallocedValue,
749749
<< "' should be released rather than deallocated";
750750

751751
auto BR = std::make_unique<PathSensitiveBugReport>(MistakenDeallocBugType,
752-
OS.str(), ErrNode);
752+
Buf, ErrNode);
753753
BR->addRange(M.getOriginExpr()->getSourceRange());
754754

755755
C.emitReport(std::move(BR));

clang/lib/StaticAnalyzer/Checkers/RetainCountChecker/RetainCountDiagnostics.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -411,11 +411,11 @@ annotateConsumedSummaryMismatch(const ExplodedNode *N,
411411
}
412412
}
413413

414-
if (os.str().empty())
414+
if (sbuf.empty())
415415
return nullptr;
416416

417417
PathDiagnosticLocation L = PathDiagnosticLocation::create(CallExitLoc, SM);
418-
return std::make_shared<PathDiagnosticEventPiece>(L, os.str());
418+
return std::make_shared<PathDiagnosticEventPiece>(L, sbuf);
419419
}
420420

421421
/// Annotate the parameter at the analysis entry point.
@@ -446,7 +446,7 @@ annotateStartParameter(const ExplodedNode *N, SymbolRef Sym,
446446
assert(CurrT->getCount() == 0);
447447
os << "0";
448448
}
449-
return std::make_shared<PathDiagnosticEventPiece>(L, os.str());
449+
return std::make_shared<PathDiagnosticEventPiece>(L, s);
450450
}
451451

452452
PathDiagnosticPieceRef
@@ -493,7 +493,7 @@ RefCountReportVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
493493
if (PrevT && IsFreeUnowned && CurrV.isNotOwned() && PrevT->isOwned()) {
494494
os << "Object is now not exclusively owned";
495495
auto Pos = PathDiagnosticLocation::create(N->getLocation(), SM);
496-
return std::make_shared<PathDiagnosticEventPiece>(Pos, os.str());
496+
return std::make_shared<PathDiagnosticEventPiece>(Pos, sbuf);
497497
}
498498

499499
// This is the allocation site since the previous node had no bindings
@@ -535,7 +535,7 @@ RefCountReportVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
535535
}
536536

537537
PathDiagnosticLocation Pos(S, SM, N->getLocationContext());
538-
return std::make_shared<PathDiagnosticEventPiece>(Pos, os.str());
538+
return std::make_shared<PathDiagnosticEventPiece>(Pos, sbuf);
539539
}
540540

541541
// Gather up the effects that were performed on the object at this
@@ -582,13 +582,13 @@ RefCountReportVisitor::VisitNode(const ExplodedNode *N, BugReporterContext &BRC,
582582
if (!shouldGenerateNote(os, PrevT, CurrV, DeallocSent))
583583
return nullptr;
584584

585-
if (os.str().empty())
585+
if (sbuf.empty())
586586
return nullptr; // We have nothing to say!
587587

588588
const Stmt *S = N->getLocation().castAs<StmtPoint>().getStmt();
589589
PathDiagnosticLocation Pos(S, BRC.getSourceManager(),
590590
N->getLocationContext());
591-
auto P = std::make_shared<PathDiagnosticEventPiece>(Pos, os.str());
591+
auto P = std::make_shared<PathDiagnosticEventPiece>(Pos, sbuf);
592592

593593
// Add the range by scanning the children of the statement for any bindings
594594
// to Sym.
@@ -831,7 +831,7 @@ RefLeakReportVisitor::getEndPath(BugReporterContext &BRC,
831831
<< RV->getCount();
832832
}
833833

834-
return std::make_shared<PathDiagnosticEventPiece>(L, os.str());
834+
return std::make_shared<PathDiagnosticEventPiece>(L, sbuf);
835835
}
836836

837837
RefCountReport::RefCountReport(const RefCountBug &D, const LangOptions &LOpts,

0 commit comments

Comments
 (0)