Clang error: always_inline function B requires target feature 'C', but would be inlined into function A that is compiled without support for 'C' (err_function_needs_feature)
Jump to navigation
Jump to search
Text | error: always_inline function B requires target feature 'C', but would be inlined into function A that is compiled without support for 'C' |
---|---|
Type | Error |
Category | None (since 8.0) Semantic Issue (until 7.1) |
Internal Id | err_function_needs_feature |
Internal Message | always_inline function %1 requires target feature '%2', but would be inlined into function %0 that is compiled without support for '%2'
|
Regular Expression | (?:error|fatal error)\: always_inline function (.*?) requires target feature '(.*?)', but would be inlined into function (.*?) that is compiled without support for '(.*?)'
|
First Commit | 2015-11-12 2b2d56f059e7 Provide a frontend based error for always_inline functions that require |
Description
Example
Flags | -xc -O2 -mno-aes
|
|
---|---|---|
Source |
#include <immintrin.h>
__attribute__((always_inline, target("aes"))) void f() {} // requires AES
void g() { f(); } // compiled without AES
| |
Compiler Output |
<source>:5:12: error: always_inline function 'f' requires target feature 'aes', but would be inlined into function 'g' that is compiled without support for 'aes' |
Clang Internals (17.0.6)
Git Commit Message
Provide a frontend based error for always_inline functions that require target features that the caller function doesn't provide. This matches the existing backend failure to inline functions that don't have matching target features - and diagnoses earlier in the case of always_inline. Fix up a few test cases that were, in fact, invalid if you tried to generate code from the backend with the specified target features and add a couple of tests to illustrate what's going on. This should fix PR25246. llvm-svn: 252834
Used in Clang Sources
This section lists all occurrences of the diagnostic within the Clang's codebase. For each occurrence, an auto-extracted snipped from the source code is listed including key elements like control structures, functions, or classes. It should illustrate the conditions under which the diagnostic is activated.
clang/lib/CodeGen/CodeGenFunction.cpp (line 2635)
// Emits an error if we don't have a valid set of target features for the
// called function.
void CodeGenFunction::checkTargetFeatures(SourceLocation Loc, const FunctionDecl *TargetDecl) {
// ...
if (BuiltinID) {
// ...
} else if (!TargetDecl->isMultiVersion() && TargetDecl->hasAttr<TargetAttr>()) {
// ...
if (!llvm::all_of(ReqFeatures, [&](StringRef Feature) {
// ...
CGM.getDiags().Report(Loc, diag::err_function_needs_feature) << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature;
clang/lib/CodeGen/CodeGenFunction.cpp (line 2644)
// Emits an error if we don't have a valid set of target features for the
// called function.
void CodeGenFunction::checkTargetFeatures(SourceLocation Loc, const FunctionDecl *TargetDecl) {
// ...
if (BuiltinID) {
// ...
} else if (!TargetDecl->isMultiVersion() && TargetDecl->hasAttr<TargetAttr>()) {
// ...
} else if (!FD->isMultiVersion() && FD->hasAttr<TargetAttr>()) {
// ...
for (const auto &F : CalleeFeatureMap) {
if (F.getValue() && (!CallerFeatureMap.lookup(F.getKey()) || !CallerFeatureMap.find(F.getKey())->getValue()))
CGM.getDiags().Report(Loc, diag::err_function_needs_feature) << FD->getDeclName() << TargetDecl->getDeclName() << F.getKey();
Triggered in Clang Tests
This section lists all internal Clang test cases that trigger the diagnostic.
clang/test/Sema/arm-neon-target.c
- clang/test/Sema/arm-neon-target.c:49:3: error: always_inline function 'vdot_u32' requires target feature 'dotprod', but would be inlined into function 'undefined' that is compiled without support for 'dotprod'
- clang/test/Sema/arm-neon-target.c:51:3: error: always_inline function 'vceqz_f16' requires target feature 'fullfp16', but would be inlined into function 'undefined' that is compiled without support for 'fullfp16'
- clang/test/Sema/arm-neon-target.c:52:3: error: always_inline function 'vrnd_f16' requires target feature 'fullfp16', but would be inlined into function 'undefined' that is compiled without support for 'fullfp16'
- clang/test/Sema/arm-neon-target.c:53:3: error: always_inline function 'vmaxnm_f16' requires target feature 'fullfp16', but would be inlined into function 'undefined' that is compiled without support for 'fullfp16'
- clang/test/Sema/arm-neon-target.c:55:3: error: always_inline function 'vmmlaq_s32' requires target feature 'i8mm', but would be inlined into function 'undefined' that is compiled without support for 'i8mm'
- clang/test/Sema/arm-neon-target.c:57:3: error: always_inline function 'vbfdot_f32' requires target feature 'bf16', but would be inlined into function 'undefined' that is compiled without support for 'bf16'
- clang/test/Sema/arm-neon-target.c:60:3: error: always_inline function 'vdup_n_bf16' requires target feature 'bf16', but would be inlined into function 'undefined' that is compiled without support for 'bf16'
- clang/test/Sema/arm-neon-target.c:62:3: error: always_inline function 'vcvt_f32_bf16' requires target feature 'bf16', but would be inlined into function 'undefined' that is compiled without support for 'bf16'
- clang/test/Sema/arm-neon-target.c:63:3: error: always_inline function 'vcvt_bf16_f32' requires target feature 'bf16', but would be inlined into function 'undefined' that is compiled without support for 'bf16'
- clang/test/Sema/arm-neon-target.c:65:3: error: always_inline function 'vqrdmlahq_s32' requires target feature 'v8.1a', but would be inlined into function 'undefined' that is compiled without support for 'v8.1a'
- clang/test/Sema/arm-neon-target.c:67:3: error: always_inline function 'vcaddq_rot90_f32' requires target feature 'v8.3a', but would be inlined into function 'undefined' that is compiled without support for 'v8.3a'
- clang/test/Sema/arm-neon-target.c:68:3: error: always_inline function 'vcmla_rot90_f16' requires target feature 'v8.3a', but would be inlined into function 'undefined' that is compiled without support for 'v8.3a'