[llvm] r268106 - Differential Revision: http://reviews.llvm.org/D19733
Rafael EspĂndola via llvm-commits
llvm-commits at lists.llvm.org
Fri Apr 29 14:30:45 PDT 2016
How should LTO handle this?
This is of interest to me when bootstrapping clang. We build
everything with -fPIC, but the linker knows it is producing a PIE,
position dependent executable or shared library.
Right now the gold plugin and lld just pass that information down to
codegen. Should them be mutating the merged module before codegen too?
Cheers,
Rafael
On 29 April 2016 at 17:19, Sriraman Tallam via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: tmsriram
> Date: Fri Apr 29 16:19:16 2016
> New Revision: 268106
>
> URL: http://llvm.org/viewvc/llvm-project?rev=268106&view=rev
> Log:
> Differential Revision: http://reviews.llvm.org/D19733
>
> Modified:
> llvm/trunk/include/llvm/CodeGen/CommandFlags.h
> llvm/trunk/lib/Target/TargetMachine.cpp
> llvm/trunk/lib/Target/X86/X86Subtarget.cpp
> llvm/trunk/lib/Target/X86/X86Subtarget.h
> llvm/trunk/test/CodeGen/X86/emutls-pie.ll
> llvm/trunk/test/CodeGen/X86/global-access-pie.ll
> llvm/trunk/test/CodeGen/X86/pie.ll
> llvm/trunk/test/CodeGen/X86/tls-pie.ll
>
> Modified: llvm/trunk/include/llvm/CodeGen/CommandFlags.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/CodeGen/CommandFlags.h?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/CodeGen/CommandFlags.h (original)
> +++ llvm/trunk/include/llvm/CodeGen/CommandFlags.h Fri Apr 29 16:19:16 2016
> @@ -198,11 +198,6 @@ TrapFuncName("trap-func", cl::Hidden,
> cl::init(""));
>
> cl::opt<bool>
> -EnablePIE("enable-pie",
> - cl::desc("Assume the creation of a position independent executable."),
> - cl::init(false));
> -
> -cl::opt<bool>
> UseCtors("use-ctors",
> cl::desc("Use .ctors instead of .init_array."),
> cl::init(false));
> @@ -290,7 +285,6 @@ static inline TargetOptions InitTargetOp
> Options.GuaranteedTailCallOpt = EnableGuaranteedTailCallOpt;
> Options.StackAlignmentOverride = OverrideStackAlignment;
> Options.StackSymbolOrdering = StackSymbolOrdering;
> - Options.PositionIndependentExecutable = EnablePIE;
> Options.UseInitArray = !UseCtors;
> Options.DataSections = DataSections;
> Options.FunctionSections = FunctionSections;
>
> Modified: llvm/trunk/lib/Target/TargetMachine.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/TargetMachine.cpp?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/TargetMachine.cpp (original)
> +++ llvm/trunk/lib/Target/TargetMachine.cpp Fri Apr 29 16:19:16 2016
> @@ -109,7 +109,7 @@ TLSModel::Model TargetMachine::getTLSMod
> bool isLocal = GV->hasLocalLinkage();
> bool isDeclaration = GV->isDeclaration();
> bool isPIC = getRelocationModel() == Reloc::PIC_;
> - bool isPIE = Options.PositionIndependentExecutable;
> + bool isPIE = GV->getParent()->getPIELevel() != PIELevel::Default;
> // FIXME: what should we do for protected and internal visibility?
> // For variables, is internal different from hidden?
> bool isHidden = GV->hasHiddenVisibility();
>
> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
> +++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Fri Apr 29 16:19:16 2016
> @@ -159,8 +159,7 @@ unsigned char X86Subtarget::classifyGlob
> // we don't need to use the PLT - we can directly call it.
> // In PIE mode, calls to global functions don't need to go through PLT
> if (isTargetELF() && TM.getRelocationModel() == Reloc::PIC_ &&
> - (!TM.Options.PositionIndependentExecutable ||
> - GV->isDeclarationForLinker()) &&
> + !isGlobalDefinedInPIE(GV, TM) &&
> GV->hasDefaultVisibility() && !GV->hasLocalLinkage()) {
> return X86II::MO_PLT;
> } else if (isPICStyleStubAny() && !GV->isStrongDefinitionForLinker() &&
>
> Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
> +++ llvm/trunk/lib/Target/X86/X86Subtarget.h Fri Apr 29 16:19:16 2016
> @@ -552,7 +552,7 @@ public:
> /// Executable (PIE) where its definition cannot be interposed.
> bool isGlobalDefinedInPIE(const GlobalValue *GV,
> const TargetMachine &TM) const {
> - return TM.Options.PositionIndependentExecutable &&
> + return GV->getParent()->getPIELevel() != PIELevel::Default &&
> !GV->isDeclarationForLinker();
> }
>
>
> Modified: llvm/trunk/test/CodeGen/X86/emutls-pie.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/emutls-pie.ll?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/emutls-pie.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/emutls-pie.ll Fri Apr 29 16:19:16 2016
> @@ -1,10 +1,10 @@
> -; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X32 %s
> -; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X64 %s
> -; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-android -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X32 %s
> -; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -emulated-tls -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-android -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X64 %s
>
> ; Use my_emutls_get_address like __emutls_get_address.
> @@ -129,3 +129,8 @@ entry:
>
> ; X64-NOT: __emutls_v.i2
> ; X64-NOT: __emutls_t.i2
> +
> +
> +!llvm.module.flags = !{!0, !1}
> +!0 = !{i32 1, !"PIC Level", i32 1}
> +!1 = !{i32 1, !"PIE Level", i32 1}
>
> Modified: llvm/trunk/test/CodeGen/X86/global-access-pie.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/global-access-pie.ll?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/global-access-pie.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/global-access-pie.ll Fri Apr 29 16:19:16 2016
> @@ -1,6 +1,6 @@
> -; RUN: llc < %s -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X64 %s
> -; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -emulated-tls -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X32 %s
>
> ; External Linkage
> @@ -117,3 +117,7 @@ entry:
> %call = call i32 @access_fp(i32 ()* @bar)
> ret i32 %call
> }
> +
> +!llvm.module.flags = !{!0, !1}
> +!0 = !{i32 1, !"PIC Level", i32 1}
> +!1 = !{i32 1, !"PIE Level", i32 1}
>
> Modified: llvm/trunk/test/CodeGen/X86/pie.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/pie.ll?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/pie.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/pie.ll Fri Apr 29 16:19:16 2016
> @@ -1,7 +1,7 @@
> -; RUN: llc < %s -O0 -mcpu=generic -mtriple=i686-linux-gnu -relocation-model=pic -enable-pie | FileCheck %s
> -; RUN: llc < %s -O0 -mcpu=generic -mtriple=i686-linux-gnu -fast-isel -relocation-model=pic -enable-pie | FileCheck %s
> -; RUN: llc < %s -O0 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie | FileCheck %s
> -; RUN: llc < %s -O0 -mcpu=generic -mtriple=x86_64-linux-gnu -fast-isel -relocation-model=pic -enable-pie | FileCheck %s
> +; RUN: llc < %s -O0 -mcpu=generic -mtriple=i686-linux-gnu -relocation-model=pic | FileCheck %s
> +; RUN: llc < %s -O0 -mcpu=generic -mtriple=i686-linux-gnu -fast-isel -relocation-model=pic | FileCheck %s
> +; RUN: llc < %s -O0 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic | FileCheck %s
> +; RUN: llc < %s -O0 -mcpu=generic -mtriple=x86_64-linux-gnu -fast-isel -relocation-model=pic | FileCheck %s
>
> ; CHECK-LABEL: bar:
> ; CHECK: call{{l|q}} foo{{$}}
> @@ -39,3 +39,7 @@ entry:
> }
>
> ; -fpie for local global data tests should be added here
> +
> +!llvm.module.flags = !{!0, !1}
> +!0 = !{i32 1, !"PIC Level", i32 1}
> +!1 = !{i32 1, !"PIE Level", i32 1}
>
> Modified: llvm/trunk/test/CodeGen/X86/tls-pie.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/tls-pie.ll?rev=268106&r1=268105&r2=268106&view=diff
> ==============================================================================
> --- llvm/trunk/test/CodeGen/X86/tls-pie.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/tls-pie.ll Fri Apr 29 16:19:16 2016
> @@ -1,6 +1,6 @@
> -; RUN: llc < %s -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -march=x86 -mcpu=generic -mtriple=i386-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X32 %s
> -; RUN: llc < %s -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic -enable-pie \
> +; RUN: llc < %s -march=x86-64 -mcpu=generic -mtriple=x86_64-linux-gnu -relocation-model=pic \
> ; RUN: | FileCheck -check-prefix=X64 %s
>
> @i = thread_local global i32 15
> @@ -79,3 +79,7 @@ define i32* @f4() {
> entry:
> ret i32* @i2
> }
> +
> +!llvm.module.flags = !{!0, !1}
> +!0 = !{i32 1, !"PIC Level", i32 1}
> +!1 = !{i32 1, !"PIE Level", i32 1}
>
>
> _______________________________________________
> 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