From 1f3d9b98d08453cee0646c6f666a0e184c4440bf Mon Sep 17 00:00:00 2001 From: Alexey Prokhin Date: Sat, 3 Dec 2011 14:20:54 +0400 Subject: [PATCH] Removed old hack for llvm 2.8, it is not required anymore --- gen/toir.cpp | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/gen/toir.cpp b/gen/toir.cpp index 2401b96d..533c60d1 100644 --- a/gen/toir.cpp +++ b/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()); }