This is an archive of the discontinued LLVM Phabricator instance.

Add path to lower addrspacecasts in constant exprs for __ptr32/__ptr64.
Changes PlannedPublic

Authored by akhuang on Nov 10 2021, 4:41 PM.

Details

Summary

This is for addrspacecasts to ms ptr32 and ptr64 pointers that
occur in global variables. It adds an X86 override for
AsmPrinter::emitGlobalConstant that deals with zext to 64-bit pointers
and trunc when casting to 32-bit pointers.

Bug: https://bugs.llvm.org/show_bug.cgi?id=51888

Diff Detail

Event Timeline

akhuang created this revision.Nov 10 2021, 4:41 PM
akhuang requested review of this revision.Nov 10 2021, 4:41 PM
Herald added a project: Restricted Project. · View Herald TranscriptNov 10 2021, 4:41 PM
arsenm added inline comments.Nov 10 2021, 4:51 PM
llvm/lib/Target/X86/X86AsmPrinter.cpp
145

Would it be easier to just add a new callback to handle addrspacecast instead of having to reproduce some of the generic logic and call into the default implementation

JohnReagan added inline comments.
llvm/lib/Target/X86/X86AsmPrinter.cpp
138

What would the sign-extended form look like? Is it much harder to add? I thought I remember you have both signed and zero extended in other places? (I'm biased since OpenVMS wants sign-extended behavior)

akhuang planned changes to this revision.Nov 11 2021, 11:22 AM
akhuang added inline comments.
llvm/lib/Target/X86/X86AsmPrinter.cpp
138

I think I'll have to add some code in the frontend to avoid making these constant exprs for some or all of these addrspacecasts....

145

Yeah, that'd be better; I think the version in this patch is missing a bunch of logic as well.