r252832 - In preparation to use it in more places rename
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Wed Nov 11 16:44:05 PST 2015
Author: echristo
Date: Wed Nov 11 18:44:04 2015
New Revision: 252832
URL: http://llvm.org/viewvc/llvm-project?rev=252832&view=rev
Log:
In preparation to use it in more places rename
checkBuiltinTargetFeatures to checkTargetFeatures and sink
the error handling into the function.
Modified:
cfe/trunk/lib/CodeGen/CGBuiltin.cpp
cfe/trunk/lib/CodeGen/CodeGenFunction.h
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=252832&r1=252831&r2=252832&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Wed Nov 11 18:44:04 2015
@@ -344,24 +344,24 @@ Value *CodeGenFunction::EmitVAStartEnd(V
}
// Returns true if we have a valid set of target features.
-bool CodeGenFunction::checkBuiltinTargetFeatures(
- const FunctionDecl *TargetDecl) {
+void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
+ const FunctionDecl *TargetDecl) {
// Early exit if this is an indirect call.
if (!TargetDecl)
- return true;
+ return;
// Get the current enclosing function if it exists. If it doesn't
// we can't check the target features anyhow.
const FunctionDecl *FD = dyn_cast_or_null<FunctionDecl>(CurFuncDecl);
if (!FD)
- return true;
+ return;
unsigned BuiltinID = TargetDecl->getBuiltinID();
const char *FeatureList =
CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
if (!FeatureList || StringRef(FeatureList) == "")
- return true;
+ return;
llvm::StringMap<bool> FeatureMap;
CGM.getFunctionFeatureMap(FeatureMap, FD);
@@ -370,7 +370,7 @@ bool CodeGenFunction::checkBuiltinTarget
// true, otherwise return false.
SmallVector<StringRef, 1> AttrFeatures;
StringRef(FeatureList).split(AttrFeatures, ",");
- return std::all_of(AttrFeatures.begin(), AttrFeatures.end(),
+ if (!std::all_of(AttrFeatures.begin(), AttrFeatures.end(),
[&](StringRef &Feature) {
SmallVector<StringRef, 1> OrFeatures;
Feature.split(OrFeatures, "|");
@@ -378,7 +378,10 @@ bool CodeGenFunction::checkBuiltinTarget
[&](StringRef &Feature) {
return FeatureMap[Feature];
});
- });
+ }))
+ CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)
+ << TargetDecl->getDeclName()
+ << CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
}
RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
@@ -1969,10 +1972,7 @@ RValue CodeGenFunction::EmitBuiltinExpr(
// This is down here to avoid non-target specific builtins, however, if
// generic builtins start to require generic target features then we
// can move this up to the beginning of the function.
- if (!checkBuiltinTargetFeatures(FD))
- CGM.getDiags().Report(E->getLocStart(), diag::err_builtin_needs_feature)
- << FD->getDeclName()
- << CGM.getContext().BuiltinInfo.getRequiredFeatures(BuiltinID);
+ checkTargetFeatures(E, FD);
// See if we have a target specific intrinsic.
const char *Name = getContext().BuiltinInfo.getName(BuiltinID);
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.h
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.h?rev=252832&r1=252831&r2=252832&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.h (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.h Wed Nov 11 18:44:04 2015
@@ -2638,9 +2638,7 @@ public:
RValue EmitCallExpr(const CallExpr *E,
ReturnValueSlot ReturnValue = ReturnValueSlot());
- void getFunctionFeatureMap(llvm::StringMap<bool> &FeatureMap,
- const FunctionDecl *FD);
- bool checkBuiltinTargetFeatures(const FunctionDecl *TargetDecl);
+ void checkTargetFeatures(const CallExpr *E, const FunctionDecl *TargetDecl);
llvm::CallInst *EmitRuntimeCall(llvm::Value *callee,
const Twine &name = "");
More information about the cfe-commits
mailing list