nullptr_is_used should consider undef pointer too
ADD
tests/alive-tv/memory/undefptr.src.ll
+define void @f() {
+ %a = bitcast i8* undef to i32*
+ %b = getelementptr i32, i32* %a, i32 1
+ store i32 undef, i32* %b
+ ret void
+}

ADD
tests/alive-tv/memory/undefptr.tgt.ll
+define void @f() {
+ %a = bitcast i8* undef to i32*
+ %b = getelementptr i32, i32* %a, i32 1
+ store i32 undef, i32* %b
+ unreachable
+}

MODIFY
tools/transform.cpp
tools/transform.cpp
@@ -320,7 +320,9 @@ static void check_refinement(Errors &errs, Transform &t,
}
static bool has_nullptr(const Value *v) {
- if (dynamic_cast<const NullPointerValue*>(v))
+ if (dynamic_cast<const NullPointerValue*>(v) ||
+ (dynamic_cast<const UndefValue*>(v) && v->getType().isPtrType()))
+ // undef pointer points to the nullblk
return true;
if (auto agg = dynamic_cast<const AggregateConst*>(v)) {

nullptr_is_used should consider undef pointer too (#190)