Page MenuHomePhabricator

[codeview] Translate basic DITypes to CV type records
ClosedPublic

Authored by rnk on May 31 2016, 3:51 PM.

Details

Summary

This is meant to be the tiniest step towards DIType to CV type index
translation that I could come up with. Whenever translation fails, we use type
index zero, which is the unknown type.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk updated this revision to Diff 59142.May 31 2016, 3:51 PM
rnk updated this revision to Diff 59143.
rnk retitled this revision from to [codeview] Translate basic DITypes to CV type records.
rnk updated this object.
rnk added reviewers: aaboud, zturner.
rnk added subscribers: amccarth, llvm-commits.
  • Add missing test
zturner added inline comments.May 31 2016, 4:01 PM
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
811–812 ↗(On Diff #59143)
else if (ByteSize == 2)
  STK = SimpleTypeKind::Character16;
else if (ByteSize == 4)
  STK = SimpleTypeKind::Character32;

Is there any way to distinguish wchar_t from DW_ATE_unsigned_char with ByteSize == 2?

majnemer added inline comments.
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
780 ↗(On Diff #59143)

I think this is for stuff like _Decimal64, we shouldn't map it to floats...

The closest thing I can think of is the currency type.

895–897 ↗(On Diff #59143)

Todo for unaligned?
Also, should we set flat?

majnemer added inline comments.May 31 2016, 4:05 PM
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
811–812 ↗(On Diff #59143)

The BasicType's name maybe?

zturner added inline comments.May 31 2016, 4:06 PM
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
857–859 ↗(On Diff #59143)

Is this true? Surely there has to be a PointerOptions on a non member pointer.

rnk added inline comments.May 31 2016, 4:54 PM
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
780 ↗(On Diff #59143)

Eh, let's remove it. I'll give you a dollar if a real user complains in the next year.

811–812 ↗(On Diff #59143)

Ooh, all the character types are all messed up. That needs real work... Added some stuff.

857–859 ↗(On Diff #59143)

It's related to method 'this' pointers, not member pointers. This is the test case I can use to get them to fill in PointerOptions:

struct A {
  const int *a;
  void f() const;
};
void A::f() const {}
A a;

It's used for the const qualification on the 'this' parameter of A::f, but not the const qualifier on the const int *a; field. In that case, they use an LF_MODIFIER record.

895–897 ↗(On Diff #59143)

Yeah, there's unaligned and also a similar issue with __restrict. I can't convince MSVC to set IsFlat, so I left it off.

rnk updated this revision to Diff 59153.May 31 2016, 4:54 PM
  • Translate character types better

Do we have a test for char vs signed char? What about /J ?

rnk added a comment.May 31 2016, 5:12 PM

Do we have a test for char vs signed char?

Yes.

What about /J ?

They don't change their type emission. If you explicitly wrote signed/unsigned, you get SignedCharacter/UnsignedCharacter. If you don't, you get NarrowCharacter. Our approach of checking the name give the same behavior.

rnk updated this revision to Diff 59158.May 31 2016, 5:12 PM
  • Fix up some 16 bit type issues
majnemer added inline comments.May 31 2016, 6:16 PM
lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
824–827 ↗(On Diff #59158)

I don't see a test for this. long x; gives me "long int".

rnk updated this revision to Diff 59165.May 31 2016, 6:25 PM
  • Fix long handling
majnemer accepted this revision.May 31 2016, 7:05 PM
majnemer added a reviewer: majnemer.

LGTM!

We should have a todo for:

using HRESULT = long;
HRESULT an_hresult;

MSVC emits:

(000070) S_GDATA32: [0000:00000000], Type: T_HRESULT(0008), an_hresult

lib/CodeGen/AsmPrinter/CodeViewDebug.cpp
757 ↗(On Diff #59165)

Divide by eight for consistency?

This revision is now accepted and ready to land.May 31 2016, 7:05 PM
This revision was automatically updated to reflect the committed changes.
rnk added a comment.Jun 1 2016, 10:14 AM

Amjad, I went ahead and landed this. I know it conflicts with what you're working on, but I didn't see any updates at http://reviews.llvm.org/D20435 and this is the most important thing for me to work on. Hopefully we agree on the direction we're going here, I'll try to work very incrementally and CC you on every patch. I was going to look at POD structs (ignoring C++ methods) and function types next.

aaboud edited edge metadata.Jun 1 2016, 1:58 PM
In D20840#445895, @rnk wrote:

Amjad, I went ahead and landed this. I know it conflicts with what you're working on, but I didn't see any updates at http://reviews.llvm.org/D20435 and this is the most important thing for me to work on. Hopefully we agree on the direction we're going here, I'll try to work very incrementally and CC you on every patch. I was going to look at POD structs (ignoring C++ methods) and function types next.

I intended to update D20435 (was waiting for your other patch of improving codeview assembly readability).
Anyway, I stopped working on D20435 once I noticed this patch.
Sorry, I did not have enough time to review it yet, but I will do soon and let you know if there is any change need to be done.