Skip to content

Commit 95815a5

Browse files
committed
Merge from 'main' to 'sycl-web' (intel#22)
CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp
2 parents 2e16c13 + e721bc9 commit 95815a5

File tree

159 files changed

+1690
-921
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

+1690
-921
lines changed

clang/include/clang/Basic/CodeGenOptions.h

+13-3
Original file line numberDiff line numberDiff line change
@@ -278,27 +278,37 @@ class CodeGenOptions : public CodeGenOptionsBase {
278278
/// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
279279
std::string SymbolPartition;
280280

281+
/// Regular expression and the string it was created from.
282+
struct RemarkPattern {
283+
std::string Pattern;
284+
std::shared_ptr<llvm::Regex> Regex;
285+
286+
explicit operator bool() const { return Regex != nullptr; }
287+
288+
llvm::Regex *operator->() const { return Regex.get(); }
289+
};
290+
281291
/// Regular expression to select optimizations for which we should enable
282292
/// optimization remarks. Transformation passes whose name matches this
283293
/// expression (and support this feature), will emit a diagnostic
284294
/// whenever they perform a transformation. This is enabled by the
285295
/// -Rpass=regexp flag.
286-
std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
296+
RemarkPattern OptimizationRemarkPattern;
287297

288298
/// Regular expression to select optimizations for which we should enable
289299
/// missed optimization remarks. Transformation passes whose name matches this
290300
/// expression (and support this feature), will emit a diagnostic
291301
/// whenever they tried but failed to perform a transformation. This is
292302
/// enabled by the -Rpass-missed=regexp flag.
293-
std::shared_ptr<llvm::Regex> OptimizationRemarkMissedPattern;
303+
RemarkPattern OptimizationRemarkMissedPattern;
294304

295305
/// Regular expression to select optimizations for which we should enable
296306
/// optimization analyses. Transformation passes whose name matches this
297307
/// expression (and support this feature), will emit a diagnostic
298308
/// whenever they want to explain why they decided to apply or not apply
299309
/// a given transformation. This is enabled by the -Rpass-analysis=regexp
300310
/// flag.
301-
std::shared_ptr<llvm::Regex> OptimizationRemarkAnalysisPattern;
311+
RemarkPattern OptimizationRemarkAnalysisPattern;
302312

303313
/// Set of files defining the rules for the symbol rewriting.
304314
std::vector<std::string> RewriteMapFiles;

clang/include/clang/Basic/Sanitizers.h

+4
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,10 @@ struct SanitizerSet {
178178
/// Returns a non-zero SanitizerMask, or \c 0 if \p Value is not known.
179179
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups);
180180

181+
/// Serialize a SanitizerSet into values for -fsanitize= or -fno-sanitize=.
182+
void serializeSanitizerSet(SanitizerSet Set,
183+
SmallVectorImpl<StringRef> &Values);
184+
181185
/// For each sanitizer group bit set in \p Kinds, set the bits for sanitizers
182186
/// this group enables.
183187
SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);

clang/include/clang/Basic/XRayInstr.h

+5
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,13 @@ struct XRayInstrSet {
6565
XRayInstrMask Mask = 0;
6666
};
6767

68+
/// Parses a command line argument into a mask.
6869
XRayInstrMask parseXRayInstrValue(StringRef Value);
6970

71+
/// Serializes a set into a list of command line arguments.
72+
void serializeXRayInstrValue(XRayInstrSet Set,
73+
SmallVectorImpl<StringRef> &Values);
74+
7075
} // namespace clang
7176

7277
#endif // LLVM_CLANG_BASIC_XRAYINSTR_H

clang/include/clang/Driver/Options.td

+3-10
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,7 @@ def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, Group<f_clang_Group>,
14431443
Flags<[CoreOption, NoXarchOption]>;
14441444
def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
14451445
Group<f_clang_Group>,
1446-
HelpText<"Path to blacklist file for sanitizers">,
1447-
MarshallingInfoStringVector<LangOpts<"SanitizerBlacklistFiles">>;
1446+
HelpText<"Path to blacklist file for sanitizers">;
14481447
def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
14491448
HelpText<"Path to system blacklist file for sanitizers">,
14501449
Flags<[CC1Option]>;
@@ -2181,8 +2180,7 @@ def foffload_static_lib_EQ : CommaJoined<["-"], "foffload-static-lib=">, Flags<[
21812180
def foffload_whole_static_lib_EQ : CommaJoined<["-"], "foffload-whole-static-lib=">, Flags<[NoXarchOption, CoreOption]>, Group<offload_lib_Group>;
21822181
def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;
21832182
def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
2184-
HelpText<"Parse OpenMP pragmas and generate parallel code.">,
2185-
MarshallingInfoFlag<LangOpts<"OpenMP">, "0u">, Normalizer<"makeFlagToValueNormalizer(50u)">;
2183+
HelpText<"Parse OpenMP pragmas and generate parallel code.">;
21862184
def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>;
21872185
def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
21882186
def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;
@@ -4546,12 +4544,7 @@ def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
45464544
//===----------------------------------------------------------------------===//
45474545

45484546
let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
4549-
def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">,
4550-
Values<"line-tables-only,line-directives-only,constructor,limited,standalone,unused-types">,
4551-
NormalizedValuesScope<"codegenoptions">,
4552-
NormalizedValues<["DebugLineTablesOnly", "DebugDirectivesOnly", "DebugInfoConstructor",
4553-
"LimitedDebugInfo", "FullDebugInfo", "UnusedTypeInfo"]>,
4554-
MarshallingInfoString<CodeGenOpts<"DebugInfo">, "NoDebugInfo">, AutoNormalizeEnum;
4547+
def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">;
45554548
def debug_info_macro : Flag<["-"], "debug-info-macro">,
45564549
HelpText<"Emit macro debug information">,
45574550
MarshallingInfoFlag<CodeGenOpts<"MacroDebugInfo">>;

clang/include/clang/Frontend/CompilerInvocation.h

+30-5
Original file line numberDiff line numberDiff line change
@@ -249,18 +249,43 @@ class CompilerInvocation : public CompilerInvocationBase {
249249
DiagnosticsEngine &Diags);
250250

251251
/// Parse command line options that map to LangOptions.
252-
static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
253-
InputKind IK, const llvm::Triple &T,
252+
static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args,
253+
InputKind IK, const llvm::Triple &T,
254+
std::vector<std::string> &Includes,
255+
DiagnosticsEngine &Diags);
256+
257+
static bool ParseLangArgs(CompilerInvocation &Res, LangOptions &Opts,
258+
llvm::opt::ArgList &Args, InputKind IK,
259+
const llvm::Triple &T,
254260
std::vector<std::string> &Includes,
255261
DiagnosticsEngine &Diags);
256262

263+
/// Generate command line options from LangOptions.
264+
static void GenerateLangArgs(const LangOptions &Opts,
265+
SmallVectorImpl<const char *> &Args,
266+
StringAllocator SA, const llvm::Triple &T);
267+
257268
/// Parse command line options that map to CodeGenOptions.
258-
static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
259-
InputKind IK, DiagnosticsEngine &Diags,
260-
const llvm::Triple &T,
269+
static bool ParseCodeGenArgsImpl(CodeGenOptions &Opts,
270+
llvm::opt::ArgList &Args, InputKind IK,
271+
DiagnosticsEngine &Diags,
272+
const llvm::Triple &T,
273+
const std::string &OutputFile,
274+
const LangOptions &LangOptsRef);
275+
276+
static bool ParseCodeGenArgs(CompilerInvocation &Res, CodeGenOptions &Opts,
277+
llvm::opt::ArgList &Args, InputKind IK,
278+
DiagnosticsEngine &Diags, const llvm::Triple &T,
261279
const std::string &OutputFile,
262280
const LangOptions &LangOptsRef);
263281

282+
// Generate command line options from CodeGenOptions.
283+
static void GenerateCodeGenArgs(const CodeGenOptions &Opts,
284+
SmallVectorImpl<const char *> &Args,
285+
StringAllocator SA, const llvm::Triple &T,
286+
const std::string &OutputFile,
287+
const LangOptions *LangOpts);
288+
264289
/// Parse command line options that map to HeaderSearchOptions.
265290
static void ParseHeaderSearchArgs(CompilerInvocation &Res,
266291
HeaderSearchOptions &Opts,

clang/lib/Analysis/CalledOnceCheck.cpp

+24
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "clang/Analysis/AnalysisDeclContext.h"
2323
#include "clang/Analysis/CFG.h"
2424
#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
25+
#include "clang/Basic/Builtins.h"
2526
#include "clang/Basic/IdentifierTable.h"
2627
#include "clang/Basic/LLVM.h"
2728
#include "llvm/ADT/BitVector.h"
@@ -330,6 +331,29 @@ class DeclRefFinder
330331
return Visit(OVE->getSourceExpr());
331332
}
332333

334+
const DeclRefExpr *VisitCallExpr(const CallExpr *CE) {
335+
if (!ShouldRetrieveFromComparisons)
336+
return nullptr;
337+
338+
// We want to see through some of the boolean builtin functions
339+
// that we are likely to see in conditions.
340+
switch (CE->getBuiltinCallee()) {
341+
case Builtin::BI__builtin_expect:
342+
case Builtin::BI__builtin_expect_with_probability: {
343+
assert(CE->getNumArgs() >= 2);
344+
345+
const DeclRefExpr *Candidate = Visit(CE->getArg(0));
346+
return Candidate != nullptr ? Candidate : Visit(CE->getArg(1));
347+
}
348+
349+
case Builtin::BI__builtin_unpredictable:
350+
return Visit(CE->getArg(0));
351+
352+
default:
353+
return nullptr;
354+
}
355+
}
356+
333357
const DeclRefExpr *VisitExpr(const Expr *E) {
334358
// It is a fallback method that gets called whenever the actual type
335359
// of the given expression is not covered.

clang/lib/Basic/Sanitizers.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
#include "clang/Basic/Sanitizers.h"
1414
#include "llvm/ADT/Hashing.h"
15+
#include "llvm/ADT/SmallVector.h"
1516
#include "llvm/ADT/StringSwitch.h"
1617

1718
using namespace clang;
@@ -34,6 +35,14 @@ SanitizerMask clang::parseSanitizerValue(StringRef Value, bool AllowGroups) {
3435
return ParsedKind;
3536
}
3637

38+
void clang::serializeSanitizerSet(SanitizerSet Set,
39+
SmallVectorImpl<StringRef> &Values) {
40+
#define SANITIZER(NAME, ID) \
41+
if (Set.has(SanitizerKind::ID)) \
42+
Values.push_back(NAME);
43+
#include "clang/Basic/Sanitizers.def"
44+
}
45+
3746
SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
3847
#define SANITIZER(NAME, ID)
3948
#define SANITIZER_GROUP(NAME, ID, ALIAS) \

clang/lib/Basic/XRayInstr.cpp

+27
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//===----------------------------------------------------------------------===//
1212

1313
#include "clang/Basic/XRayInstr.h"
14+
#include "llvm/ADT/SmallVector.h"
1415
#include "llvm/ADT/StringSwitch.h"
1516

1617
namespace clang {
@@ -30,4 +31,30 @@ XRayInstrMask parseXRayInstrValue(StringRef Value) {
3031
return ParsedKind;
3132
}
3233

34+
void serializeXRayInstrValue(XRayInstrSet Set,
35+
SmallVectorImpl<StringRef> &Values) {
36+
if (Set.Mask == XRayInstrKind::All) {
37+
Values.push_back("all");
38+
return;
39+
}
40+
41+
if (Set.Mask == XRayInstrKind::None) {
42+
Values.push_back("none");
43+
return;
44+
}
45+
46+
if (Set.has(XRayInstrKind::Custom))
47+
Values.push_back("custom");
48+
49+
if (Set.has(XRayInstrKind::Typed))
50+
Values.push_back("typed");
51+
52+
if (Set.has(XRayInstrKind::FunctionEntry) &&
53+
Set.has(XRayInstrKind::FunctionExit))
54+
Values.push_back("function");
55+
else if (Set.has(XRayInstrKind::FunctionEntry))
56+
Values.push_back("function-entry");
57+
else if (Set.has(XRayInstrKind::FunctionExit))
58+
Values.push_back("function-exit");
59+
}
3360
} // namespace clang

0 commit comments

Comments
 (0)