diff options
author | Qiu Chaofan <qiucofan@cn.ibm.com> | 2023-03-15 14:21:52 +0800 |
---|---|---|
committer | Qiu Chaofan <qiucofan@cn.ibm.com> | 2023-03-15 14:21:52 +0800 |
commit | 608212a0ff2f9e9a2cee8b5b0fa206fd15eb6472 (patch) | |
tree | 65bed1922932b813b1e5ff50c7f9ea67fa3c11ca /clang/lib/CodeGen/CodeGenFunction.cpp | |
parent | 0aee67ad4e6e750351ecf608d7d056fc49cb9348 (diff) | |
download | llvm-608212a0ff2f9e9a2cee8b5b0fa206fd15eb6472.zip llvm-608212a0ff2f9e9a2cee8b5b0fa206fd15eb6472.tar.gz llvm-608212a0ff2f9e9a2cee8b5b0fa206fd15eb6472.tar.bz2 |
[Clang] Check feature requirement from inlined callee
Currently clang emits error when both always_inline and target
attributes are on callee, but caller doesn't have some feature.
This patch makes clang emit error when caller cannot meet target feature
requirements from an always-inlined callee.
Reviewed By: erichkeane
Differential Revision: https://reviews.llvm.org/D143479
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenFunction.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.cpp b/clang/lib/CodeGen/CodeGenFunction.cpp index af60b31..a5cbf72 100644 --- a/clang/lib/CodeGen/CodeGenFunction.cpp +++ b/clang/lib/CodeGen/CodeGenFunction.cpp @@ -2612,6 +2612,16 @@ void CodeGenFunction::checkTargetFeatures(SourceLocation Loc, })) CGM.getDiags().Report(Loc, diag::err_function_needs_feature) << FD->getDeclName() << TargetDecl->getDeclName() << MissingFeature; + } else if (!FD->isMultiVersion() && FD->hasAttr<TargetAttr>()) { + llvm::StringMap<bool> CalleeFeatureMap; + CGM.getContext().getFunctionFeatureMap(CalleeFeatureMap, TargetDecl); + + 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(); + } } } |