[LLVMbugs] [Bug 7806] New: MIC (Modified immediate constants) field is not honored in ARM JIT's Code emitter
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue Aug 3 19:38:16 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7806
Summary: MIC (Modified immediate constants) field is not
honored in ARM JIT's Code emitter
Product: libraries
Version: trunk
Platform: Other
OS/Version: Linux
Status: NEW
Severity: normal
Priority: P
Component: Backend: ARM
AssignedTo: unassignedbugs at nondot.org
ReportedBy: sliao at google.com
CC: llvmbugs at cs.uiuc.edu
See the repro case in the attached file. The file is generated by "clang
-emit-llvm -c "llvm_builtins.c" -o "llvm_builtins.bc". Then you can repro it
using a simple testing JIT that parses the file as module, create EE from it
and get function pointer from EE.
See the highlighted instruction below. The JIT tried incorrectly to calculate
the address for 0x100 + 0x404700e0 + 8 == 0x404701e8. But it's wrong, because
in the "0x100", "1" is treated as rotating amount, according to A5.2.4 of the
ARM Architecture Reference Manual.
float Loop(float * inputs, float count)
{
float i = 0;
do
{
float a = i * inputs[0];
// this is the offending statement
a += i < count ? 1.0f : 0;
// the selection causes it to load 0 or 1 from end of function by
// doing something like:
// 0x404700c0:e3a07000 b5 mov r7, #0
// 0x404700c4:eef40ac0 258 vcmpe.f32 s1, s0
// 0x404700c8:eef1fa10 70 vmrs apsr_nzcv, fpscr
// 0x404700cc:e2411001 162 sub r1, r1, #1
// 0x404700d0:43a07001 b5 movmi r7, #1
// 0x404700d4:e3570000 54 cmp r7, #0
// 0x404700d8:e3a07000 b5 mov r7, #0
// 0x404700dc:13a07004 b5 movne r7, #4
//********0x404700e0:e28f8100 15 add r8, pc, #0 # The JIT tried
incorrectly to jump to 0x100 + 0x404700e0 + 8 == 0x404701e8. But it's wrong,
because for "0x100", "1" is treated as rotating amount, according to A5.2.4.
// 0x404700e4:ed902a00 332 vldr.32 s4, [r0]
// 0x404700e8:e3510000 54 cmp r1, #0
// 0x404700ec:e0887007 16 add r7, r8, r7
// 0x404700f0:edd71a00 332 vldr.32 s3, [r7]
//
// 0x404701e0:e8bd81f0 8a pop {r4, r5, r6, r7, r8, pc}
* * *******
// 0x404701e4:0 1b andeq r0, r0, r0
// 0x404701e8:0 1b andeq r0, r0, r0
// 0x404701ec:3f800000 165 svclo #8388608 // 1.0f
// 0x404701f0:3e99999a be mrclo p9, #4, r9, cr9, cr10, #4
// padding to make the body bigger than 256 bytes
a += inputs[2 * (int)i];
a += inputs[3 * (int)i];
a -= inputs[4 * (int)i];
a += inputs[8 * (int)i];
a -= inputs[4 * (int)i];
a += inputs[8 * (int)i];
a -= inputs[9 * (int)i];
a += inputs[14 * (int)i];
a += inputs[22 * (int)i];
a += inputs[33 * (int)i];
a -= inputs[44 * (int)i];
a += inputs[28 * (int)i];
a -= inputs[34 * (int)i];
a += inputs[48 * (int)i];
a -= inputs[59 * (int)i];
inputs[(int)i] = a;
i += 0.3f;
} while (i < 0.922f);
return i;
}
--
Configure bugmail: http://llvm.org/bugs/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.
More information about the llvm-bugs
mailing list