fix calculation of size_t bits for VLAs
MODIFY
ir/instr.h
ir/instr.h
@@ -389,6 +389,7 @@ public:
initially_dead(initially_dead) {}
Value& getSize() const { return *size; }
+ Value* getMul() const { return mul; }
bool initDead() const { return initially_dead; }
std::vector<Value*> operands() const override;
void rauw(const Value &what, Value &with) override;

ADD
tests/alive-tv/memory/alloca-vla2.srctgt.ll
+define void @src(i32 %parm) {
+ %c = icmp eq i32 %parm, 0
+ br i1 %c, label %foo, label %gah
+
+gah:
+ %x = shl nsw i32 %parm, 1
+ %al = alloca i8, i32 %x
+ br label %foo
+
+foo:
+ ret void
+}
+
+define void @tgt(i32 %parm) {
+ %c = icmp eq i32 %parm, 0
+ br i1 %c, label %foo, label %gah
+
+gah:
+ br label %foo
+
+foo:
+ ret void
+}

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -531,6 +531,13 @@ static uint64_t max_gep(const Instr &inst) {
uint64_t mul = 1;
if (auto alloc = dynamic_cast<const Alloc*>(&inst)) {
size = &alloc->getSize();
+ if (alloc->getMul()) {
+ if (auto n = get_int(*alloc->getMul())) {
+ mul = *n;
+ } else {
+ max_alloc_size = UINT64_MAX;
+ }
+ }
} else if (auto alloc = dynamic_cast<const Malloc*>(&inst)) {
size = &alloc->getSize();
} else if (auto alloc = dynamic_cast<const Calloc*>(&inst)) {

fix calculation of size_t bits for VLAs