From d2e7196d0a1b33b16b4693a3278ca2f580bf0f0e Mon Sep 17 00:00:00 2001 From: Davide Italiano Date: Fri, 17 Jun 2016 18:07:14 +0000 Subject: [PATCH] [Codegen] Change PICLevel. We convert `Default` to `NotPIC` so that target independent code can reason about this correctly. Differential Revision: http://reviews.llvm.org/D21394 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273024 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Support/CodeGen.h | 3 ++- lib/IR/Module.cpp | 2 +- lib/Target/PowerPC/PPCAsmPrinter.cpp | 6 +++--- lib/Target/PowerPC/PPCISelDAGToDAG.cpp | 2 +- lib/Target/PowerPC/PPCISelLowering.cpp | 4 ++-- 5 files changed, 9 insertions(+), 8 deletions(-) diff --git a/include/llvm/Support/CodeGen.h b/include/llvm/Support/CodeGen.h index 554c900e3bb..e19abf8271e 100644 --- a/include/llvm/Support/CodeGen.h +++ b/include/llvm/Support/CodeGen.h @@ -29,7 +29,8 @@ namespace llvm { } namespace PICLevel { - enum Level { Default=0, Small=1, Large=2 }; + // This is used to map -fpic/-fPIC. + enum Level { NotPIC=0, SmallPIC=1, BigPIC=2 }; } namespace PIELevel { diff --git a/lib/IR/Module.cpp b/lib/IR/Module.cpp index b15cac40274..f229e2b3702 100644 --- a/lib/IR/Module.cpp +++ b/lib/IR/Module.cpp @@ -487,7 +487,7 @@ PICLevel::Level Module::getPICLevel() const { auto *Val = cast_or_null(getModuleFlag("PIC Level")); if (!Val) - return PICLevel::Default; + return PICLevel::NotPIC; return static_cast( cast(Val->getValue())->getZExtValue()); diff --git a/lib/Target/PowerPC/PPCAsmPrinter.cpp b/lib/Target/PowerPC/PPCAsmPrinter.cpp index bb1ab2e9889..b43f51df602 100644 --- a/lib/Target/PowerPC/PPCAsmPrinter.cpp +++ b/lib/Target/PowerPC/PPCAsmPrinter.cpp @@ -601,7 +601,7 @@ void PPCAsmPrinter::EmitInstruction(const MachineInstr *MI) { else if (MO.isBlockAddress()) MOSymbol = GetBlockAddressSymbol(MO.getBlockAddress()); - if (PL == PICLevel::Small) { + if (PL == PICLevel::SmallPIC) { const MCExpr *Exp = MCSymbolRefExpr::create(MOSymbol, MCSymbolRefExpr::VK_GOT, OutContext); @@ -1045,7 +1045,7 @@ void PPCLinuxAsmPrinter::EmitStartOfAsmFile(Module &M) { TM.getRelocationModel() != Reloc::PIC_) return AsmPrinter::EmitStartOfAsmFile(M); - if (M.getPICLevel() == PICLevel::Small) + if (M.getPICLevel() == PICLevel::SmallPIC) return AsmPrinter::EmitStartOfAsmFile(M); OutStreamer->SwitchSection(OutContext.getELFSection( @@ -1072,7 +1072,7 @@ void PPCLinuxAsmPrinter::EmitFunctionEntryLabel() { // linux/ppc32 - Normal entry label. if (!Subtarget->isPPC64() && (TM.getRelocationModel() != Reloc::PIC_ || - MF->getFunction()->getParent()->getPICLevel() == PICLevel::Small)) + MF->getFunction()->getParent()->getPICLevel() == PICLevel::SmallPIC)) return AsmPrinter::EmitFunctionEntryLabel(); if (!Subtarget->isPPC64()) { diff --git a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp index eeb5a07c251..0e9b2daa0cb 100644 --- a/lib/Target/PowerPC/PPCISelDAGToDAG.cpp +++ b/lib/Target/PowerPC/PPCISelDAGToDAG.cpp @@ -319,7 +319,7 @@ SDNode *PPCDAGToDAGISel::getGlobalBaseReg() { if (PPCLowering->getPointerTy(CurDAG->getDataLayout()) == MVT::i32) { if (PPCSubTarget->isTargetELF()) { GlobalBaseReg = PPC::R30; - if (M->getPICLevel() == PICLevel::Small) { + if (M->getPICLevel() == PICLevel::SmallPIC) { BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MoveGOTtoLR)); BuildMI(FirstMBB, MBBI, dl, TII.get(PPC::MFLR), GlobalBaseReg); MF->getInfo()->setUsesPICBase(true); diff --git a/lib/Target/PowerPC/PPCISelLowering.cpp b/lib/Target/PowerPC/PPCISelLowering.cpp index 31197fd8304..22ae871dc6b 100644 --- a/lib/Target/PowerPC/PPCISelLowering.cpp +++ b/lib/Target/PowerPC/PPCISelLowering.cpp @@ -2172,7 +2172,7 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op, GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSGD_HA, dl, PtrVT, GOTReg, TGA); } else { - if (picLevel == PICLevel::Small) + if (picLevel == PICLevel::SmallPIC) GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT); else GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT); @@ -2190,7 +2190,7 @@ SDValue PPCTargetLowering::LowerGlobalTLSAddress(SDValue Op, GOTPtr = DAG.getNode(PPCISD::ADDIS_TLSLD_HA, dl, PtrVT, GOTReg, TGA); } else { - if (picLevel == PICLevel::Small) + if (picLevel == PICLevel::SmallPIC) GOTPtr = DAG.getNode(PPCISD::GlobalBaseReg, dl, PtrVT); else GOTPtr = DAG.getNode(PPCISD::PPC32_PICGOT, dl, PtrVT);