This is an archive of the discontinued LLVM Phabricator instance.

[TargetMachine] Move COFF special case for ExternalSymbolSDNode from shouldAssumeDSOLocal to X86Subtarget
ClosedPublic

Authored by MaskRay on Aug 21 2021, 1:06 PM.

Details

Summary

Intended to be NFC. ARM/AArch64 don't appear to need adjustment.

TargetMachine::shouldAssumeDSOLocal is expected to be very simple, ideally
matching isDSOLocal(). The IR producers are expected to set dso_local correctly.
(While some may think this function can make producers' work easier, the
function is really not in a good position to set dso_local. See the various
special cases we duplicate from clang CodeGenModule.cpp.)

Diff Detail

Event Timeline

MaskRay created this revision.Aug 21 2021, 1:06 PM
MaskRay requested review of this revision.Aug 21 2021, 1:06 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 21 2021, 1:06 PM

Intended to be NFC. ARM/AArch64 don't appear to need adjustment.

Hmm, it seems like the COFF specific code that this refers to has gone through a couple refactorings since I touched it, so I don't remember exactly which things it refers to and when that check was needed. My main concern is if the conclusion that the ARM/AArch64 codepaths don't need adjustment comes from some supposedly COFF-generic test only is executed for x86.

It's also plausible that it just isn't needed there, because those corresponding arm/aarch64 subtarget functions for classifying references are indeed a little bit different than the x86 one.

In practice, I did include this patch in my nightly test run (running things for all 4 architectures, which should try out many of the mingw specific edge cases) and didn't run into any issues with it - so I guess it should be practically fine...

MaskRay added a comment.EditedAug 23 2021, 9:15 AM

FYI I use this script to test end-to-end behavior of .c => .s: https://gist.github.com/MaskRay/c03a90922003df666551589f1629df22

The following configurations's codegen stay unchanged. So this should be safe.

run win.x86 -target x86_64-windows
run win.x86.asan -target x86_64-windows -fsanitize=address
run win.x86.coverage -target x86_64-windows -fprofile-instr-generate
run win.x86.pgo -target x86_64-windows -fprofile-generate

run mingw.x86 -target x86_64-windows-gnu
run mingw.x86.nopic -target x86_64-windows-gnu -fno-pic
run mingw.x86.asan -target x86_64-windows-gnu -fsanitize=address
run mingw.x86.coverage -target x86_64-windows-gnu -fprofile-instr-generate
run mingw.x86.pgo -target x86_64-windows-gnu -fprofile-generate

run win.arm -target arm-windows
run win.arm.asan -target arm-windows -fsanitize=address

run win.a64 -target aarch64-windows
run win.a64.asan -target aarch64-windows -fsanitize=address

If there is arm/aarch64 coverage issue, it can't be this patch's fault:)

mstorsjo accepted this revision.Aug 23 2021, 12:14 PM

FYI I use this script to test end-to-end behavior of .c => .s: https://gist.github.com/MaskRay/c03a90922003df666551589f1629df22

Awesome, thanks for being thorough in checking it!

I can't come up with anything else right now to check, so I guess there's no reason to hold this back then.

This revision is now accepted and ready to land.Aug 23 2021, 12:14 PM