Skip to content

Commit bdbd603

Browse files
rebase
Created using spr 1.3.6
2 parents 0d7cc25 + 5a0a07c commit bdbd603

File tree

159 files changed

+8106
-4971
lines changed

Some content is hidden

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

159 files changed

+8106
-4971
lines changed

bolt/lib/Profile/BoltAddressTranslation.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ BoltAddressTranslation::getFallthroughsInTrace(uint64_t FuncAddress,
546546
return Res;
547547

548548
for (auto Iter = FromIter; Iter != ToIter;) {
549-
const uint32_t Src = Iter->first;
549+
const uint32_t Src = Iter->second >> 1;
550550
if (Iter->second & BRANCHENTRY) {
551551
++Iter;
552552
continue;
@@ -557,7 +557,7 @@ BoltAddressTranslation::getFallthroughsInTrace(uint64_t FuncAddress,
557557
++Iter;
558558
if (Iter->second & BRANCHENTRY)
559559
break;
560-
Res.emplace_back(Src, Iter->first);
560+
Res.emplace_back(Src, Iter->second >> 1);
561561
}
562562

563563
return Res;

bolt/lib/Profile/DataAggregator.cpp

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -835,13 +835,8 @@ bool DataAggregator::doTrace(const Trace &Trace, uint64_t Count,
835835

836836
LLVM_DEBUG(dbgs() << "Processing " << FTs->size() << " fallthroughs for "
837837
<< FromFunc->getPrintName() << ":" << Trace << '\n');
838-
for (auto [From, To] : *FTs) {
839-
if (BAT) {
840-
From = BAT->translate(FromFunc->getAddress(), From, /*IsBranchSrc=*/true);
841-
To = BAT->translate(FromFunc->getAddress(), To, /*IsBranchSrc=*/false);
842-
}
838+
for (const auto &[From, To] : *FTs)
843839
doIntraBranch(*ParentFunc, From, To, Count, false);
844-
}
845840

846841
return true;
847842
}

bolt/lib/Rewrite/RewriteInstance.cpp

Lines changed: 13 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -780,14 +780,6 @@ void RewriteInstance::discoverFileObjects() {
780780

781781
// For local symbols we want to keep track of associated FILE symbol name for
782782
// disambiguation by combined name.
783-
StringRef FileSymbolName;
784-
bool SeenFileName = false;
785-
struct SymbolRefHash {
786-
size_t operator()(SymbolRef const &S) const {
787-
return std::hash<decltype(DataRefImpl::p)>{}(S.getRawDataRefImpl().p);
788-
}
789-
};
790-
std::unordered_map<SymbolRef, StringRef, SymbolRefHash> SymbolToFileName;
791783
for (const ELFSymbolRef &Symbol : InputFile->symbols()) {
792784
Expected<StringRef> NameOrError = Symbol.getName();
793785
if (NameOrError && NameOrError->starts_with("__asan_init")) {
@@ -806,21 +798,8 @@ void RewriteInstance::discoverFileObjects() {
806798
if (cantFail(Symbol.getFlags()) & SymbolRef::SF_Undefined)
807799
continue;
808800

809-
if (cantFail(Symbol.getType()) == SymbolRef::ST_File) {
801+
if (cantFail(Symbol.getType()) == SymbolRef::ST_File)
810802
FileSymbols.emplace_back(Symbol);
811-
StringRef Name =
812-
cantFail(std::move(NameOrError), "cannot get symbol name for file");
813-
// Ignore Clang LTO artificial FILE symbol as it is not always generated,
814-
// and this uncertainty is causing havoc in function name matching.
815-
if (Name == "ld-temp.o")
816-
continue;
817-
FileSymbolName = Name;
818-
SeenFileName = true;
819-
continue;
820-
}
821-
if (!FileSymbolName.empty() &&
822-
!(cantFail(Symbol.getFlags()) & SymbolRef::SF_Global))
823-
SymbolToFileName[Symbol] = FileSymbolName;
824803
}
825804

826805
// Sort symbols in the file by value. Ignore symbols from non-allocatable
@@ -1028,14 +1007,14 @@ void RewriteInstance::discoverFileObjects() {
10281007
// The <id> field is used for disambiguation of local symbols since there
10291008
// could be identical function names coming from identical file names
10301009
// (e.g. from different directories).
1031-
std::string AltPrefix;
1032-
auto SFI = SymbolToFileName.find(Symbol);
1033-
if (SymbolType == SymbolRef::ST_Function && SFI != SymbolToFileName.end())
1034-
AltPrefix = Name + "/" + std::string(SFI->second);
1010+
auto SFI = llvm::upper_bound(FileSymbols, ELFSymbolRef(Symbol));
1011+
if (SymbolType == SymbolRef::ST_Function && SFI != FileSymbols.begin()) {
1012+
StringRef FileSymbolName = cantFail(SFI[-1].getName());
1013+
if (!FileSymbolName.empty())
1014+
AlternativeName = NR.uniquify(Name + "/" + FileSymbolName.str());
1015+
}
10351016

10361017
UniqueName = NR.uniquify(Name);
1037-
if (!AltPrefix.empty())
1038-
AlternativeName = NR.uniquify(AltPrefix);
10391018
}
10401019

10411020
uint64_t SymbolSize = ELFSymbolRef(Symbol).getSize();
@@ -1294,7 +1273,7 @@ void RewriteInstance::discoverFileObjects() {
12941273
FDE->getAddressRange());
12951274
}
12961275

1297-
BC->setHasSymbolsWithFileName(SeenFileName);
1276+
BC->setHasSymbolsWithFileName(FileSymbols.size());
12981277

12991278
// Now that all the functions were created - adjust their boundaries.
13001279
adjustFunctionBoundaries();
@@ -1567,6 +1546,11 @@ void RewriteInstance::registerFragments() {
15671546

15681547
uint64_t ParentAddress{0};
15691548

1549+
// Check if containing FILE symbol is BOLT emitted synthetic symbol marking
1550+
// local fragments of global parents.
1551+
if (cantFail(FSI[-1].getName()) == getBOLTFileSymbolName())
1552+
goto registerParent;
1553+
15701554
// BOLT split fragment symbols are emitted just before the main function
15711555
// symbol.
15721556
for (ELFSymbolRef NextSymbol = Symbol; NextSymbol < StopSymbol;

bolt/test/X86/register-fragments-bolt-symbols.s

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
# RUN: link_fdata %s %t.bolt %t.preagg PREAGG
3131
# PREAGG: B X:0 #chain.cold.0# 1 0
32+
# PREAGG: B X:0 #dummy# 1 0
3233
# RUN: perf2bolt %t.bolt -p %t.preagg --pa -o %t.bat.fdata -w %t.bat.yaml -v=1 \
3334
# RUN: | FileCheck %s --check-prefix=CHECK-REGISTER
3435
# RUN: FileCheck --input-file %t.bat.fdata --check-prefix=CHECK-FDATA %s
@@ -44,7 +45,13 @@
4445
# CHECK-SYMS: l F .text.cold [[#]] chain.cold.0
4546
# CHECK-SYMS: l F .text [[#]] chain
4647
# CHECK-SYMS: l df *ABS* [[#]] bolt-pseudo.o
48+
# CHECK-SYMS: l F .text.cold [[#]] dummy.cold.0
49+
# CHECK-SYMS: l F .text.cold.1 [[#]] dummy.cold.1
50+
# CHECK-SYMS: l F .text.cold.2 [[#]] dummy.cold.2
4751

52+
# CHECK-REGISTER: BOLT-INFO: marking dummy.cold.0/1(*2) as a fragment of dummy
53+
# CHECK-REGISTER: BOLT-INFO: marking dummy.cold.1/1(*2) as a fragment of dummy
54+
# CHECK-REGISTER: BOLT-INFO: marking dummy.cold.2/1(*2) as a fragment of dummy
4855
# CHECK-REGISTER: BOLT-INFO: marking chain.cold.0/1(*2) as a fragment of chain/2(*2)
4956

5057
# CHECK-FDATA: 0 [unknown] 0 1 chain/chain.s/2 10 0 1

clang/include/clang/Basic/DiagnosticSemaKinds.td

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13054,6 +13054,11 @@ def err_invalid_hlsl_resource_type: Error<
1305413054
def err_hlsl_spirv_only: Error<"%0 is only available for the SPIR-V target">;
1305513055
def err_hlsl_vk_literal_must_contain_constant: Error<"the argument to vk::Literal must be a vk::integral_constant">;
1305613056

13057+
def err_hlsl_resource_range_overlap: Error<
13058+
"resource ranges %select{t|u|b|s}0[%1;%2] and %select{t|u|b|s}3[%4;%5] "
13059+
"overlap within space = %6 and visibility = "
13060+
"%select{All|Vertex|Hull|Domain|Geometry|Pixel|Amplification|Mesh}7">;
13061+
1305713062
// Layout randomization diagnostics.
1305813063
def err_non_designated_init_used : Error<
1305913064
"a randomized struct can only be initialized with a designated initializer">;

clang/include/clang/Sema/SemaHLSL.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ class SemaHLSL : public SemaBase {
134134
SourceLocation Loc, IdentifierInfo *DeclIdent,
135135
SmallVector<llvm::hlsl::rootsig::RootElement> &Elements);
136136

137+
// Returns true when D is invalid and a diagnostic was produced
138+
bool handleRootSignatureDecl(HLSLRootSignatureDecl *D, SourceLocation Loc);
137139
void handleRootSignatureAttr(Decl *D, const ParsedAttr &AL);
138140
void handleNumThreadsAttr(Decl *D, const ParsedAttr &AL);
139141
void handleWaveSizeAttr(Decl *D, const ParsedAttr &AL);

clang/include/clang/Tooling/DependencyScanning/DependencyScanningFilesystem.h

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ namespace clang {
2323
namespace tooling {
2424
namespace dependencies {
2525

26+
class DependencyScanningService;
27+
2628
using DependencyDirectivesTy =
2729
SmallVector<dependency_directives_scan::Directive, 20>;
2830

@@ -349,7 +351,7 @@ class DependencyScanningWorkerFilesystem
349351
static const char ID;
350352

351353
DependencyScanningWorkerFilesystem(
352-
DependencyScanningFilesystemSharedCache &SharedCache,
354+
DependencyScanningService &Service,
353355
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS);
354356

355357
llvm::ErrorOr<llvm::vfs::Status> status(const Twine &Path) override;
@@ -435,10 +437,7 @@ class DependencyScanningWorkerFilesystem
435437
/// Returns entry associated with the unique ID in the shared cache or nullptr
436438
/// if none is found.
437439
const CachedFileSystemEntry *
438-
findSharedEntryByUID(llvm::vfs::Status Stat) const {
439-
return SharedCache.getShardForUID(Stat.getUniqueID())
440-
.findEntryByUID(Stat.getUniqueID());
441-
}
440+
findSharedEntryByUID(llvm::vfs::Status Stat) const;
442441

443442
/// Associates the given entry with the filename in the local cache and
444443
/// returns it.
@@ -452,20 +451,14 @@ class DependencyScanningWorkerFilesystem
452451
/// some. Otherwise, constructs new one with the given error code, associates
453452
/// it with the filename and returns the result.
454453
const CachedFileSystemEntry &
455-
getOrEmplaceSharedEntryForFilename(StringRef Filename, std::error_code EC) {
456-
return SharedCache.getShardForFilename(Filename)
457-
.getOrEmplaceEntryForFilename(Filename, EC);
458-
}
454+
getOrEmplaceSharedEntryForFilename(StringRef Filename, std::error_code EC);
459455

460456
/// Returns entry associated with the filename in the shared cache if there is
461457
/// some. Otherwise, associates the given entry with the filename and returns
462458
/// it.
463459
const CachedFileSystemEntry &
464460
getOrInsertSharedEntryForFilename(StringRef Filename,
465-
const CachedFileSystemEntry &Entry) {
466-
return SharedCache.getShardForFilename(Filename)
467-
.getOrInsertEntryForFilename(Filename, Entry);
468-
}
461+
const CachedFileSystemEntry &Entry);
469462

470463
void printImpl(raw_ostream &OS, PrintType Type,
471464
unsigned IndentLevel) const override {
@@ -478,8 +471,9 @@ class DependencyScanningWorkerFilesystem
478471
/// VFS.
479472
bool shouldBypass(StringRef Path) const;
480473

481-
/// The global cache shared between worker threads.
482-
DependencyScanningFilesystemSharedCache &SharedCache;
474+
/// The service associated with this VFS.
475+
DependencyScanningService &Service;
476+
483477
/// The local cache is used by the worker thread to cache file system queries
484478
/// locally instead of querying the global cache every time.
485479
DependencyScanningFilesystemLocalCache LocalCache;

clang/include/clang/Tooling/DependencyScanning/DependencyScanningService.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ class DependencyScanningService {
8787
ScanningOptimizations OptimizeArgs = ScanningOptimizations::Default,
8888
bool EagerLoadModules = false, bool TraceVFS = false,
8989
std::time_t BuildSessionTimestamp =
90-
llvm::sys::toTimeT(std::chrono::system_clock::now()));
90+
llvm::sys::toTimeT(std::chrono::system_clock::now()),
91+
bool CacheNegativeStats = true);
9192

9293
ScanningMode getMode() const { return Mode; }
9394

@@ -99,6 +100,8 @@ class DependencyScanningService {
99100

100101
bool shouldTraceVFS() const { return TraceVFS; }
101102

103+
bool shouldCacheNegativeStats() const { return CacheNegativeStats; }
104+
102105
DependencyScanningFilesystemSharedCache &getSharedCache() {
103106
return SharedCache;
104107
}
@@ -116,6 +119,7 @@ class DependencyScanningService {
116119
const bool EagerLoadModules;
117120
/// Whether to trace VFS accesses.
118121
const bool TraceVFS;
122+
const bool CacheNegativeStats;
119123
/// The global file system cache.
120124
DependencyScanningFilesystemSharedCache SharedCache;
121125
/// The global module cache entries.

0 commit comments

Comments
 (0)