Open shaobo-he opened 4 years ago
The problem is that
%2 = getelementptr inbounds %struct.f, %struct.f* undef, i32 0, i32 0
expects a cell already for the pointer operand but there is none. Typically, we solve this problem by running a pass that converts undef
into nondeterminism. Right now, I was just adding patches that solve the problem of not having a cell for the gep's pointer operand case by case. I need to do it more systematic. I can have something soon.
The problem is that
%2 = getelementptr inbounds %struct.f, %struct.f* undef, i32 0, i32 0
expects a cell already for the pointer operand but there is none. Typically, we solve this problem by running a pass that converts
undef
into nondeterminism. Right now, I was just adding patches that solve the problem of not having a cell for the gep's pointer operand case by case. I need to do it more systematic. I can have something soon.
Thank you for your reply, @caballa. Btw, sea-dsa doesn't crash on the following program that's similar to the one above.
; ModuleID = 'unallocated_dereference_fail.ll'
source_filename = "unallocated_dereference_fail.c"
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"
; Function Attrs: noinline nounwind uwtable
define dso_local i32 @main() #0 {
%1 = getelementptr inbounds i32, i32* undef, i64 0
%2 = load i32, i32* %1, align 4
ret i32 %2
}
attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-jump-tables"="false" "no-nans-fp-math"="false" "no-signed-zeros-fp-math"="false" "no-trapping-math"="false" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
!llvm.module.flags = !{!0}
!llvm.ident = !{!1}
!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{!"clang version 8.0.1- (branches/release_80)"}
I'm curious what's the difference here.
Hello sea-dsa developers,
I still observed some crashes in SV-COMP benchmarks even after the recent fixes. So I used c-reduce to produce a minimal C program for debugging. I observed some inconsistency with respect to LLVM's mem2reg optimization. Consider the following C program that c-reduce generates (let's temporary ignore the undefineness of this program and focus on the relevant part)
The following LLVM-IR program is produced by the command:
clang-8 -O0 -c -emit-llvm -S -Xclang -disable-O0-optnone floppy_true.i.cil.c
,sea-dsa's release build works fine for this program. However, if I enable the
mem2reg
optimization using the command:opt-8 floppy_true.i.cil.ll -mem2reg -S -o floppy_true.i.cil.ll
, sea-dsa crashes on the following optimized program,It appears to me
mem2reg
does a fairly reasonable optimization here by converting access to uninitialized location intoundef
. So I'd expect sea-dsa not to crash on the resulting program.