summaryrefslogtreecommitdiffstats
path: root/llvm/test
diff options
context:
space:
mode:
authorJack Carter <jcarter@mips.com>2013-01-08 19:01:28 +0000
committerJack Carter <jcarter@mips.com>2013-01-08 19:01:28 +0000
commitc3dd91c4d7bed3ad9c07d3c5a8bf49906fdec3e1 (patch)
treea4380eef33083cfaed97887cb0a8d28ce669ab1a /llvm/test
parent9e28cd3fad1e4c26842cc7e4c062353790a7b7cd (diff)
downloadbcm5719-llvm-c3dd91c4d7bed3ad9c07d3c5a8bf49906fdec3e1.tar.gz
bcm5719-llvm-c3dd91c4d7bed3ad9c07d3c5a8bf49906fdec3e1.zip
This patch produces the correct addend value for
an R_MIPS_GPREL16 relocation. Contributer: Jack Carter llvm-svn: 171882
Diffstat (limited to 'llvm/test')
-rw-r--r--llvm/test/MC/Mips/mips_gprel16.ll33
1 files changed, 33 insertions, 0 deletions
diff --git a/llvm/test/MC/Mips/mips_gprel16.ll b/llvm/test/MC/Mips/mips_gprel16.ll
new file mode 100644
index 00000000000..b5a282de560
--- /dev/null
+++ b/llvm/test/MC/Mips/mips_gprel16.ll
@@ -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"
+
+@var1 = internal global i32 0, align 4
+@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
+}
+
OpenPOWER on IntegriCloud