Page MenuHomePhabricator

Please use GitHub pull requests for new patches. Phabricator shutdown timeline

yihanaa (Wang Yihan)
User

Projects

User does not belong to any projects.

User Details

User Since
Aug 19 2020, 5:26 PM (162 w, 1 h)

Recent Activity

Sep 2 2022

yihanaa updated yihanaa.
Sep 2 2022, 10:56 AM
yihanaa updated yihanaa.
Sep 2 2022, 3:43 AM

Aug 15 2022

yihanaa closed D131887: [NFC][SmallVector] Use std::conditional_t instead of std::conditional.

Thanks for your review @erichkeane!

Aug 15 2022, 8:00 AM · Restricted Project, Restricted Project
yihanaa committed rG91d784a0217f: [NFC][SmallVector] Use std::conditional_t instead of std::conditional (authored by yihanaa).
[NFC][SmallVector] Use std::conditional_t instead of std::conditional
Aug 15 2022, 6:53 AM · Restricted Project, Restricted Project
yihanaa added a reviewer for D131887: [NFC][SmallVector] Use std::conditional_t instead of std::conditional: erichkeane.
Aug 15 2022, 6:42 AM · Restricted Project, Restricted Project
yihanaa requested review of D131887: [NFC][SmallVector] Use std::conditional_t instead of std::conditional.
Aug 15 2022, 6:32 AM · Restricted Project, Restricted Project

May 5 2022

yihanaa added a comment to D124221: Reimplement `__builtin_dump_struct` in Sema..

This is unfortunately true, unless we generate some code that calculates the length of the string at runtime. I find it difficult to draw the line between defining this built-in functionality and developers developing printf-like functionality, if built-in does too much, flexibility will decrease, if built-in does less, (features like length limits) then develop personnel may need to do some work. o(≧口≦)o

May 5 2022, 9:55 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D124221: Reimplement `__builtin_dump_struct` in Sema..

I found LLDB have this feature. LLDB uses "..." to indicate that only part of the string is now printed, and it also have a command to modify length limit. This approach is similar to the idea of @erichkeane, can we do the same?what do you all think?

typedef signed char int8_t;
typedef unsigned char uint8_t;
May 5 2022, 9:41 AM · Restricted Project, Unknown Object (Project)
yihanaa accepted D124221: Reimplement `__builtin_dump_struct` in Sema..
May 5 2022, 5:25 AM · Restricted Project, Unknown Object (Project)

May 4 2022

yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 4 2022, 10:25 PM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 4 2022, 10:02 PM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 4 2022, 4:32 AM · Restricted Project, Unknown Object (Project)

May 2 2022

yihanaa added a comment to D124221: Reimplement `__builtin_dump_struct` in Sema..

Do we need to do argument promotion here,ahh...maybe i understood wrong

May 2 2022, 11:21 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 2 2022, 11:08 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D124221: Reimplement `__builtin_dump_struct` in Sema..

This implementation looks good to me😁

May 2 2022, 10:41 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 2 2022, 3:03 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
May 2 2022, 1:19 AM · Restricted Project, Unknown Object (Project)

Apr 28 2022

yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Thank you all, I have commit in eaca933c59fd61b3df4697b5fae0eeec67acfaeb

Apr 28 2022, 10:30 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Thanks for review @rsmith, @erichkeane and @aaron.ballman , I have add a newline back to the end of the test, and waiting for ci....

Apr 28 2022, 11:37 AM · Restricted Project, Unknown Object (Project)
yihanaa updated the diff for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Add the newline back to the end of the test.

Apr 28 2022, 11:35 AM · Restricted Project, Unknown Object (Project)

Apr 27 2022

yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

While we'd usually be happy to take the fix-in-hand and apply it, part of the discussion on the other thread is whether to remove __builtin_dump_struct entirely. Because of that, I don't think we should make substantial changes in this area until it's clear we're keeping the builtin.

Apr 27 2022, 10:16 PM · Restricted Project, Unknown Object (Project)

Apr 26 2022

yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 26 2022, 10:35 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

@yihanaa : I'd suggest seeing the conversation that @rsmith @aaron.ballman and I are having about this builtin here: https://reviews.llvm.org/D124221

In general it looks like the three of us think that this builtin needs an overhaul in implementation/functionality in order to be further useful. While we very much appreciate your attempts to try to improve it, we believe there needs to be larger-scale changes.

Thanks for your reply, I would like to get involved and help if needed

While I eagerly await __builtin_reflect_struct, this change still provides significant value in fixing a regression with __builtin_dump_struct. Should we proceed with this change and that proposal independently?

Agree

Apr 26 2022, 9:27 PM · Restricted Project, Unknown Object (Project)

Apr 25 2022

yihanaa added a reviewer for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name: asoffer.
Apr 25 2022, 12:39 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D124221: Reimplement `__builtin_dump_struct` in Sema..

Thank you for inviting me to a discussion on this topic. I have something very confusing as follows:

Apr 25 2022, 9:04 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

@yihanaa : I'd suggest seeing the conversation that @rsmith @aaron.ballman and I are having about this builtin here: https://reviews.llvm.org/D124221

In general it looks like the three of us think that this builtin needs an overhaul in implementation/functionality in order to be further useful. While we very much appreciate your attempts to try to improve it, we believe there needs to be larger-scale changes.

Apr 25 2022, 7:51 AM · Restricted Project, Unknown Object (Project)

Apr 23 2022

yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Should we use PrintingPolicy.Indentation instead of 4 hardcoded in dumpRecord?

Apr 23 2022, 9:08 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D124221: Reimplement `__builtin_dump_struct` in Sema..
Apr 23 2022, 8:33 AM · Restricted Project, Unknown Object (Project)
yihanaa updated the diff for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Optimize the code according to @rsmith 's suggestion, and use analyze_printf::PrintfSpecifier::fixType instead of this static DenseMap to find the printf format specifier.

Apr 23 2022, 7:14 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 23 2022, 4:35 AM · Restricted Project, Unknown Object (Project)

Apr 13 2022

yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Could you please help me review the code?@rsmith,thanks😊

Apr 13 2022, 10:14 PM · Restricted Project, Unknown Object (Project)

Apr 7 2022

yihanaa added inline comments to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
Apr 7 2022, 3:06 AM · Restricted Project, Restricted Project, Unknown Object (Project)

Apr 4 2022

yihanaa updated the diff for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Improve comment

Apr 4 2022, 11:18 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 4 2022, 10:46 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

I'll just add that in the recursive call, for record type, it will just print what's between {...}
Eg:

int printf(const char *, ...);
Apr 4 2022, 10:03 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 4 2022, 10:00 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 4 2022, 9:47 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

I don't particularly get what the 'fix' is here to Richard's issue. Additionally, I think this is showing me the absolute desperate need we have for some sort of 'text-checking' tests for this feature, checking vs the IR is too unreadable.

Apr 4 2022, 9:41 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Can you guys please help me review this patch? 😁

Apr 4 2022, 8:46 AM · Restricted Project, Unknown Object (Project)
yihanaa added a reviewer for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name: MaskRay.
Apr 4 2022, 7:38 AM · Restricted Project, Unknown Object (Project)

Apr 3 2022

yihanaa added inline comments to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
Apr 3 2022, 7:57 AM · Restricted Project, Restricted Project, Unknown Object (Project)
yihanaa added a reviewer for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name: xbolva00.
Apr 3 2022, 5:55 AM · Restricted Project, Unknown Object (Project)

Apr 1 2022

yihanaa updated the diff for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Reformat code

Apr 1 2022, 8:43 PM · Restricted Project, Unknown Object (Project)
yihanaa updated the diff for D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.

Reformat code.

Apr 1 2022, 8:24 PM · Restricted Project, Unknown Object (Project)
yihanaa abandoned D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Apr 1 2022, 6:13 PM · Restricted Project, Unknown Object (Project)
yihanaa planned changes to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Apr 1 2022, 6:12 PM · Restricted Project, Unknown Object (Project)
yihanaa requested review of D122920: [Clang][CodeGen]Fix __builtin_dump_struct missing record type field name.
Apr 1 2022, 10:42 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
Apr 1 2022, 9:00 AM · Restricted Project, Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
Apr 1 2022, 8:26 AM · Restricted Project, Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.

I also agree that this is a useful debugging builtin, and no program logic should be forced to depend on the output of this builtin. It's just used to print out some useful debugging information

FWIW, @rsmith is the clang-codeowner, so he's the one to convince (and @rjmccall is also a very senior reviewer). So I wouldn't be able to approve this patch without their consent/agreement.

Apr 1 2022, 8:14 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Apr 1 2022, 7:59 AM · Restricted Project, Unknown Object (Project)

Mar 31 2022

yihanaa added a comment to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.

I also agree that this is a useful debugging builtin, and no program logic should be forced to depend on the output of this builtin. It's just used to print out some useful debugging information

Mar 31 2022, 8:41 PM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 8:34 PM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 12:02 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.

I'm concerned about the direction of this patch given @rjmccall's comments on https://reviews.llvm.org/D112626 -- presumably the way we'd want to address those comments would be to convert a __builtin_dump_struct(a, f) call into a single f("...", a.x, a.y, a.z) call in Sema, and that approach doesn't seem compatible with generating code to loop over array elements.

I'm also concerned that this builtin is making a lot of design decisions on behalf of the programmer, meaning that either it does exactly what you want or it's not suitable for your use and there's not much you can do about it. A different design that let the programmer choose whether to recurse into structs and arrays and similarly let the programmer choose how to format the fields would seem preferable, but I'm not confident there's a good way to expose that in C (though in C++ there seem to be good designs to choose from). As an example of how that manifests here, the choice to print each element as a separate line for a struct member of type const char str[256]; is probably going to make the output very unreadable, but choosing to print every array of char using "%s" will be equally bad for arrays that don't contain text -- the "right" answer for a dumping facility probably involves checking whether the array contains only printable characters and trimming a trailing sequence of zeroes, but that seems like vastly more complexity than we'd want in code generated by a builtin.

Mar 31 2022, 11:58 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 11:51 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 11:29 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 11:23 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 11:09 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.

There is another question, which way should I print for an empty array?

Mar 31 2022, 10:47 AM · Restricted Project, Unknown Object (Project)
yihanaa added inline comments to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 10:32 AM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.

Thanks for your suggestion @erichkeane !

Mar 31 2022, 9:27 AM · Restricted Project, Unknown Object (Project)
yihanaa abandoned D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.
Mar 31 2022, 7:48 AM · Unknown Object (Project), Restricted Project, Restricted Project
yihanaa requested review of D122822: [Clang][CodeGen]Add constant array support for __builtin_dump_sturct.
Mar 31 2022, 7:47 AM · Restricted Project, Unknown Object (Project)

Mar 30 2022

yihanaa added a comment to D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members.

Thank you for the reviews @erichkeane. I've applied for commit access and commit in 907d3acefc3bdd6eb83f21589c6473ca7e88b3eb.

Mar 30 2022, 4:53 PM · Restricted Project, Unknown Object (Project)
yihanaa committed rG907d3acefc3b: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct… (authored by yihanaa).
[Clang][CodeGen]Beautify dump format, add indent for nested struct and struct…
Mar 30 2022, 4:44 PM · Unknown Object (Project), Restricted Project
yihanaa closed D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members.
Mar 30 2022, 4:44 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members.

This seems fine to me. I won't likely have time to commit this for a while, but you should be able to apply for commit-rights now and do it yourself.

Mar 30 2022, 7:51 AM · Restricted Project, Unknown Object (Project)

Mar 29 2022

yihanaa requested review of D122704: [Clang][CodeGen]Beautify dump format, add indent for nested struct and struct members.
Mar 29 2022, 10:17 PM · Restricted Project, Unknown Object (Project)
yihanaa added a comment to D122670: [Clang][CodeGen]Remove anonymous tag locations.

Still LGTM.

Mar 29 2022, 10:59 AM · Unknown Object (Project), Restricted Project
yihanaa updated the diff for D122670: [Clang][CodeGen]Remove anonymous tag locations.

Add this change into ReleaseNotes.

Mar 29 2022, 10:55 AM · Unknown Object (Project), Restricted Project
yihanaa added a comment to D122670: [Clang][CodeGen]Remove anonymous tag locations.

I think Aaron wants release notes for just about everything :) Mind tossing one on this patch? I'll commit for you after that.

Mar 29 2022, 10:51 AM · Unknown Object (Project), Restricted Project
yihanaa requested review of D122670: [Clang][CodeGen]Remove anonymous tag locations.
Mar 29 2022, 10:44 AM · Unknown Object (Project), Restricted Project
yihanaa added a comment to D122668: [Clang][doc][NFC]Remove duplicate items in ReleaseNotes.

2 small bits, otherwise LGTM.

Mar 29 2022, 10:28 AM · Unknown Object (Project), Restricted Project
yihanaa updated the diff for D122668: [Clang][doc][NFC]Remove duplicate items in ReleaseNotes.

Fixed "Description" issue and removed useless newlines

Mar 29 2022, 10:26 AM · Unknown Object (Project), Restricted Project
yihanaa requested review of D122668: [Clang][doc][NFC]Remove duplicate items in ReleaseNotes.
Mar 29 2022, 10:18 AM · Restricted Project, Restricted Project
yihanaa added a comment to D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

I'd also suggest splitting into the '3' things that you're trying to accomplish above. The CGBuiltin.cpp code has way too much going on to reasonably review.

I'd also suggest splitting into the '3' things that you're trying to accomplish above. The CGBuiltin.cpp code has way too much going on to reasonably review.

Maybe I should split the third thing into another separate patch, the first thing needs to modify the indent when adding constant array support, that is the third thing (modify the indent), what do you think?

I would suggest piling them from #3, to #2 to #1. That is: "Change the anonymous printing" in the first, add the 'sub-element-tabbing' in 2nd, and 'add constant array support' in 3rd.

Mar 29 2022, 9:55 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

I'd also suggest splitting into the '3' things that you're trying to accomplish above. The CGBuiltin.cpp code has way too much going on to reasonably review.

Mar 29 2022, 9:36 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

I'd also suggest splitting into the '3' things that you're trying to accomplish above. The CGBuiltin.cpp code has way too much going on to reasonably review.

Mar 29 2022, 9:22 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

This looks to be quite the large patch, can you split this up into individual patches? It isn't clear to me what all is going on everywhere.

Mar 29 2022, 9:15 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa updated the diff for D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

split another patch to fix ReleaseNotes.

Mar 29 2022, 9:13 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

Thanks for review @erichkeane ,maybe i should split this patch.

Mar 29 2022, 9:05 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa updated the diff for D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.

Remove unnecessary code format

Mar 29 2022, 8:56 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa requested review of D122662: [Clang][CodeGen] Add constant array support for __builtin_dump_sturct, and beautify dump format.
Mar 29 2022, 8:44 AM · Restricted Project, Restricted Project, Restricted Project

Mar 24 2022

yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

LGTM aside from a tiny nit with one of the release notes.

I'd be happy to fix it

LGTM aside from a tiny nit with one of the release notes.

Don't worry about it, I'll make the change as part of committing.

Mar 24 2022, 12:12 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa updated the diff for D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

Put the dump format changes under the "Non-comprehensive list of changes in this release" heading instead.

Mar 24 2022, 12:10 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

LGTM aside from a tiny nit with one of the release notes.

Mar 24 2022, 12:03 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

LGTM! Please give Aaron a few hours (perhaps until tomorrow?) to take 1 last look before committing.

Also, if you lack commit rights and need someone to commit for you, please provide the name + email address you'd like it committed under.

Mar 24 2022, 11:57 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

Waitting for CI...

Mar 24 2022, 11:46 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa updated the diff for D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

Use `FD->getDeclName().empty() instead of FD->getNameAsString().empty()`
Add a the format changes to release notes

Mar 24 2022, 11:45 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

Maybe add the changes under "Attribute Changes in Clang"?

Mar 24 2022, 11:18 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

What if we don't emit '=' for zero-width bitfield, like this:

struct Bar {
unsigned c : 1;
unsigned : 3;
unsigned : 0;
unsigned b;
};

struct Bar {
unsigned int c : 1 = 0
unsigned int   : 3 = 0
unsigned int   : 0
unsigned int b = 0
}

What do you all think?

I like this idea best of all!

Agreed!

@erichkeane @aaron.ballman
Previously we used FieldDecl->getNameAsString to get the field name, but the comments for this function indicate that it is Deprecated,and suggestion move clients to getName().

The FieldDecl->getName() return the anonymous inner struct's name like:

struct T3A {
  union {
    int a;
    char b[4];
  };
};
struct T3A {
union T3A::(anonymous at ./builtin_dump_struct.c:77:5) {
    int a = 42
    char[4] b = 0x2a
    }
}

what do you all think?

I would probably keep using getNameAsString() as I don't think the extra information helps overly much. That interface was marked deprecated 13 years ago, so don't feel bad for making use of it.

Mar 24 2022, 11:01 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa updated the diff for D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

Support dump bitwidth of bitfields, and unnamed bitfields.
for example:

struct Bar {
unsigned c : 1;
unsigned : 3;
unsigned : 0;
unsigned b;
};
Mar 24 2022, 10:58 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

What if we don't emit '=' for zero-width bitfield, like this:

struct Bar {
unsigned c : 1;
unsigned : 3;
unsigned : 0;
unsigned b;
};

struct Bar {
unsigned int c : 1 = 0
unsigned int   : 3 = 0
unsigned int   : 0
unsigned int b = 0
}

What do you all think?

I like this idea best of all!

Agreed!

Mar 24 2022, 9:14 AM · Restricted Project, Restricted Project, Restricted Project

Mar 23 2022

yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

I'm sorry I misunderstood what you meant @aaron.ballman.

Can we follow the lead of LLVM IR?it use 'undef'
for example:

struct T6A {
    unsigned a : 1;
    unsigned  : 0;
    unsigned c : 1;
};

@__const.foo.a = private unnamed_addr constant %struct.T6A { i8 1, [3 x i8] undef, i8 1, [3 x i8] undef }, align 4

I misunderstood him too, he told me off line :)

I guess I would be 'ok' with undef, though that has a different meaning (it means, this has an arbitrary value). In this case, it has NO value, which is somewhat different.

Mar 23 2022, 1:43 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

If it is ok, I think we should probably change the format of the 'dump' for fields. Using the colon to split up the field from the value is unfortunate, may I suggest replacing it with '=' instead? As well as printing the size after a colon. So for:

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

Output:

struct Bar {
unsigned int c : 1 = 1
unsigned int : 3  = 0
unsigned int : 0 = 
unsigned int b = 2022
}

What do you all think?

I think that's a good idea for clarity. For the case where we have no value, I wonder if we want to do something like: unsigned int : 0 = <uninitialized> (or something else to make it exceptionally clear that there's nothing missing after the =)?

how

If it is ok, I think we should probably change the format of the 'dump' for fields. Using the colon to split up the field from the value is unfortunate, may I suggest replacing it with '=' instead? As well as printing the size after a colon. So for:

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

Output:

struct Bar {
unsigned int c : 1 = 1
unsigned int : 3  = 0
unsigned int : 0 = 
unsigned int b = 2022
}

What do you all think?

I think that's a good idea for clarity. For the case where we have no value, I wonder if we want to do something like: unsigned int : 0 = <uninitialized> (or something else to make it exceptionally clear that there's nothing missing after the =)?

How to judge whether this field is initialized? Maybe this memory has been initialized by memset

He means a special-case for the 0-size bitfield, which HAS no value (actually, wonder if this is a problem with the no-unique-address types as well?). I might suggest N/A instead of uninitialized, but am open to bikeshedding.

Mar 23 2022, 1:30 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

If it is ok, I think we should probably change the format of the 'dump' for fields. Using the colon to split up the field from the value is unfortunate, may I suggest replacing it with '=' instead? As well as printing the size after a colon. So for:

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

Output:

struct Bar {
unsigned int c : 1 = 1
unsigned int : 3  = 0
unsigned int : 0 = 
unsigned int b = 2022
}

What do you all think?

I think that's a good idea for clarity. For the case where we have no value, I wonder if we want to do something like: unsigned int : 0 = <uninitialized> (or something else to make it exceptionally clear that there's nothing missing after the =)?

Mar 23 2022, 1:15 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.

If it is ok, I think we should probably change the format of the 'dump' for fields. Using the colon to split up the field from the value is unfortunate, may I suggest replacing it with '=' instead? As well as printing the size after a colon. So for:

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

Output:

struct Bar {
unsigned int c : 1 = 1
unsigned int : 3  = 0
unsigned int : 0 = 
unsigned int b = 2022
}

What do you all think?

Mar 23 2022, 1:06 PM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
  1. Support zero-width bitfield, named bitfield and unnamed bitfield.
  2. Add a release notes.

The builtin function __builtin_dump_struct behaves for zero-width bitfield and unnamed bitfield as follows

int printf(const char *fmt, ...);

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

int main() {
  foo();
  return 0;
}

Output:

struct Bar {
unsigned int c : 1
unsigned int  : 0
unsigned int b : 2022
}

Thank you for the release note and additional test coverage. I'm wondering why we handle the zero-width bit-field differently from the anonymous one (e.g., why do we not have unsigned int : 3 before the unsigned int : 0? It seems a bit odd to drop that from the output.

Thanks, I don't know what the value of this zero-width bitfield should output, can it be a empty value as same as unnamed-bitfield’ she field name?

for example:

struct Bar {
unsigned int c : 1
unsigned int  : 0
unsigned int  :
unsigned int b : 2022
}

I would definitely expect this, yes.

Mar 23 2022, 11:56 AM · Restricted Project, Restricted Project, Restricted Project
yihanaa added a comment to D122248: [clang][CodeGen]Fix clang crash and add bitfield support in __builtin_dump_struct.
  1. Support zero-width bitfield, named bitfield and unnamed bitfield.
  2. Add a release notes.

The builtin function __builtin_dump_struct behaves for zero-width bitfield and unnamed bitfield as follows

int printf(const char *fmt, ...);

void foo(void) {
  struct Bar {
    unsigned c : 1;
    unsigned : 3;
    unsigned : 0;
    unsigned b;
  };

  struct Bar a = {
    .c = 1,
    .b = 2022,
  };

  __builtin_dump_struct(&a, &printf);
}

int main() {
  foo();
  return 0;
}

Output:

struct Bar {
unsigned int c : 1
unsigned int  : 0
unsigned int b : 2022
}

Thank you for the release note and additional test coverage. I'm wondering why we handle the zero-width bit-field differently from the anonymous one (e.g., why do we not have unsigned int : 3 before the unsigned int : 0? It seems a bit odd to drop that from the output.

Mar 23 2022, 11:50 AM · Restricted Project, Restricted Project, Restricted Project