Skip to content

Commit

Permalink
Add test cases for bug reported in issue #49
Browse files Browse the repository at this point in the history
  • Loading branch information
caballa committed Nov 7, 2019
1 parent dde25dd commit 109ae43
Show file tree
Hide file tree
Showing 3 changed files with 116 additions and 0 deletions.
18 changes: 18 additions & 0 deletions tests/expected_graphs/extractvalue_constant_struct.dot
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
digraph unnamed {
graph [center=true, ratio=true, bgcolor=lightgray, fontname=Helvetica];
node [fontname=Helvetica, fontsize=11];

Node0x7fc5c8e0cdc0 [shape=record,label="{\{0:i16\}:R}"];
Node0x7fc5c8e0cf80 [shape=record,label="{\{0:i16*,4:i32\}:SMR|{<s0>\<0, unknown\>}}"];
Node0x7fc5c8e08590 [shape=plaintext, label ="\{ i16*, i32 \} undef"];
Node0x7fc5c8e08590 -> Node0x7fc5c8e0cf80[arrowtail=tee,label="0",fontsize=8,color=purple];
Node0x7fc5c8e085e0 [shape=plaintext, label ="ss0"];
Node0x7fc5c8e085e0 -> Node0x7fc5c8e0cf80[arrowtail=tee,label="0",fontsize=8,color=purple];
Node0x7fc5c8e07998 [shape=plaintext, label ="g.ptr"];
Node0x7fc5c8e07998 -> Node0x7fc5c8e0cdc0[arrowtail=tee,label="0",fontsize=8,color=purple];
Node0x7fc5c8e086c0 [shape=plaintext, label ="ss1"];
Node0x7fc5c8e086c0 -> Node0x7fc5c8e0cf80[arrowtail=tee,label="0",fontsize=8,color=purple];
Node0x7fc5c8e08758 [shape=plaintext, label ="v2.p"];
Node0x7fc5c8e08758 -> Node0x7fc5c8e0cdc0[arrowtail=tee,label="0",fontsize=8,color=purple];
Node0x7fc5c8e0cf80:s0 -> Node0x7fc5c8e0cdc0[arrowtail=tee,label="0",fontsize=8];
}
48 changes: 48 additions & 0 deletions tests/extractvalue_constant_struct.bad.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
; RUN: %seadsa %butd_dsa --sea-dsa-dot %s --sea-dsa-dot-outdir=%T/extractvalue_constant_struct.bad.ll
; RUN: %cmp-graphs %tests/extractvalue_constant_struct.dot %T/extractvalue_constant_struct.bad.ll/main.mem.dot | OutputCheck %s -d --comment=";"
; CHECK: ^OK$
; XFAIL: *

source_filename = "/tmp/st.c"
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
target triple = "i386-apple-macosx10.13.0"

%struct.s = type { i16*, i32 } ; struct with a ptr to i16 and a i32 int
@g.ptr = internal unnamed_addr global i16 42, align 4
declare void @verifier.assume.not(i1)
declare void @seahorn.fail()


; Function Attrs: noreturn
declare void @verifier.error() #0

; Function Attrs: noinline nounwind ssp uwtable
define i32 @main() local_unnamed_addr #2 {
entry:
%v1 = load i16, i16* @g.ptr
%v2.p = extractvalue %struct.s {i16* @g.ptr, i32 0}, 0
%v2 = load i16, i16* %v2.p
%cond = icmp eq i16 %v1, %v2
call void @verifier.assume.not(i1 %cond)
br label %verifier.error

verifier.error: ; preds = %entry
call void @seahorn.fail()
br label %verifier.error.split

verifier.error.split: ; preds = %verifier.error
ret i32 42
}

attributes #0 = { noreturn }
attributes #1 = { argmemonly nounwind }
attributes #2 = { noinline nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "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"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}

!0 = !{i32 1, !"NumRegisterParameters", i32 0}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"PIC Level", i32 2}
!3 = !{!"clang version 5.0.2 (tags/RELEASE_502/final)"}
50 changes: 50 additions & 0 deletions tests/extractvalue_constant_struct.ok.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
; RUN: %seadsa %butd_dsa --sea-dsa-dot %s --sea-dsa-dot-outdir=%T/extractvalue_constant_struct.ok.ll
; RUN: %cmp-graphs %tests/extractvalue_constant_struct.dot %T/extractvalue_constant_struct.ok.ll/main.mem.dot | OutputCheck %s -d --comment=";"
; CHECK: ^OK$

source_filename = "/tmp/st.c"
target datalayout = "e-m:o-p:32:32-f64:32:64-f80:128-n8:16:32-S128"
target triple = "i386-apple-macosx10.13.0"

%struct.s = type { i16*, i32 } ; struct with a ptr to i16 and a i32 int
@g.ptr = internal unnamed_addr global i16 42, align 4
declare void @verifier.assume.not(i1)
declare void @seahorn.fail()


; Function Attrs: noreturn
declare void @verifier.error() #0

; Function Attrs: noinline nounwind ssp uwtable
define i32 @main() local_unnamed_addr #2 {
entry:
%v1 = load i16, i16* @g.ptr
%ss0 = insertvalue {i16*, i32} undef, i16* @g.ptr, 0
%ss1 = insertvalue {i16*, i32} %ss0, i32 0, 1
%v2.p = extractvalue {i16*, i32} %ss0, 0
;; %v2.p = extractvalue %struct.s {i16* @g.ptr, i32 0}, 0
%v2 = load i16, i16* %v2.p
%cond = icmp eq i16 %v1, %v2
call void @verifier.assume.not(i1 %cond)
br label %verifier.error

verifier.error: ; preds = %entry
call void @seahorn.fail()
br label %verifier.error.split

verifier.error.split: ; preds = %verifier.error
ret i32 42
}

attributes #0 = { noreturn }
attributes #1 = { argmemonly nounwind }
attributes #2 = { noinline nounwind ssp uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "less-precise-fpmad"="false" "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"="penryn" "target-features"="+cx16,+fxsr,+mmx,+sse,+sse2,+sse3,+sse4.1,+ssse3,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2}
!llvm.ident = !{!3}

!0 = !{i32 1, !"NumRegisterParameters", i32 0}
!1 = !{i32 1, !"wchar_size", i32 4}
!2 = !{i32 7, !"PIC Level", i32 2}
!3 = !{!"clang version 5.0.2 (tags/RELEASE_502/final)"}

0 comments on commit 109ae43

Please sign in to comment.