================
@@ -1571,6 +1575,65 @@ static bool checkAVXParam(DiagnosticsEngine &Diag,
ASTContext &Ctx,
return false;
}
+void X86_64TargetCodeGenInfo::checkFunctionABI(CodeGenModule &CGM,
+ const FunctionDecl *FD) const {
+ auto GetReturnTypeLoc = [](const FunctionDecl *FD) {
+ if (const TypeSourceInfo *TSI = FD->getTypeSourceInfo()) {
+ TypeLoc TL = TSI->getTypeLoc();
+
+ if (auto FTL = TL.IgnoreParens().getAs<FunctionTypeLoc>()) {
+ SourceLocation Loc = FTL.getReturnLoc().getBeginLoc();
+ if (Loc.isValid())
+ return Loc;
+ }
+ }
+
+ SourceLocation Loc = FD->getLocation();
+ if (Loc.isValid())
+ return Loc;
+
+ return FD->getBeginLoc();
+ };
+
+ auto Check = [&](QualType Ty, SourceLocation Loc, bool IsReturn) {
+ if (!Ty->isVectorType())
+ return false;
+ if (CGM.getContext().getTypeSize(Ty) <= 128)
+ return false;
+
+ StringRef Feature =
+ CGM.getContext().getTypeSize(Ty) > 256 ? "avx512f" : "avx";
+
+ llvm::StringMap<bool> FeatureMap;
+ CGM.getContext().getFunctionFeatureMap(FeatureMap, FD);
+ if (!FeatureMap.lookup(Feature)) {
+ CGM.getDiags().Report(Loc, diag::warn_avx_calling_convention)
+ << !IsReturn << Ty << Feature;
+ return true;
+ }
+
+ return false;
+ };
+
+ // psABI warnings & errors for function definitions that are only visible
+ // in this translation unit are handled at call site by checkFunctionCallABI
+ if (!FD->isExternallyVisible())
+ return;
+
+ // First check the return type and emit diagnostic if required
----------------
AaronBallman wrote:
```suggestion
// First check the return type and emit diagnostic if required.
```
https://github.com/llvm/llvm-project/pull/199091
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits