Skip to content

Commit b5ce77d

Browse files
committed
Drop invalid "in-bounds" GEP for constant offsets
This GEP was not in fact guaranteed to be in-bounds. This was discovered by a failure in the WASM version of correctness_indexing_access_undef after a change to LLVM's LICM declined to hoist part of the computation. LLVM reference: llvm/llvm-project#151492
1 parent 17464c2 commit b5ce77d

File tree

1 file changed

+0
-12
lines changed

1 file changed

+0
-12
lines changed

src/CodeGen_LLVM.cpp

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1966,18 +1966,6 @@ Value *CodeGen_LLVM::codegen_buffer_pointer(Value *base_address, Halide::Type ty
19661966
if (promote_indices() && d.getPointerSize() == 8) {
19671967
index = promote_64(index);
19681968
}
1969-
1970-
// Peel off a constant offset as a second GEP. This helps LLVM's
1971-
// aliasing analysis, especially for backends that do address
1972-
// computation in 32 bits but use 64-bit pointers.
1973-
if (const Add *add = index.as<Add>()) {
1974-
if (auto offset = as_const_int(add->b)) {
1975-
Value *base = codegen_buffer_pointer(base_address, type, add->a);
1976-
Value *off = codegen(make_const(Int(8 * d.getPointerSize()), *offset));
1977-
return CreateInBoundsGEP(builder.get(), llvm_type_of(type), base, off);
1978-
}
1979-
}
1980-
19811969
return codegen_buffer_pointer(base_address, type, codegen(index));
19821970
}
19831971

0 commit comments

Comments
 (0)