Skip to content

Commit 685bad0

Browse files
committed
remove getelement nuw flag from pointer arithmetic; too aggresive
1 parent d27bd60 commit 685bad0

File tree

3 files changed

+5
-23
lines changed

3 files changed

+5
-23
lines changed

gen/binops.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -116,16 +116,7 @@ DValue *emitPointerOffset(Loc loc, DValue *base, Expression *offset,
116116
if (!llResult) {
117117
if (negateOffset)
118118
llOffset = gIR->ir->CreateNeg(llOffset);
119-
#if LDC_LLVM_VER >= 2000
120-
llvm::GEPNoWrapFlags nw = llvm::GEPNoWrapFlags::inBounds();
121-
if (!negateOffset)
122-
nw |= llvm::GEPNoWrapFlags::noUnsignedWrap();
123-
#endif
124-
llResult = DtoGEP1(llBaseTy, llBase, llOffset
125-
#if LDC_LLVM_VER >= 2000
126-
, "", nullptr, nw
127-
#endif
128-
);
119+
llResult = DtoGEP1(llBaseTy, llBase, llOffset);
129120
}
130121

131122
return new DImValue(resultType, llResult);

gen/toir.cpp

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1534,16 +1534,7 @@ class ToElemVisitor : public Visitor {
15341534
assert(e->e2->op == EXP::int64);
15351535
LLConstant *offset =
15361536
e->op == EXP::plusPlus ? DtoConstUint(1) : DtoConstInt(-1);
1537-
#if LDC_LLVM_VER >= 2000
1538-
auto nw = llvm::GEPNoWrapFlags::inBounds();
1539-
if (e->op == EXP::plusPlus)
1540-
nw |= llvm::GEPNoWrapFlags::noUnsignedWrap();
1541-
#endif
1542-
post = DtoGEP1(DtoMemType(dv->type->nextOf()), val, offset, "", p->scopebb()
1543-
#if LDC_LLVM_VER >= 2000
1544-
, nw
1545-
#endif
1546-
);
1537+
post = DtoGEP1(DtoMemType(dv->type->nextOf()), val, offset, "", p->scopebb());
15471538
} else if (e1type->isComplex()) {
15481539
assert(e2type->isComplex());
15491540
LLValue *one = LLConstantFP::get(DtoComplexBaseType(e1type), 1.0);

tests/codegen/inbounds.d

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,21 +30,21 @@ int foo3(int* p, int i) {
3030
// PostExp in pointer
3131
// CHECK-LABEL: @foo4
3232
int foo4(int* p) {
33-
// CHECK: getelementptr inbounds{{( nuw)?}}
33+
// CHECK: getelementptr inbounds
3434
return *p++;
3535
}
3636

3737
// PreExp in pointer
3838
// CHECK-LABEL: @foo5
3939
int foo5(int* p) {
40-
// CHECK: getelementptr inbounds{{( nuw)?}}
40+
// CHECK: getelementptr inbounds
4141
return *++p;
4242
}
4343

4444
// Add offset to pointer
4545
// CHECK-LABEL: @foo6
4646
int foo6(int* p, int i) {
47-
// CHECK: getelementptr inbounds{{( nuw)?}}
47+
// CHECK: getelementptr inbounds
4848
return *(p + i);
4949
}
5050

0 commit comments

Comments
 (0)