This is an archive of the discontinued LLVM Phabricator instance.

[AArch64] Fix emitting an AdrpAddLdr LOH when there's a potential clobber of the def of the adrp before the ldr.
ClosedPublic

Authored by aemerson on Feb 26 2021, 12:18 PM.

Details

Summary

Apparently this pass used to have liveness analysis but it was removed for scompile time reasons. This workaround prevents the LOH from being emitted unless the ADD and LDR are adjacent.

Fixes https://github.com/JuliaLang/julia/issues/39820

Diff Detail

Event Timeline

aemerson created this revision.Feb 26 2021, 12:18 PM
aemerson requested review of this revision.Feb 26 2021, 12:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 26 2021, 12:18 PM
qcolombet accepted this revision.Feb 26 2021, 2:43 PM
qcolombet added inline comments.
llvm/lib/Target/AArch64/AArch64CollectLOH.cpp
444

I think AddMI->getIterator() == EndIt shouldn't be possible, otherwise we won't have a load in MI2.

I haven't looked at that code for a long time but I think that when you'll look for a proper fix, you should be able to use handleClobber to accumulate the registers that are clobbered between two instructions.

You may actually use that right now to still only issue this LOH when all the possible optimizations are safe.

This revision is now accepted and ready to land.Feb 26 2021, 2:43 PM
loladiro accepted this revision.Mar 1 2021, 12:28 PM

Verified to fix the crash we were seeing downstream as well.