[PATCH] D59873: Add additional mangling for struct members of non trivial structs
Dan Zimmerman via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Mar 27 05:47:18 PDT 2019
danzimm created this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.
In https://bugs.llvm.org/show_bug.cgi?id=41206 we observe bad codegen when embedding a non-trivial C struct within a C struct. This is due to the fact that name mangling for non-trivial structs marks the two structs as identical. This diff contains a potential fix for this issue. I've included a test that exercises this for two scenarios. Please comment if there're any other scenarios I should consider.
Test Plan: I've included a unit test
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D59873
Files:
clang/lib/CodeGen/CGNonTrivialStruct.cpp
Index: clang/lib/CodeGen/CGNonTrivialStruct.cpp
===================================================================
--- clang/lib/CodeGen/CGNonTrivialStruct.cpp
+++ clang/lib/CodeGen/CGNonTrivialStruct.cpp
@@ -139,8 +139,8 @@
// <alignment-info> ::= <dst-alignment> ["_" <src-alignment>]
// <struct-field-info> ::= <field-info>+
// <field-info> ::= <struct-or-scalar-field-info> | <array-field-info>
-// <struct-or-scalar-field-info> ::= <struct-field-info> | <strong-field-info> |
-// <trivial-field-info>
+// <struct-or-scalar-field-info> ::= "_S" <struct-field-info> |
+// <strong-field-info> | <trivial-field-info>
// <array-field-info> ::= "_AB" <array-offset> "s" <element-size> "n"
// <num-elements> <innermost-element-info> "_AE"
// <innermost-element-info> ::= <struct-or-scalar-field-info>
@@ -175,6 +175,7 @@
void visitStruct(QualType QT, const FieldDecl *FD,
CharUnits CurStructOffset) {
CharUnits FieldOffset = CurStructOffset + asDerived().getFieldOffset(FD);
+ appendStr("_S");
asDerived().visitStructFields(QT, FieldOffset);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59873.192427.patch
Type: text/x-patch
Size: 1181 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190327/053a7ee9/attachment.bin>
More information about the cfe-commits
mailing list