This is an archive of the discontinued LLVM Phabricator instance.

[X86] Only force FP usage in the presence of pushf/popf on Win64
ClosedPublic

Authored by rnk on Feb 9 2022, 4:46 PM.

Details

Summary

This ensures that the Windows unwinder will work at every instruction
boundary, and allows other targets to read and write flags without
setting up a frame pointer.

Diff Detail

Event Timeline

rnk created this revision.Feb 9 2022, 4:46 PM
rnk requested review of this revision.Feb 9 2022, 4:46 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 9 2022, 4:46 PM
nickdesaulniers added inline comments.Feb 9 2022, 4:48 PM
llvm/lib/Target/X86/X86FrameLowering.cpp
103

isWin64Prologue(MF) &&

rnk updated this revision to Diff 407351.Feb 9 2022, 4:54 PM
  • use a helper
nickdesaulniers accepted this revision.Feb 9 2022, 5:20 PM

This approach works, too (in addition to D92695) and is simpler (though, should X86FrameLowering::has128ByteRedZone now return false for frame using the intrinsics that aren't wincfi? If so, then modification to that method too will degenerate into D92695).

Consider whether D119382 still has value; if it does, perhaps it should land first and/or this patch made a child of it; otherwise happy to abandon it.

Also, in D92695, I modify llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll. I'm not sure what's preferred for that test. PTAL

It would be helpful to have in the commit message for this patch that it

Fixes: https://github.com/llvm/llvm-project/issues/46875

This revision is now accepted and ready to land.Feb 9 2022, 5:20 PM
rnk added a comment.Feb 9 2022, 6:22 PM

This approach works, too (in addition to D92695) and is simpler (though, should X86FrameLowering::has128ByteRedZone now return false for frame using the intrinsics that aren't wincfi? If so, then modification to that method too will degenerate into D92695).

Yeah, my understanding of has128ByteRedZone is that it is meant to be a target check: does the target have a redzone by convention? So, I think it makes sense to keep the function-specific compatibility checks at the call site where it is used.

Consider whether D119382 still has value; if it does, perhaps it should land first and/or this patch made a child of it; otherwise happy to abandon it.

Now that I found the existing in tree x86-64-flags-intrinsics test, I think we could skip that new test.

Also, in D92695, I modify llvm/test/CodeGen/X86/x86-64-flags-intrinsics.ll. I'm not sure what's preferred for that test. PTAL

You know I went looking for that, but did not find it... I will update it to have it check win64 and linux codegen, since those behave differently now.

It would be helpful to have in the commit message for this patch that it

Fixes: https://github.com/llvm/llvm-project/issues/46875

Sure.

This revision was landed with ongoing or failed builds.Feb 9 2022, 6:23 PM
This revision was automatically updated to reflect the committed changes.

Is there a test which uses flags.read with an alloca to ensure that we obey the redzone rules?