This is an archive of the discontinued LLVM Phabricator instance.

OpaquePtr: print byval types containing anonymous types correctly.
ClosedPublic

Authored by t.p.northover on Jan 7 2020, 4:03 AM.

Details

Reviewers
dblaikie
arsenm
Summary

While implementing inalloca types I discovered an issue with how we print attribute types (currently just byval). If the specified type references an anonymous Module-level one, the Attribute::getAsString function doesn't have the necessary context to figure out its number, so you'll see something like

%0 = type opaque

define void @foo(<{ %0* }>* byval(<{ %"type 0x7fe75580a800"* }>) %a) {
  ret void
}

This patch puts the Attribute printing logic into AsmWriter for this case, where TypePrinting is available to do the right thing. I only applied it to function argument attributes because that's the only attribute that can have a type currently, but would be happy to be more aggressive.

It's also worth noting that the Verifier is still affected by this issue when printing its messages, but I decided that was probably OK since there should be other context to figure out the problem location.

Diff Detail

Event Timeline

t.p.northover created this revision.Jan 7 2020, 4:03 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 7 2020, 4:03 AM

Relised I should test all modified places that print attrs.

arsenm accepted this revision.Jan 7 2020, 6:20 AM
arsenm added a subscriber: arsenm.

LGTM

This revision is now accepted and ready to land.Jan 7 2020, 6:20 AM
t.p.northover closed this revision.Jan 7 2020, 7:12 AM

Thanks Matt. Pushed:

To github.com:llvm/llvm-project.git

f26ed6e47cb8..e130eef58814  HEAD -> master