Skip to content

Commit

Permalink
[X86] Move getting module flag into runOnMachineFunction to reduce …
Browse files Browse the repository at this point in the history
…compile-time. NFCI

Reviewed By: nikic

Differential Revision: https://reviews.llvm.org/D131245
  • Loading branch information
phoebewang committed Aug 5, 2022
1 parent 45c056b commit 2312b74
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
5 changes: 5 additions & 0 deletions llvm/lib/Target/X86/X86AsmPrinter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,9 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {
EmitFPOData =
Subtarget->isTargetWin32() && MF.getMMI().getModule()->getCodeViewFlag();

IndCSPrefix =
MF.getMMI().getModule()->getModuleFlag("indirect_branch_cs_prefix");

SetupMachineFunction(MF);

if (Subtarget->isTargetCOFF()) {
Expand All @@ -86,6 +89,8 @@ bool X86AsmPrinter::runOnMachineFunction(MachineFunction &MF) {

EmitFPOData = false;

IndCSPrefix = false;

// We didn't modify anything.
return false;
}
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/X86/X86AsmPrinter.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ class LLVM_LIBRARY_VISIBILITY X86AsmPrinter : public AsmPrinter {
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
Expand Down
7 changes: 2 additions & 5 deletions llvm/lib/Target/X86/X86MCInstLower.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2449,9 +2449,6 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
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");
Expand Down Expand Up @@ -2501,7 +2498,7 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
}

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:
Expand Down Expand Up @@ -2684,7 +2681,7 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
.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;
}
Expand Down

0 comments on commit 2312b74

Please sign in to comment.