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.