[llvm] r269909 - Don't pass a Reloc::Model to MC.

Steven Wu via llvm-commits llvm-commits at lists.llvm.org
Fri Aug 26 13:41:46 PDT 2016


Hi Rafael

There is a problem I run into for this commit. It is related to DynamicNoPIC relation model. DynamicNoPIC is the a executable loaded at a fixed address but it is allowed to load dynamic libraries. We have users relying this mode to compile certain firmware. This commit breaks the use case by putting the constructors in the wrong section. CC Nick who knows better about the reason and implementation behind this.

> On May 18, 2016, at 4:58 AM, Rafael Espindola via llvm-commits <llvm-commits at lists.llvm.org> wrote:
> 
> Author: rafael
> Date: Wed May 18 06:58:50 2016
> New Revision: 269909
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=269909&view=rev
> Log:
> Don't pass a Reloc::Model to MC.
> 
> MC only needs to know if the output is PIC or not. It never has to
> decide about creating GOTs and PLTs for example. The only thing that
> MC itself uses this information for is expanding "macros" in sparc and
> mips. The rest I am pretty sure could be moved to CodeGen.
> 
> This is a cleanup and isolates the code from future changes to
> Reloc::Model.
> 
> Modified:
>    llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
>    llvm/trunk/lib/MC/MCObjectFileInfo.cpp
>    llvm/trunk/lib/Object/IRObjectFile.cpp
>    llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
>    llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
>    llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
>    llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
>    llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
>    llvm/trunk/test/MC/Mips/cprestore-noreorder-noat.s
>    llvm/trunk/test/MC/Mips/cprestore-noreorder.s
>    llvm/trunk/test/MC/Mips/cprestore-reorder.s
>    llvm/trunk/test/MC/Mips/cprestore-warning-unused.s
>    llvm/trunk/test/MC/Mips/init-order-bug.ll
>    llvm/trunk/test/MC/Sparc/sparc-pic.s
>    llvm/trunk/tools/dsymutil/DwarfLinker.cpp
>    llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
>    llvm/trunk/tools/llvm-mc/llvm-mc.cpp
> 
> Modified: llvm/trunk/include/llvm/MC/MCObjectFileInfo.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/MC/MCObjectFileInfo.h?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/MC/MCObjectFileInfo.h (original)
> +++ llvm/trunk/include/llvm/MC/MCObjectFileInfo.h Wed May 18 06:58:50 2016
> @@ -194,8 +194,8 @@ protected:
>   MCSection *SXDataSection;
> 
> public:
> -  void InitMCObjectFileInfo(const Triple &TT, Reloc::Model RM,
> -                            CodeModel::Model CM, MCContext &ctx);
> +  void InitMCObjectFileInfo(const Triple &TT, bool PIC, CodeModel::Model CM,
> +                            MCContext &ctx);
> 
>   bool getSupportsWeakOmittedEHFrame() const {
>     return SupportsWeakOmittedEHFrame;
> @@ -347,11 +347,11 @@ public:
>   enum Environment { IsMachO, IsELF, IsCOFF };
>   Environment getObjectFileType() const { return Env; }
> 
> -  Reloc::Model getRelocM() const { return RelocM; }
> +  bool isPositionIndependent() const { return PositionIndependent; }
> 
> private:
>   Environment Env;
> -  Reloc::Model RelocM;
> +  bool PositionIndependent;
>   CodeModel::Model CMModel;
>   MCContext *Ctx;
>   Triple TT;
> 
> Modified: llvm/trunk/lib/MC/MCObjectFileInfo.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/MCObjectFileInfo.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/MC/MCObjectFileInfo.cpp (original)
> +++ llvm/trunk/lib/MC/MCObjectFileInfo.cpp Wed May 18 06:58:50 2016
> @@ -177,7 +177,7 @@ void MCObjectFileInfo::initMachOMCObject
>                            MachO::S_THREAD_LOCAL_VARIABLE_POINTERS,
>                            SectionKind::getMetadata());
> 
> -  if (RelocM == Reloc::Static) {
> +  if (!PositionIndependent) {

^ This comparison is not an exact rewrite. For DynamicNoPIC relocation model, it uses "__DATA,__mod_func_init" before but now it goes to "__TEXT,__constructor". Maybe a new field for whether the binary is dynamic is needed. 

Thanks

Steven

>     StaticCtorSection = Ctx->getMachOSection("__TEXT", "__constructor", 0,
>                                              SectionKind::getData());
>     StaticDtorSection = Ctx->getMachOSection("__TEXT", "__destructor", 0,
> @@ -313,18 +313,21 @@ void MCObjectFileInfo::initELFMCObjectFi
>     // Fallthrough if not using EHABI
>   case Triple::ppc:
>   case Triple::x86:
> -    PersonalityEncoding = (RelocM == Reloc::PIC_)
> -     ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
> -     : dwarf::DW_EH_PE_absptr;
> -    LSDAEncoding = (RelocM == Reloc::PIC_)
> -      ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
> -      : dwarf::DW_EH_PE_absptr;
> -    TTypeEncoding = (RelocM == Reloc::PIC_)
> -     ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
> -     : dwarf::DW_EH_PE_absptr;
> +    PersonalityEncoding = PositionIndependent
> +                              ? dwarf::DW_EH_PE_indirect |
> +                                    dwarf::DW_EH_PE_pcrel |
> +                                    dwarf::DW_EH_PE_sdata4
> +                              : dwarf::DW_EH_PE_absptr;
> +    LSDAEncoding = PositionIndependent
> +                       ? dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4
> +                       : dwarf::DW_EH_PE_absptr;
> +    TTypeEncoding = PositionIndependent
> +                        ? dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
> +                              dwarf::DW_EH_PE_sdata4
> +                        : dwarf::DW_EH_PE_absptr;
>     break;
>   case Triple::x86_64:
> -    if (RelocM == Reloc::PIC_) {
> +    if (PositionIndependent) {
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         ((CMModel == CodeModel::Small || CMModel == CodeModel::Medium)
>          ? dwarf::DW_EH_PE_sdata4 : dwarf::DW_EH_PE_sdata8);
> @@ -349,7 +352,7 @@ void MCObjectFileInfo::initELFMCObjectFi
>     LSDAEncoding = dwarf::DW_EH_PE_absptr;
>     FDECFIEncoding = dwarf::DW_EH_PE_absptr;
>     TTypeEncoding = dwarf::DW_EH_PE_absptr;
> -    if (RelocM == Reloc::PIC_){
> +    if (PositionIndependent) {
>       PersonalityEncoding |= dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel;
>       LSDAEncoding |= dwarf::DW_EH_PE_pcrel;
>       FDECFIEncoding |= dwarf::DW_EH_PE_pcrel;
> @@ -361,7 +364,7 @@ void MCObjectFileInfo::initELFMCObjectFi
>     // The small model guarantees static code/data size < 4GB, but not where it
>     // will be in memory. Most of these could end up >2GB away so even a signed
>     // pc-relative 32-bit address is insufficient, theoretically.
> -    if (RelocM == Reloc::PIC_) {
> +    if (PositionIndependent) {
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata8;
>       LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata8;
> @@ -403,7 +406,7 @@ void MCObjectFileInfo::initELFMCObjectFi
>     break;
>   case Triple::sparcel:
>   case Triple::sparc:
> -    if (RelocM == Reloc::PIC_) {
> +    if (PositionIndependent) {
>       LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata4;
> @@ -417,7 +420,7 @@ void MCObjectFileInfo::initELFMCObjectFi
>     break;
>   case Triple::sparcv9:
>     LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
> -    if (RelocM == Reloc::PIC_) {
> +    if (PositionIndependent) {
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata4;
>       TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
> @@ -430,7 +433,7 @@ void MCObjectFileInfo::initELFMCObjectFi
>   case Triple::systemz:
>     // All currently-defined code models guarantee that 4-byte PC-relative
>     // values will be in range.
> -    if (RelocM == Reloc::PIC_) {
> +    if (PositionIndependent) {
>       PersonalityEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel |
>         dwarf::DW_EH_PE_sdata4;
>       LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
> @@ -824,11 +827,10 @@ void MCObjectFileInfo::initCOFFMCObjectF
>                                         SectionKind::getReadOnly());
> }
> 
> -void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple,
> -                                            Reloc::Model relocm,
> +void MCObjectFileInfo::InitMCObjectFileInfo(const Triple &TheTriple, bool PIC,
>                                             CodeModel::Model cm,
>                                             MCContext &ctx) {
> -  RelocM = relocm;
> +  PositionIndependent = PIC;
>   CMModel = cm;
>   Ctx = &ctx;
> 
> 
> Modified: llvm/trunk/lib/Object/IRObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRObjectFile.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Object/IRObjectFile.cpp (original)
> +++ llvm/trunk/lib/Object/IRObjectFile.cpp Wed May 18 06:58:50 2016
> @@ -79,7 +79,7 @@ void IRObjectFile::CollectAsmUndefinedRe
> 
>   MCObjectFileInfo MOFI;
>   MCContext MCCtx(MAI.get(), MRI.get(), &MOFI);
> -  MOFI.InitMCObjectFileInfo(TT, Reloc::Default, CodeModel::Default, MCCtx);
> +  MOFI.InitMCObjectFileInfo(TT, /*PIC*/ false, CodeModel::Default, MCCtx);
>   std::unique_ptr<RecordStreamer> Streamer(new RecordStreamer(MCCtx));
>   T->createNullTargetStreamer(*Streamer);
> 
> 
> Modified: llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/AsmParser/MipsAsmParser.cpp Wed May 18 06:58:50 2016
> @@ -433,8 +433,7 @@ public:
> 
>     CurrentFn = nullptr;
> 
> -    IsPicEnabled =
> -        (getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_);
> +    IsPicEnabled = getContext().getObjectFileInfo()->isPositionIndependent();
> 
>     IsCpRestoreSet = false;
>     CpRestoreOffset = -1;
> 
> Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsTargetStreamer.cpp Wed May 18 06:58:50 2016
> @@ -668,7 +668,7 @@ MipsTargetELFStreamer::MipsTargetELFStre
>   // covers all cases so this statement covers most cases and direct object
>   // emission must call setPic() once MCObjectFileInfo has been initialized. The
>   // cases we don't handle here are covered by MipsAsmPrinter.
> -  Pic = MCA.getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_;
> +  Pic = MCA.getContext().getObjectFileInfo()->isPositionIndependent();
> 
>   const FeatureBitset &Features = STI.getFeatureBits();
> 
> 
> Modified: llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp (original)
> +++ llvm/trunk/lib/Target/Mips/MipsAsmPrinter.cpp Wed May 18 06:58:50 2016
> @@ -674,7 +674,7 @@ void MipsAsmPrinter::EmitStartOfAsmFile(
>   // MipsTargetStreamer has an initialization order problem when emitting an
>   // object file directly (see MipsTargetELFStreamer for full details). Work
>   // around it by re-initializing the PIC state here.
> -  TS.setPic(OutContext.getObjectFileInfo()->getRelocM());
> +  TS.setPic(OutContext.getObjectFileInfo()->isPositionIndependent());
> 
>   // Compute MIPS architecture attributes based on the default subtarget
>   // that we'd have constructed. Module level directives aren't LTO
> 
> Modified: llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp (original)
> +++ llvm/trunk/lib/Target/Sparc/AsmParser/SparcAsmParser.cpp Wed May 18 06:58:50 2016
> @@ -899,8 +899,7 @@ SparcAsmParser::parseSparcAsmOperand(std
> 
>       const MCExpr *Res = MCSymbolRefExpr::create(Sym, MCSymbolRefExpr::VK_None,
>                                                   getContext());
> -      if (isCall &&
> -          getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_)
> +      if (isCall && getContext().getObjectFileInfo()->isPositionIndependent())
>         Res = SparcMCExpr::create(SparcMCExpr::VK_Sparc_WPLT30, Res,
>                                   getContext());
>       Op = SparcOperand::CreateImm(Res, S, E);
> @@ -1221,7 +1220,7 @@ SparcAsmParser::adjustPICRelocation(Spar
>   // actually a %pc10 or %pc22 relocation. Otherwise, they are interpreted
>   // as %got10 or %got22 relocation.
> 
> -  if (getContext().getObjectFileInfo()->getRelocM() == Reloc::PIC_) {
> +  if (getContext().getObjectFileInfo()->isPositionIndependent()) {
>     switch(VK) {
>     default: break;
>     case SparcMCExpr::VK_Sparc_LO:
> 
> Modified: llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp (original)
> +++ llvm/trunk/lib/Target/TargetLoweringObjectFile.cpp Wed May 18 06:58:50 2016
> @@ -43,7 +43,8 @@ using namespace llvm;
> void TargetLoweringObjectFile::Initialize(MCContext &ctx,
>                                           const TargetMachine &TM) {
>   Ctx = &ctx;
> -  InitMCObjectFileInfo(TM.getTargetTriple(), TM.getRelocationModel(),
> +  InitMCObjectFileInfo(TM.getTargetTriple(),
> +                       TM.getRelocationModel() == Reloc::PIC_,
>                        TM.getCodeModel(), *Ctx);
> }
> 
> 
> Modified: llvm/trunk/test/MC/Mips/cprestore-noreorder-noat.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cprestore-noreorder-noat.s?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/cprestore-noreorder-noat.s (original)
> +++ llvm/trunk/test/MC/Mips/cprestore-noreorder-noat.s Wed May 18 06:58:50 2016
> @@ -1,17 +1,17 @@
> -# RUN: not llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj \
> +# RUN: not llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj \
> # RUN:   -o /dev/null 2>&1 | FileCheck %s -check-prefix=O32
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 \
> # RUN:   -filetype=obj -o /dev/null 2>&1 | FileCheck %s -allow-empty -check-prefix=N32
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -target-abi=n32 \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi=n32 \
> # RUN:   -filetype=obj -o /dev/null 2>&1 | FileCheck %s -allow-empty -check-prefix=N64
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -target-abi=n32 \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi=n32 \
> # RUN:   -filetype=obj -o - | llvm-objdump -d -r - | \
> # RUN:   FileCheck %s -check-prefix=NO-STORE
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -relocation-model=pic -filetype=obj -o - | \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -filetype=obj -o - | \
> # RUN:   llvm-objdump -d -r - | \
> # RUN:   FileCheck %s -check-prefix=NO-STORE
> 
> 
> Modified: llvm/trunk/test/MC/Mips/cprestore-noreorder.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cprestore-noreorder.s?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/cprestore-noreorder.s (original)
> +++ llvm/trunk/test/MC/Mips/cprestore-noreorder.s Wed May 18 06:58:50 2016
> @@ -1,20 +1,20 @@
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -show-encoding | \
> # RUN:  FileCheck %s
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj -o -| \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj -o -| \
> # RUN:  llvm-objdump -d -r -arch=mips - | \
> # RUN:   FileCheck %s -check-prefix=CHECK-FOR-STORE
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=MICROMIPS
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=static -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=NO-PIC
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N32
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N64
> 
>   .text
> 
> Modified: llvm/trunk/test/MC/Mips/cprestore-reorder.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cprestore-reorder.s?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/cprestore-reorder.s (original)
> +++ llvm/trunk/test/MC/Mips/cprestore-reorder.s Wed May 18 06:58:50 2016
> @@ -1,20 +1,20 @@
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -show-encoding | \
> # RUN:  FileCheck %s
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic -filetype=obj -o -| \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent -filetype=obj -o -| \
> # RUN:  llvm-objdump -d -r -arch=mips - | \
> # RUN:   FileCheck %s -check-prefix=CHECK-FOR-STORE
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -mattr=+micromips --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=MICROMIPS
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=static -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=NO-PIC
> 
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips64 -target-abi n32 --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N32
> 
> -# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 -relocation-model=pic -show-encoding | \
> +# RUN: llvm-mc %s -arch=mips64 -mcpu=mips64 -target-abi n64 --position-independent -show-encoding | \
> # RUN:  FileCheck %s -check-prefix=BAD-ABI -check-prefix=BAD-ABI-N64
> 
>   .text
> 
> Modified: llvm/trunk/test/MC/Mips/cprestore-warning-unused.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/cprestore-warning-unused.s?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/cprestore-warning-unused.s (original)
> +++ llvm/trunk/test/MC/Mips/cprestore-warning-unused.s Wed May 18 06:58:50 2016
> @@ -1,4 +1,4 @@
> -# RUN: llvm-mc %s -arch=mips -mcpu=mips32 -relocation-model=pic 2>%t1
> +# RUN: llvm-mc %s -arch=mips -mcpu=mips32 --position-independent 2>%t1
> # RUN: FileCheck %s < %t1
> 
>   .text
> 
> Modified: llvm/trunk/test/MC/Mips/init-order-bug.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/init-order-bug.ll?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Mips/init-order-bug.ll (original)
> +++ llvm/trunk/test/MC/Mips/init-order-bug.ll Wed May 18 06:58:50 2016
> @@ -1,5 +1,5 @@
> ; RUN: llc -mtriple=mipsel-linux-gnu -relocation-model=pic -filetype=asm < %s | \
> -; RUN:     llvm-mc -triple=mipsel-linux-gnu -relocation-model=pic -filetype=obj | \
> +; RUN:     llvm-mc -triple=mipsel-linux-gnu --position-independent -filetype=obj | \
> ; RUN:     llvm-objdump -d - | FileCheck %s
> ; RUN: llc -mtriple=mipsel-linux-gnu -relocation-model=pic -filetype=obj < %s | \
> ; RUN:     llvm-objdump -d - | FileCheck %s
> 
> Modified: llvm/trunk/test/MC/Sparc/sparc-pic.s
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Sparc/sparc-pic.s?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/test/MC/Sparc/sparc-pic.s (original)
> +++ llvm/trunk/test/MC/Sparc/sparc-pic.s Wed May 18 06:58:50 2016
> @@ -1,5 +1,5 @@
> -! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=pic -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=PIC %s
> -! RUN: llvm-mc %s -arch=sparcv9 --relocation-model=static -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=NOPIC %s
> +! RUN: llvm-mc %s -arch=sparcv9 --position-independent -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=PIC %s
> +! RUN: llvm-mc %s -arch=sparcv9 -filetype=obj | llvm-readobj -r | FileCheck --check-prefix=NOPIC %s
> 
> 
> ! PIC:      Relocations [
> 
> Modified: llvm/trunk/tools/dsymutil/DwarfLinker.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/dsymutil/DwarfLinker.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/tools/dsymutil/DwarfLinker.cpp (original)
> +++ llvm/trunk/tools/dsymutil/DwarfLinker.cpp Wed May 18 06:58:50 2016
> @@ -595,8 +595,7 @@ bool DwarfStreamer::init(Triple TheTripl
> 
>   MOFI.reset(new MCObjectFileInfo);
>   MC.reset(new MCContext(MAI.get(), MRI.get(), MOFI.get()));
> -  MOFI->InitMCObjectFileInfo(TheTriple, Reloc::Default, CodeModel::Default,
> -                             *MC);
> +  MOFI->InitMCObjectFileInfo(TheTriple, /*PIC*/ false, CodeModel::Default, *MC);
> 
>   MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, "");
>   if (!MAB)
> 
> Modified: llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp (original)
> +++ llvm/trunk/tools/llvm-dwp/llvm-dwp.cpp Wed May 18 06:58:50 2016
> @@ -616,7 +616,7 @@ int main(int argc, char **argv) {
> 
>   MCObjectFileInfo MOFI;
>   MCContext MC(MAI.get(), MRI.get(), &MOFI);
> -  MOFI.InitMCObjectFileInfo(TheTriple, Reloc::Default, CodeModel::Default, MC);
> +  MOFI.InitMCObjectFileInfo(TheTriple, /*PIC*/ false, CodeModel::Default, MC);
> 
>   auto MAB = TheTarget->createMCAsmBackend(*MRI, TripleName, "");
>   if (!MAB)
> 
> Modified: llvm/trunk/tools/llvm-mc/llvm-mc.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-mc/llvm-mc.cpp?rev=269909&r1=269908&r2=269909&view=diff
> ==============================================================================
> --- llvm/trunk/tools/llvm-mc/llvm-mc.cpp (original)
> +++ llvm/trunk/tools/llvm-mc/llvm-mc.cpp Wed May 18 06:58:50 2016
> @@ -115,20 +115,8 @@ MAttrs("mattr",
>   cl::desc("Target specific attributes (-mattr=help for details)"),
>   cl::value_desc("a1,+a2,-a3,..."));
> 
> -static cl::opt<Reloc::Model>
> -RelocModel("relocation-model",
> -             cl::desc("Choose relocation model"),
> -             cl::init(Reloc::Default),
> -             cl::values(
> -            clEnumValN(Reloc::Default, "default",
> -                       "Target default relocation model"),
> -            clEnumValN(Reloc::Static, "static",
> -                       "Non-relocatable code"),
> -            clEnumValN(Reloc::PIC_, "pic",
> -                       "Fully relocatable, position independent code"),
> -            clEnumValN(Reloc::DynamicNoPIC, "dynamic-no-pic",
> -                       "Relocatable external references, non-relocatable code"),
> -            clEnumValEnd));
> +static cl::opt<bool> PIC("position-independent",
> +                         cl::desc("Position independent"), cl::init(false));
> 
> static cl::opt<llvm::CodeModel::Model>
> CMModel("code-model",
> @@ -432,7 +420,7 @@ int main(int argc, char **argv) {
>   // MCObjectFileInfo needs a MCContext reference in order to initialize itself.
>   MCObjectFileInfo MOFI;
>   MCContext Ctx(MAI.get(), MRI.get(), &MOFI, &SrcMgr);
> -  MOFI.InitMCObjectFileInfo(TheTriple, RelocModel, CMModel, Ctx);
> +  MOFI.InitMCObjectFileInfo(TheTriple, PIC, CMModel, Ctx);
> 
>   if (SaveTempLabels)
>     Ctx.setAllowTemporaryLabels(false);
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits



More information about the llvm-commits mailing list