summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEric Christopher <echristo@gmail.com>2015-11-16 18:29:59 +0000
committerEric Christopher <echristo@gmail.com>2015-11-16 18:29:59 +0000
commitb7bbc5331470b7dc0fb8d5c0154f8f39372583f1 (patch)
tree7a98abd23b767fa8c4ec1d31a73b81ef6b4f10df
parent2de9f545aaacd81846d75c3123b06b27e177e4e5 (diff)
downloadbcm5719-llvm-b7bbc5331470b7dc0fb8d5c0154f8f39372583f1.tar.gz
bcm5719-llvm-b7bbc5331470b7dc0fb8d5c0154f8f39372583f1.zip
When producing error messages for always_inline functions with the
target attribute, don't include "negative" subtarget features in the list of required features. Builtins are positive by default so don't need this change, but we pull the default list of features from the command line and so need to make sure that we only include features that are turned on for code generation in our error. llvm-svn: 253242
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.cpp7
-rw-r--r--clang/test/CodeGen/target-features-no-error.c9
2 files changed, 14 insertions, 2 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp
index a425c3e229a..4c1d6af7530 100644
--- a/clang/lib/CodeGen/CodeGenFunction.cpp
+++ b/clang/lib/CodeGen/CodeGenFunction.cpp
@@ -1917,8 +1917,11 @@ void CodeGenFunction::checkTargetFeatures(const CallExpr *E,
SmallVector<StringRef, 1> ReqFeatures;
llvm::StringMap<bool> CalleeFeatureMap;
CGM.getFunctionFeatureMap(CalleeFeatureMap, TargetDecl);
- for (const auto &F : CalleeFeatureMap)
- ReqFeatures.push_back(F.getKey());
+ for (const auto &F : CalleeFeatureMap) {
+ // Only positive features are "required".
+ if (F.getValue())
+ ReqFeatures.push_back(F.getKey());
+ }
if (!hasRequiredFeatures(ReqFeatures, CGM, FD, MissingFeature))
CGM.getDiags().Report(E->getLocStart(), diag::err_function_needs_feature)
<< FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
diff --git a/clang/test/CodeGen/target-features-no-error.c b/clang/test/CodeGen/target-features-no-error.c
new file mode 100644
index 00000000000..b6283b65ec5
--- /dev/null
+++ b/clang/test/CodeGen/target-features-no-error.c
@@ -0,0 +1,9 @@
+// RUN: %clang_cc1 %s -triple=x86_64-linux-gnu -emit-llvm -o - -target-feature -sse2
+
+// Verify that negative features don't cause additional requirements on the inline function.
+int __attribute__((target("sse"), always_inline)) foo(int a) {
+ return a + 4;
+}
+int bar() {
+ return foo(4); // expected-no-diagnostics
+}
OpenPOWER on IntegriCloud