summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/TargetMachine.cpp
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-04-08 17:51:45 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-04-08 17:51:45 +0000
commitede4a8aa2be346d4f175e61cf4a18a023ea3198d (patch)
tree22fc4c7592d859d08f4da518df0429a3c9100236 /llvm/lib/Target/TargetMachine.cpp
parent16f0ebcbb576f197422426b64f4ad54269f273d1 (diff)
downloadbcm5719-llvm-ede4a8aa2be346d4f175e61cf4a18a023ea3198d.tar.gz
bcm5719-llvm-ede4a8aa2be346d4f175e61cf4a18a023ea3198d.zip
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. llvm-svn: 154294
Diffstat (limited to 'llvm/lib/Target/TargetMachine.cpp')
-rw-r--r--llvm/lib/Target/TargetMachine.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Target/TargetMachine.cpp b/llvm/lib/Target/TargetMachine.cpp
index b8e7f15d092..b9b2526876f 100644
--- a/llvm/lib/Target/TargetMachine.cpp
+++ b/llvm/lib/Target/TargetMachine.cpp
@@ -82,7 +82,8 @@ TLSModel::Model TargetMachine::getTLSModel(const GlobalValue *GV) const {
// For variables, is internal different from hidden?
bool isHidden = GV->hasHiddenVisibility();
- if (getRelocationModel() == Reloc::PIC_) {
+ if (getRelocationModel() == Reloc::PIC_ &&
+ !Options.PositionIndependentExecutable) {
if (isLocal || isHidden)
return TLSModel::LocalDynamic;
else
OpenPOWER on IntegriCloud