Skip to content

Commit ac3d26e

Browse files
SC llvm teamSC llvm team
authored andcommitted
Merge upstream LLVM into amd-gfx12
2 parents a8dd6cf + 4ae9fdc commit ac3d26e

File tree

203 files changed

+9238
-5923
lines changed

Some content is hidden

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

203 files changed

+9238
-5923
lines changed

bolt/utils/nfc-check-setup.py

Lines changed: 31 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
import sys
88
import textwrap
99

10+
msg_prefix = "\n> NFC-Mode:"
11+
1012
def get_relevant_bolt_changes(dir: str) -> str:
1113
# Return a list of bolt source changes that are relevant to testing.
1214
all_changes = subprocess.run(
@@ -49,7 +51,7 @@ def switch_back(
4951
# the HEAD is. Must be called after checking out the previous commit on all
5052
# exit paths.
5153
if switch_back:
52-
print("Switching back to current revision..")
54+
print(f"{msg_prefix} Switching back to current revision..")
5355
if stash:
5456
subprocess.run(shlex.split("git stash pop"), cwd=source_dir)
5557
subprocess.run(shlex.split(f"git checkout {old_ref}"), cwd=source_dir)
@@ -64,8 +66,10 @@ def main():
6466
parser = argparse.ArgumentParser(
6567
description=textwrap.dedent(
6668
"""
67-
This script builds two versions of BOLT (with the current and
68-
previous revision).
69+
This script builds two versions of BOLT:
70+
llvm-bolt.new, using the current revision, and llvm-bolt.old using
71+
the previous revision. These can be used to check whether the
72+
current revision changes BOLT's functional behavior.
6973
"""
7074
)
7175
)
@@ -104,7 +108,7 @@ def main():
104108
if not args.create_wrapper and len(wrapper_args) > 0:
105109
parser.parse_args()
106110

107-
# find the repo directory
111+
# Find the repo directory.
108112
source_dir = None
109113
try:
110114
CMCacheFilename = f"{args.build_dir}/CMakeCache.txt"
@@ -118,23 +122,22 @@ def main():
118122
except Exception as e:
119123
sys.exit(e)
120124

121-
# clean the previous llvm-bolt if it exists
125+
# Clean the previous llvm-bolt if it exists.
122126
bolt_path = f"{args.build_dir}/bin/llvm-bolt"
123127
if os.path.exists(bolt_path):
124128
os.remove(bolt_path)
125129

126-
# build the current commit
127-
print("NFC-Setup: Building current revision..")
130+
# Build the current commit.
131+
print(f"{msg_prefix} Building current revision..")
128132
subprocess.run(
129133
shlex.split("cmake --build . --target llvm-bolt"), cwd=args.build_dir
130134
)
131135

132136
if not os.path.exists(bolt_path):
133137
sys.exit(f"Failed to build the current revision: '{bolt_path}'")
134138

135-
# rename llvm-bolt
139+
# Rename llvm-bolt and memorize the old hash for logging.
136140
os.replace(bolt_path, f"{bolt_path}.new")
137-
# memorize the old hash for logging
138141
old_ref = get_git_ref_or_rev(source_dir)
139142

140143
if args.check_bolt_sources:
@@ -147,7 +150,7 @@ def main():
147150
print(f"BOLT source changes were found:\n{file_changes}")
148151
open(marker, "a").close()
149152

150-
# determine whether a stash is needed
153+
# Determine whether a stash is needed.
151154
stash = subprocess.run(
152155
shlex.split("git status --porcelain"),
153156
cwd=source_dir,
@@ -156,40 +159,40 @@ def main():
156159
text=True,
157160
).stdout
158161
if stash:
159-
# save local changes before checkout
162+
# Save local changes before checkout.
160163
subprocess.run(shlex.split("git stash push -u"), cwd=source_dir)
161-
# check out the previous/cmp commit
164+
165+
# Check out the previous/cmp commit and get its commit hash for logging.
162166
subprocess.run(shlex.split(f"git checkout -f {args.cmp_rev}"), cwd=source_dir)
163-
# get the parent commit hash for logging
164167
new_ref = get_git_ref_or_rev(source_dir)
165168

166-
# build the previous commit
167-
print("NFC-Setup: Building previous revision..")
169+
# Build the previous commit.
170+
print(f"{msg_prefix} Building previous revision..")
168171
subprocess.run(
169172
shlex.split("cmake --build . --target llvm-bolt"), cwd=args.build_dir
170173
)
171174

172-
# rename llvm-bolt
175+
# Rename llvm-bolt.
173176
if not os.path.exists(bolt_path):
174177
print(f"Failed to build the previous revision: '{bolt_path}'")
175178
switch_back(args.switch_back, stash, source_dir, old_ref, new_ref)
176179
sys.exit(1)
177180
os.replace(bolt_path, f"{bolt_path}.old")
178181

179-
# symlink llvm-bolt-wrapper
182+
# Symlink llvm-bolt-wrapper
180183
if args.create_wrapper:
184+
print(f"{msg_prefix} Creating llvm-bolt wrapper..")
181185
script_dir = os.path.dirname(os.path.abspath(__file__))
182186
wrapper_path = f"{script_dir}/llvm-bolt-wrapper.py"
183187
try:
184-
# set up llvm-bolt-wrapper.ini
188+
# Set up llvm-bolt-wrapper.ini
185189
ini = subprocess.check_output(
186190
shlex.split(f"{wrapper_path} {bolt_path}.old {bolt_path}.new")
187191
+ wrapper_args,
188192
text=True,
189193
)
190194
with open(f"{args.build_dir}/bin/llvm-bolt-wrapper.ini", "w") as f:
191195
f.write(ini)
192-
# symlink llvm-bolt-wrapper
193196
os.symlink(wrapper_path, bolt_path)
194197
except Exception as e:
195198
print("Failed to create a wrapper:\n" + str(e))
@@ -199,11 +202,17 @@ def main():
199202
switch_back(args.switch_back, stash, source_dir, old_ref, new_ref)
200203

201204
print(
202-
f"Build directory {args.build_dir} is ready to run BOLT tests, e.g.\n"
203-
"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
204-
"\tbin/llvm-lit -sv tools/bolttests"
205+
f"{msg_prefix} Completed!\nBuild directory {args.build_dir} is ready for"
206+
" NFC-Mode comparison between the two revisions."
205207
)
206208

209+
if args.create_wrapper:
210+
print(
211+
"Can run BOLT tests using:\n"
212+
"\tbin/llvm-lit -sv tools/bolt/test\nor\n"
213+
"\tbin/llvm-lit -sv tools/bolttests"
214+
)
215+
207216

208217
if __name__ == "__main__":
209218
main()

clang/cmake/caches/Fuchsia-stage2-instrumented.cmake

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,3 +43,6 @@ set(CLANG_BOOTSTRAP_CMAKE_ARGS
4343
${EXTRA_ARGS}
4444
-C ${CMAKE_CURRENT_LIST_DIR}/Fuchsia-stage2.cmake
4545
CACHE STRING "")
46+
47+
# Do not use LLVM build for generating PGO data.
48+
set(CLANG_PGO_TRAINING_USE_LLVM_BUILD OFF CACHE BOOL "")

clang/include/clang/Basic/Diagnostic.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,10 @@ class DiagnosticsEngine : public RefCountedBase<DiagnosticsEngine> {
895895
/// \param FormatString A fixed diagnostic format string that will be hashed
896896
/// and mapped to a unique DiagID.
897897
template <unsigned N>
898-
// TODO: Deprecate this once all uses are removed from Clang.
898+
// FIXME: this API should almost never be used; custom diagnostics do not
899+
// have an associated diagnostic group and thus cannot be controlled by users
900+
// like other diagnostics. The number of times this API is used in Clang
901+
// should only ever be reduced, not increased.
899902
// [[deprecated("Use a CustomDiagDesc instead of a Level")]]
900903
unsigned getCustomDiagID(Level L, const char (&FormatString)[N]) {
901904
return Diags->getCustomDiagID((DiagnosticIDs::Level)L,

clang/include/clang/Basic/DiagnosticIDs.h

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,10 @@ class DiagnosticIDs : public RefCountedBase<DiagnosticIDs> {
283283
// writing, nearly all callers of this function were invalid.
284284
unsigned getCustomDiagID(CustomDiagDesc Diag);
285285

286-
// TODO: Deprecate this once all uses are removed from LLVM
286+
// FIXME: this API should almost never be used; custom diagnostics do not
287+
// have an associated diagnostic group and thus cannot be controlled by users
288+
// like other diagnostics. The number of times this API is used in Clang
289+
// should only ever be reduced, not increased.
287290
// [[deprecated("Use a CustomDiagDesc instead of a Level")]]
288291
unsigned getCustomDiagID(Level Level, StringRef Message) {
289292
return getCustomDiagID([&]() -> CustomDiagDesc {

clang/include/clang/Sema/Sema.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,13 @@ enum class CCEKind {
834834
///< message.
835835
};
836836

837+
/// Enums for the diagnostics of target, target_version and target_clones.
838+
namespace DiagAttrParams {
839+
enum DiagType { Unsupported, Duplicate, Unknown };
840+
enum Specifier { None, CPU, Tune };
841+
enum AttrName { Target, TargetClones, TargetVersion };
842+
} // end namespace DiagAttrParams
843+
837844
void inferNoReturnAttr(Sema &S, const Decl *D);
838845

839846
/// Sema - This implements semantic analysis and AST building for C.
@@ -4922,13 +4929,6 @@ class Sema final : public SemaBase {
49224929
// handled later in the process, once we know how many exist.
49234930
bool checkTargetAttr(SourceLocation LiteralLoc, StringRef Str);
49244931

4925-
/// Check Target Version attrs
4926-
bool checkTargetVersionAttr(SourceLocation Loc, Decl *D, StringRef Str);
4927-
bool checkTargetClonesAttrString(
4928-
SourceLocation LiteralLoc, StringRef Str, const StringLiteral *Literal,
4929-
Decl *D, bool &HasDefault, bool &HasCommas, bool &HasNotDefault,
4930-
SmallVectorImpl<SmallString<64>> &StringsBuffer);
4931-
49324932
ErrorAttr *mergeErrorAttr(Decl *D, const AttributeCommonInfo &CI,
49334933
StringRef NewUserDiagnostic);
49344934
FormatAttr *mergeFormatAttr(Decl *D, const AttributeCommonInfo &CI,

clang/include/clang/Sema/SemaARM.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ class SemaARM : public SemaBase {
9191
/// Return true if the given vector types are lax-compatible SVE vector types,
9292
/// false otherwise.
9393
bool areLaxCompatibleSveTypes(QualType FirstType, QualType SecondType);
94+
95+
bool checkTargetVersionAttr(const StringRef Str, const SourceLocation Loc);
96+
bool checkTargetClonesAttr(SmallVectorImpl<StringRef> &Params,
97+
SmallVectorImpl<SourceLocation> &Locs,
98+
SmallVectorImpl<SmallString<64>> &NewParams);
9499
};
95100

96101
SemaARM::ArmStreamingType getArmStreamingFnType(const FunctionDecl *FD);

clang/include/clang/Sema/SemaRISCV.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,11 @@ class SemaRISCV : public SemaBase {
5555
bool DeclareAndesVectorBuiltins = false;
5656

5757
std::unique_ptr<sema::RISCVIntrinsicManager> IntrinsicManager;
58+
59+
bool checkTargetVersionAttr(const StringRef Param, const SourceLocation Loc);
60+
bool checkTargetClonesAttr(SmallVectorImpl<StringRef> &Params,
61+
SmallVectorImpl<SourceLocation> &Locs,
62+
SmallVectorImpl<SmallString<64>> &NewParams);
5863
};
5964

6065
std::unique_ptr<sema::RISCVIntrinsicManager>

clang/include/clang/Sema/SemaX86.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ class SemaX86 : public SemaBase {
3737

3838
void handleAnyInterruptAttr(Decl *D, const ParsedAttr &AL);
3939
void handleForceAlignArgPointerAttr(Decl *D, const ParsedAttr &AL);
40+
41+
bool checkTargetClonesAttr(SmallVectorImpl<StringRef> &Params,
42+
SmallVectorImpl<SourceLocation> &Locs,
43+
SmallVectorImpl<SmallString<64>> &NewParams);
4044
};
4145
} // namespace clang
4246

clang/include/clang/StaticAnalyzer/Frontend/CheckerRegistry.h

Lines changed: 29 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -38,29 +38,29 @@
3838
// function clang_registerCheckers. For example:
3939
//
4040
// extern "C"
41-
// void clang_registerCheckers (CheckerRegistry &registry) {
42-
// registry.addChecker<MainCallChecker>("example.MainCallChecker",
43-
// "Disallows calls to functions called main");
41+
// void clang_registerCheckers(CheckerRegistry &Registry) {
42+
// Registry.addChecker<MainCallChecker>(
43+
// "example.MainCallChecker",
44+
// "Disallows calls to functions called main");
4445
// }
4546
//
46-
// The first method argument is the full name of the checker, including its
47-
// enclosing package. By convention, the registered name of a checker is the
48-
// name of the associated class (the template argument).
49-
// The second method argument is a short human-readable description of the
50-
// checker.
47+
// The first argument of this templated method is the full name of the checker
48+
// (including its package), while the second argument is a short description
49+
// that is printed by `-analyzer-checker-help`.
5150
//
52-
// The clang_registerCheckers function may add any number of checkers to the
53-
// registry. If any checkers require additional initialization, use the three-
54-
// argument form of CheckerRegistry::addChecker.
51+
// A plugin may register several separate checkers by calling `addChecker()`
52+
// multiple times. If a checker requires custom registration functions (e.g.
53+
// checker option handling) use the non-templated overload of `addChecker` that
54+
// takes two callback functions as the first two parameters.
5555
//
5656
// To load a checker plugin, specify the full path to the dynamic library as
5757
// the argument to the -load option in the cc1 frontend. You can then enable
5858
// your custom checker using the -analyzer-checker:
5959
//
60-
// clang -cc1 -load </path/to/plugin.dylib> -analyze
61-
// -analyzer-checker=<example.MainCallChecker>
60+
// clang -cc1 -load /path/to/plugin.dylib -analyze
61+
// -analyzer-checker=example.MainCallChecker
6262
//
63-
// For a complete working example, see examples/analyzer-plugin.
63+
// For complete examples, see clang/lib/Analysis/plugins/SampleAnalyzer
6464

6565
#ifndef CLANG_ANALYZER_API_VERSION_STRING
6666
// FIXME: The Clang version string is not particularly granular;
@@ -108,30 +108,25 @@ class CheckerRegistry {
108108
mgr.template registerChecker<T>();
109109
}
110110

111-
template <typename T> static bool returnTrue(const CheckerManager &mgr) {
112-
return true;
113-
}
111+
static bool returnTrue(const CheckerManager &) { return true; }
114112

115113
public:
116-
/// Adds a checker to the registry. Use this non-templated overload when your
117-
/// checker requires custom initialization.
118-
void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction sfn,
119-
StringRef FullName, StringRef Desc, StringRef DocsUri,
120-
bool IsHidden);
121-
122-
/// Adds a checker to the registry. Use this templated overload when your
123-
/// checker does not require any custom initialization.
124-
/// This function isn't really needed and probably causes more headaches than
125-
/// the tiny convenience that it provides, but external plugins might use it,
126-
/// and there isn't a strong incentive to remove it.
114+
/// Adds a checker to the registry.
115+
/// Use this for a checker defined in a plugin if it requires custom
116+
/// registration functions (e.g. for handling checker options).
117+
/// NOTE: As of now `DocsUri` is never queried from the checker registry.
118+
void addChecker(RegisterCheckerFn Fn, ShouldRegisterFunction Sfn,
119+
StringRef FullName, StringRef Desc,
120+
StringRef DocsUri = "NoDocsUri", bool IsHidden = false);
121+
122+
/// Adds a checker to the registry.
123+
/// Use this for a checker defined in a plugin if it doesn't require custom
124+
/// registration functions.
127125
template <class T>
128-
void addChecker(StringRef FullName, StringRef Desc, StringRef DocsUri,
129-
bool IsHidden = false) {
130-
// Avoid MSVC's Compiler Error C2276:
131-
// http://msdn.microsoft.com/en-us/library/850cstw1(v=VS.80).aspx
126+
void addChecker(StringRef FullName, StringRef Desc,
127+
StringRef DocsUri = "NoDocsUri", bool IsHidden = false) {
132128
addChecker(&CheckerRegistry::initializeManager<CheckerManager, T>,
133-
&CheckerRegistry::returnTrue<T>, FullName, Desc, DocsUri,
134-
IsHidden);
129+
&CheckerRegistry::returnTrue, FullName, Desc, DocsUri, IsHidden);
135130
}
136131

137132
/// Makes the checker with the full name \p fullName depend on the checker

clang/lib/AST/TextNodeDumper.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,10 @@ void TextNodeDumper::Visit(const APValue &Value, QualType Ty) {
843843
}
844844

845845
ColorScope Color(OS, ShowColors, DeclNameColor);
846-
OS << Value.getMemberPointerDecl()->getDeclName();
846+
if (const ValueDecl *MemDecl = Value.getMemberPointerDecl())
847+
OS << MemDecl->getDeclName();
848+
else
849+
OS << "null";
847850
return;
848851
}
849852
case APValue::AddrLabelDiff:

0 commit comments

Comments
 (0)