This is an archive of the discontinued LLVM Phabricator instance.

[MS] Preserve base register %rbx around cpuid
ClosedPublic

Authored by pengfei on Apr 26 2021, 7:51 PM.

Details

Summary

This patch copies implementation from cpuid.h, which preserve base register %rbx around cpuid. It fixes PR50133.

Diff Detail

Event Timeline

pengfei requested review of this revision.Apr 26 2021, 7:51 PM
pengfei created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptApr 26 2021, 7:51 PM
Herald added a subscriber: cfe-commits. · View Herald Transcript
pengfei updated this revision to Diff 340718.Apr 26 2021, 8:32 PM

Update for test.

If I remember correctly cpuid.h implementation handles this. Can we copy that?

pengfei updated this revision to Diff 340730.Apr 26 2021, 10:56 PM

Yes, it is a pretty implementation. Thanks Craig.

pengfei retitled this revision from [MS] Fix crash when calling __cpuid with /EHsc and -mavx2 to [MS] Preserve base register %rbx around cpuid.Apr 26 2021, 10:58 PM
pengfei edited the summary of this revision. (Show Details)
rnk accepted this revision.Apr 29 2021, 1:35 PM

Seems reasonable, thanks.

We really ought to solve the general problem one day. It is kind of pig-headed that the backend just picks two arbitrary CSRs, the base and frame pointers, and doesn't bother checking if any instructions clobber those registers.

This revision is now accepted and ready to land.Apr 29 2021, 1:35 PM
This revision was landed with ongoing or failed builds.Apr 29 2021, 7:16 PM
This revision was automatically updated to reflect the committed changes.

Seems reasonable, thanks.

We really ought to solve the general problem one day. It is kind of pig-headed that the backend just picks two arbitrary CSRs, the base and frame pointers, and doesn't bother checking if any instructions clobber those registers.

Agreed. Thanks Reid.