llvm2alive: fix loading ptr offset size from datalayout
MODIFY
BugList.md
BugList.md
@@ -50,6 +50,9 @@ Please contact us or submit a PR if something is missing or inaccurate.
15. Incorrect transformation: (undef u>> a) ^ -1 -> undef >> a, when a != 0
(https://bugs.llvm.org/show_bug.cgi?id=45447)
+16. Invalid undef splat in instcombine
+(https://bugs.llvm.org/show_bug.cgi?id=45455)
+
### Memory Operations (Load/Store/GEP/...)

MODIFY
ir/function.h
ir/function.h
@@ -57,6 +57,7 @@ class Function final {
std::vector<BasicBlock*> BB_order;
unsigned bits_pointers = 64;
+ unsigned bits_ptr_offset = 64;
bool little_endian = true;
// constants used in this function
@@ -69,9 +70,9 @@ class Function final {
public:
Function() {}
Function(Type &type, std::string &&name, unsigned bits_pointers = 64,
- bool little_endian = true)
+ unsigned bits_ptr_offset = 64, bool little_endian = true)
: type(&type), name(std::move(name)), bits_pointers(bits_pointers),
- little_endian(little_endian) {}
+ bits_ptr_offset(bits_ptr_offset), little_endian(little_endian) {}
const IR::Type& getType() const { return type ? *type : Type::voidTy; }
void setType(IR::Type &t) { type = &t; }
@@ -113,6 +114,7 @@ public:
bool hasReturn() const;
unsigned bitsPointers() const { return bits_pointers; }
+ unsigned bitsPtrOffset() const { return bits_ptr_offset; }
bool isLittleEndian() const { return little_endian; }
void syncDataWithSrc(const Function &src);

MODIFY
llvm_util/llvm2alive.cpp
llvm_util/llvm2alive.cpp
@@ -820,7 +820,7 @@ public:
return {};
Function Fn(*type, f.getName().str(), 8 * DL().getPointerSize(),
- DL().isLittleEndian());
+ DL().getIndexSizeInBits(0), DL().isLittleEndian());
reset_state(Fn);
for (auto &arg : f.args()) {

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -809,7 +809,7 @@ static void calculateAndInitConstants(Transform &t) {
auto max_geps
= ilog2_ceil(add_saturate(max(max_gep_src, max_gep_tgt), max_mem_access),
true) + 1;
- bits_for_offset = min(round_up(max_geps, 4), (uint64_t)bits_program_pointer);
+ bits_for_offset = min(round_up(max_geps, 4), (uint64_t)t.src.bitsPtrOffset());
// we need an extra bit because 1st bit of size is always 0
bits_size_t = ilog2_ceil(max_alloc_size, true);

llvm2alive: fix loading ptr offset size from datalayout