[llvm-commits] [llvm] r171882 - in /llvm/trunk: lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp test/MC/Mips/mips_gprel16.ll
Jack Carter
jcarter at mips.com
Tue Jan 8 11:01:28 PST 2013
Author: jacksprat
Date: Tue Jan 8 13:01:28 2013
New Revision: 171882
URL: http://llvm.org/viewvc/llvm-project?rev=171882&view=rev
Log:
This patch produces the correct addend value for
an R_MIPS_GPREL16 relocation.
Contributer: Jack Carter
Added:
llvm/trunk/test/MC/Mips/mips_gprel16.ll
Modified:
llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
Modified: llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp?rev=171882&r1=171881&r2=171882&view=diff
==============================================================================
--- llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp (original)
+++ llvm/trunk/lib/Target/Mips/MCTargetDesc/MipsAsmBackend.cpp Tue Jan 8 13:01:28 2013
@@ -37,6 +37,7 @@
case FK_Data_4:
case FK_Data_8:
case Mips::fixup_Mips_LO16:
+ case Mips::fixup_Mips_GPREL16:
case Mips::fixup_Mips_GPOFF_HI:
case Mips::fixup_Mips_GPOFF_LO:
case Mips::fixup_Mips_GOT_PAGE:
Added: llvm/trunk/test/MC/Mips/mips_gprel16.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/MC/Mips/mips_gprel16.ll?rev=171882&view=auto
==============================================================================
--- llvm/trunk/test/MC/Mips/mips_gprel16.ll (added)
+++ llvm/trunk/test/MC/Mips/mips_gprel16.ll Tue Jan 8 13:01:28 2013
@@ -0,0 +1,33 @@
+; This addresses bug 14456. We were not writing
+; out the addend to the gprel16 relocation. The
+; addend is stored in the instruction immediate
+; field.
+;llc gprel16.ll -o gprel16.o -mcpu=mips32r2 -march=mipsel -filetype=obj -relocation-model=static
+
+; RUN: llc -mcpu=mips32r2 -march=mipsel -filetype=obj -relocation-model=static %s -o - \
+; RUN: | llvm-objdump -disassemble -mattr +mips32r2 - \
+; RUN: | FileCheck %s
+
+target triple = "mipsel-sde--elf-gcc"
+
+ at var1 = internal global i32 0, align 4
+ at var2 = internal global i32 0, align 4
+
+define i32 @testvar1() nounwind {
+entry:
+; CHECK: lw ${{[0-9]+}}, 0($gp)
+ %0 = load i32* @var1, align 4
+ %tobool = icmp ne i32 %0, 0
+ %cond = select i1 %tobool, i32 1, i32 0
+ ret i32 %cond
+}
+
+define i32 @testvar2() nounwind {
+entry:
+; CHECK: lw ${{[0-9]+}}, 4($gp)
+ %0 = load i32* @var2, align 4
+ %tobool = icmp ne i32 %0, 0
+ %cond = select i1 %tobool, i32 1, i32 0
+ ret i32 %cond
+}
+
More information about the llvm-commits
mailing list