[clang] [clang][FMV][AArch64] Improve streaming mode compatibility. (PR #100181)
Alexandros Lamprineas via cfe-commits
cfe-commits at lists.llvm.org
Wed Jul 24 12:20:36 PDT 2024
================
@@ -3183,6 +3183,25 @@ class ASTContext : public RefCountedBase<ASTContext> {
const FunctionDecl *FD,
llvm::function_ref<void(FunctionDecl *)> Pred) const;
+ bool areFMVCompatible(const FunctionDecl *FD1,
+ const FunctionDecl *FD2) const {
+ if (!hasSameType(FD1->getReturnType(), FD2->getReturnType()))
+ return false;
+
+ if (FD1->isVariadic() != FD2->isVariadic())
+ return false;
+
+ if (FD1->getNumParams() != FD2->getNumParams())
+ return false;
+
+ for (unsigned I = 0; I < FD1->getNumParams(); ++I)
+ if (!hasSameType(FD1->getParamDecl(I)->getOriginalType(),
+ FD2->getParamDecl(I)->getOriginalType()))
----------------
labrinea wrote:
As I mentioned in the description of https://github.com/llvm/llvm-project/pull/100181/commits/9b24b8df3afd7c8620c4a7b7edc8533b992dd484 my patch replaces `hasSameType` with `areFMVCompatible` inside `ASTContext::forEachMultiversionedFunctionVersion`. So if I remove this check you highlighted I am seeing the following codegen test failures:
```
Clang :: CodeGenCXX/attr-target-clones-aarch64.cpp
Clang :: CodeGenCXX/attr-target-clones.cpp
Clang :: CodeGenCXX/attr-target-mv-overloads.cpp
Clang :: CodeGenCXX/attr-target-version.cpp
```
but nothing in sema. This suggests we are not diagnosing argument type mismatch. We just deassociate the declaration from the rest of the function versions. My change is NFC. To convince yourlsef look inside `Sema::areMultiversionVariantFunctionsCompatible`, we are only diagnosing mismatch on the return type:
```
enum Different {
CallingConv = 0,
ReturnType = 1,
...
};
```
If we want to diagnose argument type mismatch then it is not NFC and deserves a separate patch with corresponding sema tests.
https://github.com/llvm/llvm-project/pull/100181
More information about the cfe-commits
mailing list