Skip to content

Commit

Permalink
Avoid using subtarget features when adding X86 specific passes to
Browse files Browse the repository at this point in the history
the pass pipeline.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@209382 91177308-0d34-0410-b5e6-96231b3b80d8
  • Loading branch information
echristo committed May 22, 2014
1 parent 1e264de commit 26bbeec
Show file tree
Hide file tree
Showing 5 changed files with 17 additions and 14 deletions.
4 changes: 4 additions & 0 deletions lib/Target/X86/X86FixupLEAs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ FunctionPass *llvm::createX86FixupLEAs() {

bool FixupLEAPass::runOnMachineFunction(MachineFunction &Func) {
TM = &Func.getTarget();
const X86Subtarget &ST = TM->getSubtarget<X86Subtarget>();
if (!ST.LEAusesAG() && !ST.slowLEA())
return false;

TII = static_cast<const X86InstrInfo*>(TM->getInstrInfo());

DEBUG(dbgs() << "Start X86FixupLEAs\n";);
Expand Down
6 changes: 4 additions & 2 deletions lib/Target/X86/X86InstrInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5395,8 +5395,10 @@ namespace {
const X86TargetMachine *TM =
static_cast<const X86TargetMachine *>(&MF.getTarget());

assert(!TM->getSubtarget<X86Subtarget>().is64Bit() &&
"X86-64 PIC uses RIP relative addressing");
// Don't do anything if this is 64-bit as 64-bit PIC
// uses RIP relative addressing.
if (TM->getSubtarget<X86Subtarget>().is64Bit())
return false;

// Only emit a global base reg in PIC mode.
if (TM->getRelocationModel() != Reloc::PIC_)
Expand Down
4 changes: 4 additions & 0 deletions lib/Target/X86/X86PadShortFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

#include "X86.h"
#include "X86InstrInfo.h"
#include "X86Subtarget.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/CodeGen/MachineFunctionPass.h"
#include "llvm/CodeGen/MachineInstrBuilder.h"
Expand Down Expand Up @@ -101,6 +102,9 @@ bool PadShortFunc::runOnMachineFunction(MachineFunction &MF) {
}

TM = &MF.getTarget();
if (!TM->getSubtarget<X86Subtarget>().padShortFunctions())
return false;

TII = TM->getInstrInfo();

// Search through basic blocks and mark the ones that have early returns
Expand Down
14 changes: 3 additions & 11 deletions lib/Target/X86/X86TargetMachine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -178,9 +178,7 @@ bool X86PassConfig::addInstSelector() {
if (getX86Subtarget().isTargetELF() && getOptLevel() != CodeGenOpt::None)
addPass(createCleanupLocalDynamicTLSPass());

// For 32-bit, prepend instructions to set the "global base reg" for PIC.
if (!getX86Subtarget().is64Bit())
addPass(createX86GlobalBaseRegPass());
addPass(createX86GlobalBaseRegPass());

return false;
}
Expand All @@ -206,19 +204,13 @@ bool X86PassConfig::addPreEmitPass() {
ShouldPrint = true;
}

if (getX86Subtarget().hasAVX() && UseVZeroUpper) {
if (UseVZeroUpper) {
addPass(createX86IssueVZeroUpperPass());
ShouldPrint = true;
}

if (getOptLevel() != CodeGenOpt::None &&
getX86Subtarget().padShortFunctions()) {
if (getOptLevel() != CodeGenOpt::None) {
addPass(createX86PadShortFunctions());
ShouldPrint = true;
}
if (getOptLevel() != CodeGenOpt::None &&
(getX86Subtarget().LEAusesAG() ||
getX86Subtarget().slowLEA())){
addPass(createX86FixupLEAs());
ShouldPrint = true;
}
Expand Down
3 changes: 2 additions & 1 deletion lib/Target/X86/X86VZeroUpper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ void VZeroUpperInserter::processBasicBlock(MachineBasicBlock &MBB) {
/// runOnMachineFunction - Loop over all of the basic blocks, inserting
/// vzero upper instructions before function calls.
bool VZeroUpperInserter::runOnMachineFunction(MachineFunction &MF) {
if (MF.getTarget().getSubtarget<X86Subtarget>().hasAVX512())
const X86Subtarget &ST = MF.getTarget().getSubtarget<X86Subtarget>();
if (!ST.hasAVX() || ST.hasAVX512())
return false;
TII = MF.getTarget().getInstrInfo();
MachineRegisterInfo &MRI = MF.getRegInfo();
Expand Down

0 comments on commit 26bbeec

Please sign in to comment.