[LLVMbugs] [Bug 7226] New: [ARM JIT] ARM JIT couldn't emit constant pool entry for "ConstantVector" and "ConstantArray"
bugzilla-daemon at llvm.org
bugzilla-daemon at llvm.org
Tue May 25 06:04:07 PDT 2010
http://llvm.org/bugs/show_bug.cgi?id=7226
Summary: [ARM JIT] ARM JIT couldn't emit constant pool entry
for "ConstantVector" and "ConstantArray"
Product: libraries
Version: trunk
Platform: PC
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
In file lib/Target/ARM/ARMCodeEmitter.cpp, we found this line at the end of the
function "ARMCodeEmitter::emitConstPoolInstruction(const MachineInstr &MI)":
llvm_unreachable("Unable to handle this constantpool entry!");
ARM JITting will reach this "unreachable" line when JITting a simple program
below:
int main(int argc, char** argv) {
if(argc == 10000) {
int i;
float ident[16];
float masterscale = 0.0041f;// / (gXOffset * 4.f + 1.f);
int now = argc;
timedelta = ((float)(now - lastuptime)) / 44.f;
lastuptime = now;
if (timedelta > 3) {
// Limit the step adjustment factor to 3, so we don't get a sudden jump
// after coming back from sleep.
timedelta = 3;
}
i = gPreset;
if (i != currentpreset) {
currentpreset = i;
int rgb = gBackCol;
makeTextures();
}
}
if(argc > 1)
gTextureSwap = 1;
else
gTextureSwap = 0;
if (gTextureSwap != 0)
scale[0] = .25f;
else
scale[0] = 4.f;
printf("%d %f\n", gTextureSwap, scale[0]);
return 55;
}
The program is adapted from an internal clouds.c, so we can ignore the "if
(argc ==10000)" part.
Note that the 0.25f and 4.f in the code above will become ConstantArray of 2
elements. The first element will be 0.25f, while the second, 4.f. ConstantArray
and ConstantVector should be implemented.
Our fix is to replace the last case in
"ARMCodeEmitter::emitConstPoolInstruction(const MachineInstr &MI)" with a
function call to "emitConstantToMemory()". This new function
"emitConstantToMemory" is defined as follows.
void ARMCodeEmitter::emitConstantToMemory(unsigned CPI, const Constant* C) {
DEBUG({
errs() << " ** Constant pool #" << CPI << " @ "
<< (void*)MCE.getCurrentPCValue() << " ";
if (const Function *F = dyn_cast<Function>(C))
errs() << F->getName();
else
errs() << *C;
errs() << '\n';
});
if (const GlobalValue *GV = dyn_cast<GlobalValue>(C)) {
emitGlobalAddress(GV, ARM::reloc_arm_absolute, isa<Function>(GV), false);
emitWordLE(0);
} else if (const ConstantInt *CI = dyn_cast<ConstantInt>(C)) {
uint32_t Val = *(uint32_t*)CI->getValue().getRawData();
emitWordLE(Val);
} else if (const ConstantFP *CFP = dyn_cast<ConstantFP>(C)) {
if (CFP->getType()->isFloatTy())
emitWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
else if (CFP->getType()->isDoubleTy())
emitDWordLE(CFP->getValueAPF().bitcastToAPInt().getZExtValue());
else {
llvm_unreachable("Unable to handle this constantpool entry!");
}
} else if (const ConstantVector* CV = dyn_cast<ConstantVector>(C)) {
for (unsigned i=0;i<CV->getNumOperands();i++)
emitConstantToMemory(CPI, CV->getOperand(i));
} else if (const ConstantArray* CA = dyn_cast<ConstantArray>(C)) {
for (unsigned i=0;i<CA->getNumOperands();i++)
emitConstantToMemory(CPI, CA->getOperand(i));
} else {
llvm_unreachable("Unable to handle this constantpool entry!");
}
return;
}
This will fix the unreachable problem above, which means that we will no longer
reach the line llvm_unreachable("Unable to handle this constantpool entry!").
--
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