[PATCH] D131245: [X86] Move getting module flag into `runOnMachineFunction` to reduce compile-time. NFCI

Phoebe Wang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 5 00:50:29 PDT 2022


pengfei created this revision.
pengfei added a reviewer: nikic.
Herald added a subscriber: hiraditya.
Herald added a project: All.
pengfei requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D131245

Files:
  llvm/lib/Target/X86/X86AsmPrinter.cpp
  llvm/lib/Target/X86/X86AsmPrinter.h
  llvm/lib/Target/X86/X86MCInstLower.cpp


Index: llvm/lib/Target/X86/X86MCInstLower.cpp
===================================================================
--- llvm/lib/Target/X86/X86MCInstLower.cpp
+++ llvm/lib/Target/X86/X86MCInstLower.cpp
@@ -2449,9 +2449,6 @@
   if (OutStreamer->isVerboseAsm())
     addConstantComments(MI, *OutStreamer);
 
-  bool IndCS =
-      MF->getMMI().getModule()->getModuleFlag("indirect_branch_cs_prefix");
-
   switch (MI->getOpcode()) {
   case TargetOpcode::DBG_VALUE:
     llvm_unreachable("Should be handled target independently");
@@ -2501,7 +2498,7 @@
   }
 
   case X86::TAILJMPd64:
-    if (IndCS && MI->hasRegisterImplicitUseOperand(X86::R11))
+    if (IndCSPrefix && MI->hasRegisterImplicitUseOperand(X86::R11))
       EmitAndCountInstruction(MCInstBuilder(X86::CS_PREFIX));
     LLVM_FALLTHROUGH;
   case X86::TAILJMPr:
@@ -2684,7 +2681,7 @@
                                 .addReg(X86::NoRegister));
     return;
   case X86::CALL64pcrel32:
-    if (IndCS && MI->hasRegisterImplicitUseOperand(X86::R11))
+    if (IndCSPrefix && MI->hasRegisterImplicitUseOperand(X86::R11))
       EmitAndCountInstruction(MCInstBuilder(X86::CS_PREFIX));
     break;
   }
Index: llvm/lib/Target/X86/X86AsmPrinter.h
===================================================================
--- llvm/lib/Target/X86/X86AsmPrinter.h
+++ llvm/lib/Target/X86/X86AsmPrinter.h
@@ -31,6 +31,7 @@
   std::unique_ptr<MCCodeEmitter> CodeEmitter;
   bool EmitFPOData = false;
   bool ShouldEmitWeakSwiftAsyncExtendedFramePointerFlags = false;
+  bool IndCSPrefix = false;
 
   // This utility class tracks the length of a stackmap instruction's 'shadow'.
   // It is used by the X86AsmPrinter to ensure that the stackmap shadow
Index: llvm/lib/Target/X86/X86AsmPrinter.cpp
===================================================================
--- llvm/lib/Target/X86/X86AsmPrinter.cpp
+++ llvm/lib/Target/X86/X86AsmPrinter.cpp
@@ -86,6 +86,9 @@
 
   EmitFPOData = false;
 
+  IndCSPrefix =
+      MF.getMMI().getModule()->getModuleFlag("indirect_branch_cs_prefix");
+
   // We didn't modify anything.
   return false;
 }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131245.450249.patch
Type: text/x-patch
Size: 2085 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220805/e3718e24/attachment.bin>


More information about the llvm-commits mailing list