dblaikie created this revision. dblaikie added reviewers: probinson, aprantl. dblaikie requested review of this revision. Herald added a project: clang. Herald added a subscriber: cfe-commits.
This reverts c7f16ab3e3f27d944db72908c9c1b1b7366f5515 / r109694 - which suggested this was done to improve consistency with the gdb test suite. Possible that at the time GCC did not canonicalize integer types, and so matching types was important for cross-compiler validity, or that it was only a case of over-constrained test cases that printed out/tested the exact names of integer types. In any case neither issue seems to exist today based on my limited testing - both gdb and lldb canonicalize integer types (in a way that happens to match Clang's preferred naming, incidentally) and so never print the original text name produced in the DWARF by GCC or Clang. This canonicalization appears to be in `integer_types_same_name_p` for GDB and in `TypeSystemClang::GetBasicTypeEnumeration` for lldb. (I tested this with one translation unit defining 3 variables - `long`, `long (*)()`, and `int (*)()`, and another translation unit that had main, and a function that took `long (*)()` as a parameter - then compiled them with mismatched compilers (either GCC+Clang, or Clang+(Clang with this patch applied)) and no matter the combination, despite the debug info for one CU naming the type "long int" and the other naming it "long", both debuggers printed out the name as "long" and were able to correctly perform overload resolution and pass the `long int (*)()` variable to the `long (*)()` function parameter) Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D110455 Files: clang/lib/CodeGen/CGDebugInfo.cpp clang/test/CodeGen/aarch64-debug-sve-vector-types.c clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c clang/test/CodeGen/debug-info-enum.cpp clang/test/CodeGen/debug-info.c
Index: clang/test/CodeGen/debug-info.c =================================================================== --- clang/test/CodeGen/debug-info.c +++ clang/test/CodeGen/debug-info.c @@ -58,3 +58,8 @@ typedef unsigned long long uint64_t; typedef uint64_t uint64x2_t __attribute__((ext_vector_type(2))); uint64x2_t extvectbar[4]; + +// CHECK-DAG: !DIBasicType(name: "long" +// CHECK-DAG: !DIBasicType(name: "unsigned long long" +void integral_types(long x, unsigned long long y) { +} Index: clang/test/CodeGen/debug-info-enum.cpp =================================================================== --- clang/test/CodeGen/debug-info-enum.cpp +++ clang/test/CodeGen/debug-info-enum.cpp @@ -77,7 +77,7 @@ // CHECK-SAME: baseType: ![[LONG:[0-9]+]] // CHECK-SAME: DIFlagEnumClass // CHECK-SAME: elements: ![[ELTS6:[0-9]+]] -// CHECK: ![[LONG]] = !DIBasicType(name: "long long int", size: 64, encoding: DW_ATE_signed) +// CHECK: ![[LONG]] = !DIBasicType(name: "long long", size: 64, encoding: DW_ATE_signed) // CHECK: ![[ELTS6]] = !{![[A6:[0-9]+]], ![[B6:[0-9]+]]} // CHECK: ![[A6]] = !DIEnumerator(name: "A6", value: -9223372036854775808) // CHECK: ![[B6]] = !DIEnumerator(name: "B6", value: 9223372036854775807) @@ -87,7 +87,7 @@ // CHECK-SAME: baseType: ![[ULONG:[0-9]+]] // CHECK-SAME: DIFlagEnumClass // CHECK-SAME: elements: ![[ELTS7:[0-9]+]] -// CHECK: ![[ULONG]] = !DIBasicType(name: "long long unsigned int", size: 64, encoding: DW_ATE_unsigned) +// CHECK: ![[ULONG]] = !DIBasicType(name: "unsigned long long", size: 64, encoding: DW_ATE_unsigned) // CHECK: ![[ELTS7]] = !{![[A7:[0-9]+]]} // CHECK: ![[A7]] = !DIEnumerator(name: "A7", value: 18446744073709551615, isUnsigned: true) Index: clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c =================================================================== --- clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c +++ clang/test/CodeGen/aarch64-debug-sve-vectorx4-types.c @@ -40,14 +40,14 @@ // CHECK-DAG: name: "__clang_svint64x4_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x4_64:[0-9]+]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) // CHECK-DAG: ![[ELTS1x4_64]] = !{![[REALELTS1x4_64:[0-9]+]]} // CHECK-DAG: ![[REALELTS1x4_64]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 4, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus)) __clang_svint64x4_t s64; // CHECK-DAG: name: "__clang_svuint64x4_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x4_64]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) __clang_svuint64x4_t u64; // CHECK: name: "__clang_svfloat16x4_t",{{.*}}, baseType: ![[CT16:[0-9]+]] Index: clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c =================================================================== --- clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c +++ clang/test/CodeGen/aarch64-debug-sve-vectorx3-types.c @@ -40,14 +40,14 @@ // CHECK-DAG: name: "__clang_svint64x3_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x3_64:[0-9]+]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) // CHECK-DAG: ![[ELTS1x3_64]] = !{![[REALELTS1x3_64:[0-9]+]]} // CHECK-DAG: ![[REALELTS1x3_64]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 3, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus)) __clang_svint64x3_t s64; // CHECK-DAG: name: "__clang_svuint64x3_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x3_64]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) __clang_svuint64x3_t u64; // CHECK: name: "__clang_svfloat16x3_t",{{.*}}, baseType: ![[CT16:[0-9]+]] Index: clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c =================================================================== --- clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c +++ clang/test/CodeGen/aarch64-debug-sve-vectorx2-types.c @@ -40,14 +40,14 @@ // CHECK-DAG: name: "__clang_svint64x2_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x2_64:[0-9]+]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) // CHECK-DAG: ![[ELTS1x2_64]] = !{![[REALELTS1x2_64:[0-9]+]]} // CHECK-DAG: ![[REALELTS1x2_64]] = !DISubrange(lowerBound: 0, upperBound: !DIExpression(DW_OP_constu, 2, DW_OP_bregx, 46, 0, DW_OP_mul, DW_OP_constu, 1, DW_OP_minus)) __clang_svint64x2_t s64; // CHECK-DAG: name: "__clang_svuint64x2_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1x2_64]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) __clang_svuint64x2_t u64; // CHECK: name: "__clang_svfloat16x2_t",{{.*}}, baseType: ![[CT16:[0-9]+]] Index: clang/test/CodeGen/aarch64-debug-sve-vector-types.c =================================================================== --- clang/test/CodeGen/aarch64-debug-sve-vector-types.c +++ clang/test/CodeGen/aarch64-debug-sve-vector-types.c @@ -46,12 +46,12 @@ // CHECK-DAG: name: "__SVInt64_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long int", size: 64, encoding: DW_ATE_signed) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long", size: 64, encoding: DW_ATE_signed) __SVInt64_t s64; // CHECK-DAG: name: "__SVUint64_t",{{.*}}, baseType: ![[CT64:[0-9]+]] // CHECK-DAG: ![[CT64]] = !DICompositeType(tag: DW_TAG_array_type, baseType: ![[ELTTY64:[0-9]+]], flags: DIFlagVector, elements: ![[ELTS1_64]]) - // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "long unsigned int", size: 64, encoding: DW_ATE_unsigned) + // CHECK-DAG: ![[ELTTY64]] = !DIBasicType(name: "unsigned long", size: 64, encoding: DW_ATE_unsigned) __SVUint64_t u64; // CHECK: name: "__SVFloat16_t",{{.*}}, baseType: ![[CT16:[0-9]+]] Index: clang/lib/CodeGen/CGDebugInfo.cpp =================================================================== --- clang/lib/CodeGen/CGDebugInfo.cpp +++ clang/lib/CodeGen/CGDebugInfo.cpp @@ -873,23 +873,7 @@ break; } - switch (BT->getKind()) { - case BuiltinType::Long: - BTName = "long int"; - break; - case BuiltinType::LongLong: - BTName = "long long int"; - break; - case BuiltinType::ULong: - BTName = "long unsigned int"; - break; - case BuiltinType::ULongLong: - BTName = "long long unsigned int"; - break; - default: - BTName = BT->getName(CGM.getLangOpts()); - break; - } + BTName = BT->getName(CGM.getLangOpts()); // Bit size and offset of the type. uint64_t Size = CGM.getContext().getTypeSize(BT); return DBuilder.createBasicType(BTName, Size, Encoding);
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits