aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Sanders <daniel.sanders@imgtec.com>2015-06-14 15:36:12 +0000
committerDaniel Sanders <daniel.sanders@imgtec.com>2015-06-14 15:36:12 +0000
commit214ebac56ab97c1d59fc04cdde562b5d0c1145f9 (patch)
tree25b28bb81e1c3391691617d3f240e2125cd533af
parent2f8c90e9db7169a261c57bf0a70873975ebe3ac6 (diff)
downloadllvm-214ebac56ab97c1d59fc04cdde562b5d0c1145f9.zip
llvm-214ebac56ab97c1d59fc04cdde562b5d0c1145f9.tar.gz
llvm-214ebac56ab97c1d59fc04cdde562b5d0c1145f9.tar.bz2
Merging r238751:
------------------------------------------------------------------------ r238751 | rafael | 2015-06-01 16:10:51 +0100 (Mon, 01 Jun 2015) | 3 lines Fix relocation selection for foo-. on mips. This handles only the 32 bit case. ------------------------------------------------------------------------ llvm-svn: 239698
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp2
-rw-r--r--llvm/lib/MC/MCObjectFileInfo.cpp2
-rw-r--r--llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp3
-rw-r--r--llvm/lib/Target/Mips/MipsAsmPrinter.cpp23
-rw-r--r--llvm/test/MC/Mips/relocation.s10
5 files changed, 37 insertions, 3 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
index ef54525..1ba2e1f 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp
@@ -656,7 +656,7 @@ void SelectionDAGISel::CodeGenAndEmitDAG() {
(void)BlockNumber;
bool MatchFilterBB = false; (void)MatchFilterBB;
#ifndef NDEBUG
- MatchFilterBB = (!FilterDAGBasicBlockName.empty() &&
+ MatchFilterBB = (FilterDAGBasicBlockName.empty() ||
FilterDAGBasicBlockName ==
FuncInfo->MBB->getBasicBlock()->getName().str());
#endif
diff --git a/llvm/lib/MC/MCObjectFileInfo.cpp b/llvm/lib/MC/MCObjectFileInfo.cpp
index 858181d..e0a86ee 100644
--- a/llvm/lib/MC/MCObjectFileInfo.cpp
+++ b/llvm/lib/MC/MCObjectFileInfo.cpp
@@ -350,6 +350,8 @@ void MCObjectFileInfo::InitELFMCObjectFileInfo(Triple T) {
// eh_frame section can be read-only. DW.ref.personality will be generated
// for relocation.
PersonalityEncoding = dwarf::DW_EH_PE_indirect;
+ LSDAEncoding = dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
+ TTypeEncoding = dwarf::DW_EH_PE_indirect | dwarf::DW_EH_PE_pcrel | dwarf::DW_EH_PE_sdata4;
break;
case Triple::ppc64:
case Triple::ppc64le:
diff --git a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
index 56aac4e..ec796a3 100644
--- a/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
+++ b/llvm/lib/Target/Mips/MCTargetDesc/MipsELFObjectWriter.cpp
@@ -55,8 +55,7 @@ unsigned MipsELFObjectWriter::GetRelocType(const MCValue &Target,
default:
llvm_unreachable("invalid fixup kind!");
case FK_Data_4:
- Type = ELF::R_MIPS_32;
- break;
+ return IsPCRel ? ELF::R_MIPS_PC32 : ELF::R_MIPS_32;
case FK_Data_8:
Type = ELF::R_MIPS_64;
break;
diff --git a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
index 50c0441e..9b774cd 100644
--- a/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
+++ b/llvm/lib/Target/Mips/MipsAsmPrinter.cpp
@@ -29,6 +29,8 @@
#include "llvm/CodeGen/MachineInstr.h"
#include "llvm/CodeGen/MachineJumpTableInfo.h"
#include "llvm/CodeGen/MachineMemOperand.h"
+#include "llvm/CodeGen/MachineModuleInfoImpls.h"
+#include "llvm/CodeGen/TargetLoweringObjectFileImpl.h"
#include "llvm/IR/BasicBlock.h"
#include "llvm/IR/DataLayout.h"
#include "llvm/IR/InlineAsm.h"
@@ -1033,6 +1035,27 @@ void MipsAsmPrinter::EmitEndOfAsmFile(Module &M) {
}
// return to the text section
OutStreamer.SwitchSection(OutContext.getObjectFileInfo()->getTextSection());
+
+ /* if (Subtarget->isTargetELF()) */ {
+ const TargetLoweringObjectFileELF &TLOFELF =
+ static_cast<const TargetLoweringObjectFileELF &>(getObjFileLowering());
+
+ MachineModuleInfoELF &MMIELF = MMI->getObjFileInfo<MachineModuleInfoELF>();
+
+ // Output stubs for external and common global variables.
+ MachineModuleInfoELF::SymbolListTy Stubs = MMIELF.GetGVStubList();
+ if (!Stubs.empty()) {
+ OutStreamer.SwitchSection(TLOFELF.getDataRelSection());
+ const DataLayout *TD = TM.getSubtargetImpl()->getDataLayout();
+
+ for (const auto &Stub : Stubs) {
+ OutStreamer.EmitLabel(Stub.first);
+ OutStreamer.EmitSymbolValue(Stub.second.getPointer(),
+ TD->getPointerSize());
+ }
+ Stubs.clear();
+ }
+ }
}
void MipsAsmPrinter::PrintDebugValueComment(const MachineInstr *MI,
diff --git a/llvm/test/MC/Mips/relocation.s b/llvm/test/MC/Mips/relocation.s
new file mode 100644
index 0000000..642b409
--- /dev/null
+++ b/llvm/test/MC/Mips/relocation.s
@@ -0,0 +1,10 @@
+// RUN: llvm-mc -filetype=obj -triple mipsel-unknown-linux < %s | llvm-readobj -r | FileCheck %s
+
+// Test that we produce the correct relocation.
+// FIXME: move more relocation only tests here.
+
+ .long foo
+// CHECK: R_MIPS_32 foo
+
+ .long foo-.
+// CHECK: R_MIPS_PC32 foo