r253242 - When producing error messages for always_inline functions with the
Eric Christopher via cfe-commits
cfe-commits at lists.llvm.org
Mon Nov 16 10:30:00 PST 2015
Author: echristo
Date: Mon Nov 16 12:29:59 2015
New Revision: 253242
URL: http://llvm.org/viewvc/llvm-project?rev=253242&view=rev
Log:
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.
Added:
cfe/trunk/test/CodeGen/target-features-no-error.c
Modified:
cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenFunction.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenFunction.cpp?rev=253242&r1=253241&r2=253242&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenFunction.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenFunction.cpp Mon Nov 16 12:29:59 2015
@@ -1917,8 +1917,11 @@ void CodeGenFunction::checkTargetFeature
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;
Added: cfe/trunk/test/CodeGen/target-features-no-error.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/target-features-no-error.c?rev=253242&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/target-features-no-error.c (added)
+++ cfe/trunk/test/CodeGen/target-features-no-error.c Mon Nov 16 12:29:59 2015
@@ -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
+}
More information about the cfe-commits
mailing list