llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT--> @llvm/pr-subscribers-clang-codegen Author: Vitaly Buka (vitalybuka) <details> <summary>Changes</summary> According GCC documentation transparent union calling convention is the same as the type of the first member of the union. C++ ignores attribute. --- Full diff: https://github.com/llvm/llvm-project/pull/158194.diff 5 Files Affected: - (modified) clang/lib/CodeGen/CodeGenModule.cpp (+12-5) - (modified) clang/test/CodeGen/cfi-icall-generalize.c (+1-1) - (modified) clang/test/CodeGen/cfi-icall-normalize2.c (+1-1) - (modified) clang/test/CodeGen/kcfi-generalize.c (+1-1) - (modified) clang/test/CodeGen/kcfi-normalize.c (+1-1) ``````````diff diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index 46dbd85665e5d..44441df5ca6d8 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -2352,8 +2352,8 @@ static QualType GeneralizeTransparentUnion(QualType Ty) { return Ty; } -static QualType GeneralizeTransparentUnion(QualType Ty) { -} +static QualType GeneralizeFunctionType(ASTContext &Ctx, QualType Ty, + bool GeneralizePointers); // Generalize pointer types to a void pointer with the qualifiers of the // originally pointed-to type, e.g. 'const char *' and 'char * const *' @@ -2363,12 +2363,19 @@ static QualType GeneralizeType(ASTContext &Ctx, QualType Ty, bool GeneralizePointers) { Ty = GeneralizeTransparentUnion(Ty); - if (!GeneralizePointers || !Ty->isPointerType()) + if (!Ty->isPointerType()) + return Ty; + + QualType PTy = Ty->getPointeeType(); + if (PTy->getAs<FunctionProtoType>() || PTy->getAs<FunctionNoProtoType>()) + Ty = Ctx.getPointerType( + GeneralizeFunctionType(Ctx, PTy, GeneralizePointers)); + + if (!GeneralizePointers) return Ty; return Ctx.getPointerType( - QualType(Ctx.VoidTy) - .withCVRQualifiers(Ty->getPointeeType().getCVRQualifiers())); + QualType(Ctx.VoidTy).withCVRQualifiers(PTy.getCVRQualifiers())); } // Apply type generalization to a FunctionType's return and argument types diff --git a/clang/test/CodeGen/cfi-icall-generalize.c b/clang/test/CodeGen/cfi-icall-generalize.c index 5359134805198..6659d76fbbbb2 100644 --- a/clang/test/CodeGen/cfi-icall-generalize.c +++ b/clang/test/CodeGen/cfi-icall-generalize.c @@ -30,5 +30,5 @@ void uni(void (*fn)(union Union), union Union arg1) { // CHECK: [[TYPE]] = !{i64 0, !"_ZTSFPPiPKcPS2_E"} // CHECK: [[TYPE_GENERALIZED]] = !{i64 0, !"_ZTSFPvPKvS_E.generalized"} -// CHECK: [[TYPE2]] = !{i64 0, !"_ZTSFvPFv5UnionEPcE"} +// CHECK: [[TYPE2]] = !{i64 0, !"_ZTSFvPFvPcES_E"} // CHECK: [[TYPE2_GENERALIZED]] = !{i64 0, !"_ZTSFvPvS_E.generalized"} diff --git a/clang/test/CodeGen/cfi-icall-normalize2.c b/clang/test/CodeGen/cfi-icall-normalize2.c index b9d9af7c8a47b..49b279c04fd56 100644 --- a/clang/test/CodeGen/cfi-icall-normalize2.c +++ b/clang/test/CodeGen/cfi-icall-normalize2.c @@ -39,4 +39,4 @@ void uni(void (*fn)(union Union), union Union arg1) { // CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPFvu3i32ES_E.normalized"} // CHECK: ![[TYPE2]] = !{i64 0, !"_ZTSFvPFvu3i32S_ES_S_E.normalized"} // CHECK: ![[TYPE3]] = !{i64 0, !"_ZTSFvPFvu3i32S_S_ES_S_S_E.normalized"} -// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPFv5UnionEPu2i8E.normalized"} +// CHECK: ![[TYPE4]] = !{i64 0, !"_ZTSFvPFvPu2i8ES0_E.normalized"} diff --git a/clang/test/CodeGen/kcfi-generalize.c b/clang/test/CodeGen/kcfi-generalize.c index 24e054549d527..91f2be7b74818 100644 --- a/clang/test/CodeGen/kcfi-generalize.c +++ b/clang/test/CodeGen/kcfi-generalize.c @@ -44,5 +44,5 @@ void uni(void (*fn)(union Union), union Union arg1) { // UNGENERALIZED: [[TYPE3]] = !{i32 874141567} // GENERALIZED: [[TYPE3]] = !{i32 954385378} -// UNGENERALIZED: [[TYPE2]] = !{i32 -1619636625} +// UNGENERALIZED: [[TYPE2]] = !{i32 -1954865805} // GENERALIZED: [[TYPE2]] = !{i32 -125078496} \ No newline at end of file diff --git a/clang/test/CodeGen/kcfi-normalize.c b/clang/test/CodeGen/kcfi-normalize.c index 08f5249b6d6c3..532959a7d30fd 100644 --- a/clang/test/CodeGen/kcfi-normalize.c +++ b/clang/test/CodeGen/kcfi-normalize.c @@ -45,5 +45,5 @@ void uni(void (*fn)(union Union), union Union arg1) { // CHECK: ![[TYPE1]] = !{i32 -1143117868} // CHECK: ![[TYPE2]] = !{i32 -460921415} // CHECK: ![[TYPE3]] = !{i32 -333839615} -// C: ![[TYPE4]] = !{i32 -650530463} +// C: ![[TYPE4]] = !{i32 1186327125} // CPP: ![[TYPE4]] = !{i32 1766237188} \ No newline at end of file `````````` </details> https://github.com/llvm/llvm-project/pull/158194 _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits