mirror of
https://github.com/xomboverlord/ldc.git
synced 2026-02-16 20:03:14 +01:00
Removed old hack for llvm 2.8, it is not required anymore
This commit is contained in:
33
gen/toir.cpp
33
gen/toir.cpp
@@ -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());
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user