Skip to content

Commit

Permalink
Merge from 'main' to 'sycl-web' (intel#22)
Browse files Browse the repository at this point in the history
  CONFLICT (content): Merge conflict in clang/lib/Frontend/CompilerInvocation.cpp
  • Loading branch information
dm-vodopyanov committed Feb 13, 2021
2 parents 2e16c13 + e721bc9 commit 95815a5
Show file tree
Hide file tree
Showing 159 changed files with 1,690 additions and 921 deletions.
16 changes: 13 additions & 3 deletions clang/include/clang/Basic/CodeGenOptions.h
Original file line number Diff line number Diff line change
Expand Up @@ -278,27 +278,37 @@ class CodeGenOptions : public CodeGenOptionsBase {
/// -fsymbol-partition (see https://lld.llvm.org/Partitions.html).
std::string SymbolPartition;

/// Regular expression and the string it was created from.
struct RemarkPattern {
std::string Pattern;
std::shared_ptr<llvm::Regex> Regex;

explicit operator bool() const { return Regex != nullptr; }

llvm::Regex *operator->() const { return Regex.get(); }
};

/// Regular expression to select optimizations for which we should enable
/// optimization remarks. Transformation passes whose name matches this
/// expression (and support this feature), will emit a diagnostic
/// whenever they perform a transformation. This is enabled by the
/// -Rpass=regexp flag.
std::shared_ptr<llvm::Regex> OptimizationRemarkPattern;
RemarkPattern OptimizationRemarkPattern;

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

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

/// Set of files defining the rules for the symbol rewriting.
std::vector<std::string> RewriteMapFiles;
Expand Down
4 changes: 4 additions & 0 deletions clang/include/clang/Basic/Sanitizers.h
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,10 @@ struct SanitizerSet {
/// Returns a non-zero SanitizerMask, or \c 0 if \p Value is not known.
SanitizerMask parseSanitizerValue(StringRef Value, bool AllowGroups);

/// Serialize a SanitizerSet into values for -fsanitize= or -fno-sanitize=.
void serializeSanitizerSet(SanitizerSet Set,
SmallVectorImpl<StringRef> &Values);

/// For each sanitizer group bit set in \p Kinds, set the bits for sanitizers
/// this group enables.
SanitizerMask expandSanitizerGroups(SanitizerMask Kinds);
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Basic/XRayInstr.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,8 +65,13 @@ struct XRayInstrSet {
XRayInstrMask Mask = 0;
};

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

/// Serializes a set into a list of command line arguments.
void serializeXRayInstrValue(XRayInstrSet Set,
SmallVectorImpl<StringRef> &Values);

} // namespace clang

#endif // LLVM_CLANG_BASIC_XRAYINSTR_H
13 changes: 3 additions & 10 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -1443,8 +1443,7 @@ def fno_sanitize_EQ : CommaJoined<["-"], "fno-sanitize=">, Group<f_clang_Group>,
Flags<[CoreOption, NoXarchOption]>;
def fsanitize_blacklist : Joined<["-"], "fsanitize-blacklist=">,
Group<f_clang_Group>,
HelpText<"Path to blacklist file for sanitizers">,
MarshallingInfoStringVector<LangOpts<"SanitizerBlacklistFiles">>;
HelpText<"Path to blacklist file for sanitizers">;
def fsanitize_system_blacklist : Joined<["-"], "fsanitize-system-blacklist=">,
HelpText<"Path to system blacklist file for sanitizers">,
Flags<[CC1Option]>;
Expand Down Expand Up @@ -2181,8 +2180,7 @@ def foffload_static_lib_EQ : CommaJoined<["-"], "foffload-static-lib=">, Flags<[
def foffload_whole_static_lib_EQ : CommaJoined<["-"], "foffload-whole-static-lib=">, Flags<[NoXarchOption, CoreOption]>, Group<offload_lib_Group>;
def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group<f_Group>;
def fopenmp : Flag<["-"], "fopenmp">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>,
HelpText<"Parse OpenMP pragmas and generate parallel code.">,
MarshallingInfoFlag<LangOpts<"OpenMP">, "0u">, Normalizer<"makeFlagToValueNormalizer(50u)">;
HelpText<"Parse OpenMP pragmas and generate parallel code.">;
def fno_openmp : Flag<["-"], "fno-openmp">, Group<f_Group>, Flags<[NoArgumentUnused]>;
def fopenmp_version_EQ : Joined<["-"], "fopenmp-version=">, Group<f_Group>, Flags<[CC1Option, NoArgumentUnused]>;
def fopenmp_EQ : Joined<["-"], "fopenmp=">, Group<f_Group>;
Expand Down Expand Up @@ -4546,12 +4544,7 @@ def migrator_no_finalize_removal : Flag<["-"], "no-finalize-removal">,
//===----------------------------------------------------------------------===//

let Flags = [CC1Option, CC1AsOption, NoDriverOption] in {
def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">,
Values<"line-tables-only,line-directives-only,constructor,limited,standalone,unused-types">,
NormalizedValuesScope<"codegenoptions">,
NormalizedValues<["DebugLineTablesOnly", "DebugDirectivesOnly", "DebugInfoConstructor",
"LimitedDebugInfo", "FullDebugInfo", "UnusedTypeInfo"]>,
MarshallingInfoString<CodeGenOpts<"DebugInfo">, "NoDebugInfo">, AutoNormalizeEnum;
def debug_info_kind_EQ : Joined<["-"], "debug-info-kind=">;
def debug_info_macro : Flag<["-"], "debug-info-macro">,
HelpText<"Emit macro debug information">,
MarshallingInfoFlag<CodeGenOpts<"MacroDebugInfo">>;
Expand Down
35 changes: 30 additions & 5 deletions clang/include/clang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -249,18 +249,43 @@ class CompilerInvocation : public CompilerInvocationBase {
DiagnosticsEngine &Diags);

/// Parse command line options that map to LangOptions.
static bool ParseLangArgs(LangOptions &Opts, llvm::opt::ArgList &Args,
InputKind IK, const llvm::Triple &T,
static bool ParseLangArgsImpl(LangOptions &Opts, llvm::opt::ArgList &Args,
InputKind IK, const llvm::Triple &T,
std::vector<std::string> &Includes,
DiagnosticsEngine &Diags);

static bool ParseLangArgs(CompilerInvocation &Res, LangOptions &Opts,
llvm::opt::ArgList &Args, InputKind IK,
const llvm::Triple &T,
std::vector<std::string> &Includes,
DiagnosticsEngine &Diags);

/// Generate command line options from LangOptions.
static void GenerateLangArgs(const LangOptions &Opts,
SmallVectorImpl<const char *> &Args,
StringAllocator SA, const llvm::Triple &T);

/// Parse command line options that map to CodeGenOptions.
static bool ParseCodeGenArgs(CodeGenOptions &Opts, llvm::opt::ArgList &Args,
InputKind IK, DiagnosticsEngine &Diags,
const llvm::Triple &T,
static bool ParseCodeGenArgsImpl(CodeGenOptions &Opts,
llvm::opt::ArgList &Args, InputKind IK,
DiagnosticsEngine &Diags,
const llvm::Triple &T,
const std::string &OutputFile,
const LangOptions &LangOptsRef);

static bool ParseCodeGenArgs(CompilerInvocation &Res, CodeGenOptions &Opts,
llvm::opt::ArgList &Args, InputKind IK,
DiagnosticsEngine &Diags, const llvm::Triple &T,
const std::string &OutputFile,
const LangOptions &LangOptsRef);

// Generate command line options from CodeGenOptions.
static void GenerateCodeGenArgs(const CodeGenOptions &Opts,
SmallVectorImpl<const char *> &Args,
StringAllocator SA, const llvm::Triple &T,
const std::string &OutputFile,
const LangOptions *LangOpts);

/// Parse command line options that map to HeaderSearchOptions.
static void ParseHeaderSearchArgs(CompilerInvocation &Res,
HeaderSearchOptions &Opts,
Expand Down
24 changes: 24 additions & 0 deletions clang/lib/Analysis/CalledOnceCheck.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "clang/Analysis/AnalysisDeclContext.h"
#include "clang/Analysis/CFG.h"
#include "clang/Analysis/FlowSensitive/DataflowWorklist.h"
#include "clang/Basic/Builtins.h"
#include "clang/Basic/IdentifierTable.h"
#include "clang/Basic/LLVM.h"
#include "llvm/ADT/BitVector.h"
Expand Down Expand Up @@ -330,6 +331,29 @@ class DeclRefFinder
return Visit(OVE->getSourceExpr());
}

const DeclRefExpr *VisitCallExpr(const CallExpr *CE) {
if (!ShouldRetrieveFromComparisons)
return nullptr;

// We want to see through some of the boolean builtin functions
// that we are likely to see in conditions.
switch (CE->getBuiltinCallee()) {
case Builtin::BI__builtin_expect:
case Builtin::BI__builtin_expect_with_probability: {
assert(CE->getNumArgs() >= 2);

const DeclRefExpr *Candidate = Visit(CE->getArg(0));
return Candidate != nullptr ? Candidate : Visit(CE->getArg(1));
}

case Builtin::BI__builtin_unpredictable:
return Visit(CE->getArg(0));

default:
return nullptr;
}
}

const DeclRefExpr *VisitExpr(const Expr *E) {
// It is a fallback method that gets called whenever the actual type
// of the given expression is not covered.
Expand Down
9 changes: 9 additions & 0 deletions clang/lib/Basic/Sanitizers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

#include "clang/Basic/Sanitizers.h"
#include "llvm/ADT/Hashing.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSwitch.h"

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

void clang::serializeSanitizerSet(SanitizerSet Set,
SmallVectorImpl<StringRef> &Values) {
#define SANITIZER(NAME, ID) \
if (Set.has(SanitizerKind::ID)) \
Values.push_back(NAME);
#include "clang/Basic/Sanitizers.def"
}

SanitizerMask clang::expandSanitizerGroups(SanitizerMask Kinds) {
#define SANITIZER(NAME, ID)
#define SANITIZER_GROUP(NAME, ID, ALIAS) \
Expand Down
27 changes: 27 additions & 0 deletions clang/lib/Basic/XRayInstr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
//===----------------------------------------------------------------------===//

#include "clang/Basic/XRayInstr.h"
#include "llvm/ADT/SmallVector.h"
#include "llvm/ADT/StringSwitch.h"

namespace clang {
Expand All @@ -30,4 +31,30 @@ XRayInstrMask parseXRayInstrValue(StringRef Value) {
return ParsedKind;
}

void serializeXRayInstrValue(XRayInstrSet Set,
SmallVectorImpl<StringRef> &Values) {
if (Set.Mask == XRayInstrKind::All) {
Values.push_back("all");
return;
}

if (Set.Mask == XRayInstrKind::None) {
Values.push_back("none");
return;
}

if (Set.has(XRayInstrKind::Custom))
Values.push_back("custom");

if (Set.has(XRayInstrKind::Typed))
Values.push_back("typed");

if (Set.has(XRayInstrKind::FunctionEntry) &&
Set.has(XRayInstrKind::FunctionExit))
Values.push_back("function");
else if (Set.has(XRayInstrKind::FunctionEntry))
Values.push_back("function-entry");
else if (Set.has(XRayInstrKind::FunctionExit))
Values.push_back("function-exit");
}
} // namespace clang
Loading

0 comments on commit 95815a5

Please sign in to comment.