diff options
author | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-10-31 15:54:31 +0000 |
---|---|---|
committer | Krzysztof Parzyszek <kparzysz@codeaurora.org> | 2018-10-31 15:54:31 +0000 |
commit | 977a1fe50750130b576972f7e36f48cdd15a8c4f (patch) | |
tree | 78a7b69f39b9f10f3112139466cba14bafef8b5f /llvm/lib | |
parent | 52578ac67c517aea65d9a2f8e9ab813f7b61fc6f (diff) | |
download | bcm5719-llvm-977a1fe50750130b576972f7e36f48cdd15a8c4f.tar.gz bcm5719-llvm-977a1fe50750130b576972f7e36f48cdd15a8c4f.zip |
[Hexagon] Make sure not to use GP-relative addressing with PIC
Make sure that -relocation-model=pic prevents use of GP-relative
addressing modes.
llvm-svn: 345731
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp | 10 | ||||
-rw-r--r-- | llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h | 2 |
3 files changed, 10 insertions, 4 deletions
diff --git a/llvm/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp b/llvm/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp index c41f0d3c085..55de2512094 100644 --- a/llvm/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp +++ b/llvm/lib/Target/Hexagon/HexagonSplitConst32AndConst64.cpp @@ -63,7 +63,7 @@ bool HexagonSplitConst32AndConst64::runOnMachineFunction(MachineFunction &Fn) { auto &HST = Fn.getSubtarget<HexagonSubtarget>(); auto &HTM = static_cast<const HexagonTargetMachine&>(Fn.getTarget()); auto &TLOF = *HTM.getObjFileLowering(); - if (HST.useSmallData() && TLOF.isSmallDataEnabled()) + if (HST.useSmallData() && TLOF.isSmallDataEnabled(HTM)) return false; const TargetInstrInfo *TII = HST.getInstrInfo(); diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp index e771f383dff..386cd14c827 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp +++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.cpp @@ -199,6 +199,11 @@ MCSection *HexagonTargetObjectFile::getExplicitSectionGlobal( /// section. bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM) const { + if (!isSmallDataEnabled(TM)) { + LLVM_DEBUG(dbgs() << "Small data is not available.\n"); + return false; + } + // Only global variables, not functions. LLVM_DEBUG(dbgs() << "Checking if value is in small-data, -G" << SmallDataThreshold << ": \"" << GO->getName() << "\": "); @@ -263,8 +268,9 @@ bool HexagonTargetObjectFile::isGlobalInSmallSection(const GlobalObject *GO, return true; } -bool HexagonTargetObjectFile::isSmallDataEnabled() const { - return SmallDataThreshold > 0; +bool HexagonTargetObjectFile::isSmallDataEnabled(const TargetMachine &TM) + const { + return SmallDataThreshold > 0 && !TM.isPositionIndependent(); } unsigned HexagonTargetObjectFile::getSmallDataSize() const { diff --git a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h index eff44f097e0..18863630fde 100644 --- a/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h +++ b/llvm/lib/Target/Hexagon/HexagonTargetObjectFile.h @@ -29,7 +29,7 @@ namespace llvm { bool isGlobalInSmallSection(const GlobalObject *GO, const TargetMachine &TM) const; - bool isSmallDataEnabled() const; + bool isSmallDataEnabled(const TargetMachine &TM) const; unsigned getSmallDataSize() const; |