Skip to content

[TII][X86] Do not schedule frame-setup/frame-destory instructions #96611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 26, 2024

Conversation

HaohaiWen
Copy link
Contributor

frame-setup/frame-destroy instruction can not be scheduled around by
PostRAScheduler. Their order is critical for SEH.

frame-setup/frame-destroy instruction can not be scheduled around by
PostRAScheduler. Their order is critical for SEH.
@HaohaiWen HaohaiWen requested a review from phoebewang June 25, 2024 09:25
@HaohaiWen
Copy link
Contributor Author

Test case is related to schedule model is not easy to create.

@HaohaiWen HaohaiWen changed the title [TII] Do not schedule frame-setup/frame-destory instructions [TII][X86] Do not schedule frame-setup/frame-destory instructions Jun 26, 2024
@llvmbot
Copy link
Member

llvmbot commented Jun 26, 2024

@llvm/pr-subscribers-backend-x86

Author: Haohai Wen (HaohaiWen)

Changes

frame-setup/frame-destroy instruction can not be scheduled around by
PostRAScheduler. Their order is critical for SEH.


Full diff: https://github.com/llvm/llvm-project/pull/96611.diff

1 Files Affected:

  • (modified) llvm/lib/Target/X86/X86InstrInfo.cpp (+5)
diff --git a/llvm/lib/Target/X86/X86InstrInfo.cpp b/llvm/lib/Target/X86/X86InstrInfo.cpp
index 1a43d5c17080e..069a1ec9a5988 100644
--- a/llvm/lib/Target/X86/X86InstrInfo.cpp
+++ b/llvm/lib/Target/X86/X86InstrInfo.cpp
@@ -8832,6 +8832,11 @@ bool X86InstrInfo::isSchedulingBoundary(const MachineInstr &MI,
       Opcode == X86::PLDTILECFGV)
     return true;
 
+  // Frame setup and destory can't be scheduled around.
+  if (MI.getFlag(MachineInstr::FrameSetup) ||
+      MI.getFlag(MachineInstr::FrameDestroy))
+    return true;
+
   return TargetInstrInfo::isSchedulingBoundary(MI, MBB, MF);
 }
 

@KanRobert KanRobert self-requested a review June 26, 2024 04:05
@@ -8832,6 +8832,11 @@ bool X86InstrInfo::isSchedulingBoundary(const MachineInstr &MI,
Opcode == X86::PLDTILECFGV)
return true;

// Frame setup and destory can't be scheduled around.
if (MI.getFlag(MachineInstr::FrameSetup) ||
MI.getFlag(MachineInstr::FrameDestroy))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we put it in TargetInstrInfo::isSchedulingBoundary?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of arm tests would fail.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If arm accepts scheduling with frame setup and destory, why can't for X86?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Failed arm tests: https://buildkite.com/llvm-project/github-pull-requests/builds/75530#01904eb7-13d0-451e-b1da-bcb86cd44b60

.seh_savexmm %xmm15, 544
.seh_endprologue

For X86, most of frame-setup instruction is related to SEH exception restore.
Changing part of its order does not matter. e.g. two independent register save instructions.
Part of them does matter. e.g. .seh_pushreg, moving .seh_endprologue which may affect prologue size.

Anyway, rescheduling frame-setup instruction does not look like profitable for X86.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can't see the reason from the log, but I'm good with this change as long as no performance regression for X86.

Copy link
Contributor

@phoebewang phoebewang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

Copy link
Contributor

@KanRobert KanRobert left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@HaohaiWen HaohaiWen merged commit be00190 into llvm:main Jun 26, 2024
8 checks passed
@HaohaiWen
Copy link
Contributor Author

Thanks

@HaohaiWen HaohaiWen deleted the tii branch June 26, 2024 09:09
lravenclaw pushed a commit to lravenclaw/llvm-project that referenced this pull request Jul 3, 2024
…vm#96611)

frame-setup/frame-destroy instruction can not be scheduled around by
PostRAScheduler. Their order is critical for SEH.
AlexisPerry pushed a commit to llvm-project-tlp/llvm-project that referenced this pull request Jul 9, 2024
…vm#96611)

frame-setup/frame-destroy instruction can not be scheduled around by
PostRAScheduler. Their order is critical for SEH.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants