From 253933ee9ef2c413ecd782efeacc5d7b9bcda09a Mon Sep 17 00:00:00 2001 From: Chandler Carruth Date: Sun, 8 Apr 2012 17:51:45 +0000 Subject: Teach LLVM about a PIE option which, when enabled on top of PIC, makes optimizations which are valid for position independent code being linked into a single executable, but not for such code being linked into a shared library. I discussed the design of this with Eric Christopher, and the decision was to support an optional bit rather than a completely separate relocation model. Fundamentally, this is still PIC relocation, its just that certain optimizations are only valid under a PIC relocation model when the resulting code won't be in a shared library. The simplest path to here is to expose a single bit option in the TargetOptions. If folks have different/better designs, I'm all ears. =] I've included the first optimization based upon this: changing TLS models to the *Exec models when PIE is enabled. This is the LLVM component of PR12380 and is all of the hard work. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@154294 91177308-0d34-0410-b5e6-96231b3b80d8 --- tools/llc/llc.cpp | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'tools/llc') diff --git a/tools/llc/llc.cpp b/tools/llc/llc.cpp index 191b649c05..9e30ac198b 100644 --- a/tools/llc/llc.cpp +++ b/tools/llc/llc.cpp @@ -262,6 +262,11 @@ TrapFuncName("trap-func", cl::Hidden, cl::desc("Emit a call to trap function rather than a trap instruction"), cl::init("")); +static cl::opt +EnablePIE("enable-pie", + cl::desc("Assume the creation of a position independent executable."), + cl::init(false)); + static cl::opt SegmentedStacks("segmented-stacks", cl::desc("Use segmented stacks if possible."), @@ -467,6 +472,7 @@ int main(int argc, char **argv) { Options.RealignStack = EnableRealignStack; Options.DisableJumpTables = DisableSwitchTables; Options.TrapFuncName = TrapFuncName; + Options.PositionIndependentExecutable = EnablePIE; Options.EnableSegmentedStacks = SegmentedStacks; std::auto_ptr -- cgit v1.2.3