17#include "llvm/ADT/StringMap.h"
23 if (CGOpts.DisableLifetimeMarkers)
27 if (CGOpts.SanitizeAddressUseAfterScope ||
34 return CGOpts.OptimizationLevel != 0;
47 if (BuiltinID == X86::BI__builtin_ia32_cmpps ||
48 BuiltinID == X86::BI__builtin_ia32_cmpss ||
49 BuiltinID == X86::BI__builtin_ia32_cmppd ||
50 BuiltinID == X86::BI__builtin_ia32_cmpsd) {
51 llvm::StringMap<bool> TargetFeatureMap;
53 llvm::APSInt
Result = *(E->
getArg(2)->getIntegerConstantExpr(Ctx));
54 if (
Result.getSExtValue() > 7 && !TargetFeatureMap.lookup(
"avx"))
69 if (!TargetDecl || !Caller)
72 bool IsAlwaysInline = TargetDecl->
hasAttr<AlwaysInlineAttr>();
73 bool IsFlatten = Caller->
hasAttr<FlattenAttr>();
76 std::string MissingFeature;
77 llvm::StringMap<bool> CallerFeatureMap;
83 bool IsHipStdPar = LangOpts.HIPStdPar && LangOpts.CUDAIsDevice;
89 Diags.
Report(Loc, diag::err_builtin_needs_feature)
92 TargetDecl->
hasAttr<TargetAttr>()) {
94 const TargetAttr *TD = TargetDecl->
getAttr<TargetAttr>();
98 llvm::StringMap<bool> CalleeFeatureMap;
102 if (F[0] ==
'+' && CalleeFeatureMap.lookup(F.substr(1)))
103 ReqFeatures.push_back(StringRef(F).substr(1));
105 for (
const auto &F : CalleeFeatureMap) {
107 ReqFeatures.push_back(F.getKey());
109 if (!llvm::all_of(ReqFeatures,
111 if (!CallerFeatureMap.lookup(
Feature)) {
112 MissingFeature =
Feature.str();
119 Diags.
Report(Loc, diag::err_function_needs_feature)
123 Diags.
Report(Loc, diag::err_flatten_function_needs_feature)
128 llvm::StringMap<bool> CalleeFeatureMap;
131 for (
const auto &F : CalleeFeatureMap) {
133 (!CallerFeatureMap.lookup(F.getKey()) ||
134 !CallerFeatureMap.find(F.getKey())->getValue()) &&
137 Diags.
Report(Loc, diag::err_function_needs_feature)
141 Diags.
Report(Loc, diag::err_flatten_function_needs_feature)
Defines the clang::ASTContext interface.
Defines enum values for all the target-independent builtin functions.
Enumerates target-specific builtins in their own namespaces within namespace clang.
Holds long-lived AST nodes (such as types and decls) that can be referred to throughout the semantic ...
ParsedTargetAttr filterFunctionTargetAttrs(const TargetAttr *TD) const
Parses the target attributes passed in, and returns only the ones that are valid feature names.
Builtin::Context & BuiltinInfo
const TargetInfo & getTargetInfo() const
void getFunctionFeatureMap(llvm::StringMap< bool > &FeatureMap, const FunctionDecl *) const
const char * getRequiredFeatures(unsigned ID) const
CallExpr - Represents a function call (C99 6.5.2.2, C++ [expr.call]).
Expr * getArg(unsigned Arg)
getArg - Return the specified argument.
SourceLocation getBeginLoc() const
CodeGenOptions - Track various options which control how the code is optimized and passed to the back...
Concrete class used by the front-end to report problems and issues.
DiagnosticBuilder Report(SourceLocation Loc, unsigned DiagID)
Issue the message to the client.
Represents a function declaration or definition.
bool isMultiVersion() const
True if this function is considered a multiversioned function.
unsigned getBuiltinID(bool ConsiderWrapperFunctions=false) const
Returns a value indicating whether this function corresponds to a builtin function.
Keeps track of the various options that can be enabled, which controls the dialect of C or C++ that i...
SanitizerSet Sanitize
Set of enabled sanitizers.
DeclarationName getDeclName() const
Get the actual, stored name of the declaration, which may be a special name.
ParsedAttr - Represents a syntactic attribute.
Encodes a location in the source.
const llvm::Triple & getTriple() const
Returns the target triple of the primary target.
Defines the clang::TargetInfo interface.
bool evaluateRequiredTargetFeatures(llvm::StringRef RequiredFatures, const llvm::StringMap< bool > &TargetFetureMap)
Returns true if the required target features of a builtin function are enabled.
bool shouldEmitLifetimeMarkers(const CodeGenOptions &CGOpts, const LangOptions &LangOpts)
Decide whether we need to emit the lifetime markers.
void checkTargetFeatures(ASTContext &Ctx, DiagnosticsEngine &Diags, const LangOptions &LangOpts, const CallExpr *E, const FunctionDecl *Caller, const FunctionDecl *TargetDecl)
Check that a call to a target-specific builtin has the required target features enabled in the caller...
@ Result
The result type of a method or function.
Contains information gathered from parsing the contents of TargetAttr.
bool has(SanitizerMask K) const
Check if a certain (single) sanitizer is enabled.