Removed old hack for llvm 2.8, it is not required anymore

This commit is contained in:
Alexey Prokhin
2011-12-03 14:20:54 +04:00
parent 6357c421ac
commit 1f3d9b98d0

View File

@@ -1441,39 +1441,8 @@ DValue* IndexExp::toElem(IRState* p)
arrptr = DtoGEP(l->getRVal(), zero, r->getRVal());
}
else if (e1type->ty == Tarray) {
if(global.params.useArrayBounds) {
#if 1
/*
Workaround for a bug in llvm 2.8 which appears only when
all optimizations are off.
Example:
int a[] = new int[5];
a[0] = 100;
a[1] = 1;
a[2] = 2;
a[3] = 3;
a[4] = 4;
for (int i = 0; i < a.length-1; i++)
printf("%d\n", a[i+1]); // Error would be around here
Output:
100
100
100
100
As you can see from the example, the index always is 0.
To avoid the issue we store the index before array bounds
checking.
*/
if (optLevel() == 0 && !r->isLVal()) {
LLValue *tmp = DtoAlloca(r->getType());
DtoStore(r->getRVal(), tmp);
r = new DVarValue(r->getType(), tmp);
}
#endif
if(global.params.useArrayBounds)
DtoArrayBoundsCheck(loc, l, r);
}
arrptr = DtoArrayPtr(l);
arrptr = DtoGEP1(arrptr,r->getRVal());
}