[clang] [clang][sema] forbid vector_size attr when specify `-mgeneral-regs-only` on x86 (PR #75350)
Phoebe Wang via cfe-commits
cfe-commits at lists.llvm.org
Wed Dec 13 23:58:18 PST 2023
================
@@ -8251,6 +8251,25 @@ static void HandleVectorSizeAttr(QualType &CurType, const ParsedAttr &Attr,
return;
}
+ // check -mgeneral-regs-only is specified
+ const TargetInfo &targetInfo = S.getASTContext().getTargetInfo();
+ llvm::Triple::ArchType arch = targetInfo.getTriple().getArch();
+ const auto HasFeature = [](const clang::TargetOptions &targetOpts,
+ const std::string &feature) {
+ return std::find(targetOpts.Features.begin(), targetOpts.Features.end(),
+ feature) != targetOpts.Features.end();
+ };
+ if (CurType->isSpecificBuiltinType(BuiltinType::LongDouble)) {
----------------
phoebewang wrote:
`LongDouble` is not the only problem. GCC simply disallows any vector return type without SSE (`sse` feature) and gives error like `SSE register return with SSE disabled` and give warnings to vector argument type. https://godbolt.org/z/fhG76nqYo
LLVM behaves differently from GCC. It can generate code for any vector types expect `LongDouble` with `-mgeneral-regs-only`.
I think it would be incorrect but I'm not sure if we want to make it such strict.
`LongDouble` cannot be supported without `x87` feature. I'd expect something like https://reviews.llvm.org/D98895. It would be good if you can add vector type check there.
And you need to add test case for this scenario.
https://github.com/llvm/llvm-project/pull/75350
More information about the cfe-commits
mailing list