Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,9 @@ file(GLOB ae_nullptr_deref_files RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "${CMAKE_C
foreach(filename ${ae_nullptr_deref_files})
add_test(
NAME ae_nullptr_deref_tests/${filename}
COMMAND ae -null-ptr-deref ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
#TODO: add null-ptr-deref handler code: removed "-null-ptr-deref" option
#COMMAND ae -null-ptr-deref ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
COMMAND ae ${CMAKE_CURRENT_SOURCE_DIR}/${filename}
WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/bin
)
endforeach()
Expand Down
2 changes: 2 additions & 0 deletions diff_tests/difftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@ def comparer_andersen(stats1: Stats, stats2: Stats):
('basic_cpp_tests/vector-3.cpp.bc', 0.17), # 0.15063392744891338
('complex_tests/test4.c.bc', 0.29), # 0.2820512820512821
('basic_cpp_tests/global-obj-in-array.cpp.bc', 0.03), # 0.024187195645946763
('basic_cpp_tests/deque-3.cpp.bc', 0.01), # 0.0010106734674600023
('basic_cpp_tests/deque-4.cpp.bc', 0.01), # 0.0010218273679429763
]
path = sys.argv[-1] # TODO: Hack
for name, threshold in exceptions:
Expand Down
4 changes: 2 additions & 2 deletions generate_bc.sh
Original file line number Diff line number Diff line change
Expand Up @@ -105,11 +105,11 @@ for td in $test_dirs; do
then
$compiler -Wno-everything -S -c -Xclang -DINCLUDEMAIN -Wno-implicit-function-declaration -fno-discard-value-names -g -emit-llvm -I"$root" "$c_f" -o "$bc_f"
else
$compiler -Wno-everything -S -emit-llvm -fno-discard-value-names -I"$root" "$c_f" -o "$bc_f"
$compiler -fpack-struct -Wno-everything -S -emit-llvm -fno-discard-value-names -I"$root" "$c_f" -o "$bc_f"
fi
#llvm-as "$bc_f" -o "$bc_f"
opt -S -p=mem2reg "$bc_f" -o "$bc_f"
done
done

fi
fi
3 changes: 2 additions & 1 deletion src/ae_nullptr_deref_tests/dangleptr_safe_load_reassign.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// Created by Ethan Lin on 21/10/2024.
//
#include <stdlib.h>
#include <stdbool.h>

extern void SAFE_LOAD(void *p);
extern void UNSAFE_LOAD(void *p);
Expand All @@ -14,7 +15,7 @@ int main() {

free(safePtr);

safePtr = (int *)malloc(sizeof(int));
safePtr = (int *)malloc(sizeof(int));
*safePtr = 888;
SAFE_LOAD(safePtr);
svf_assert(*safePtr == 888);
Expand Down
4 changes: 2 additions & 2 deletions src/basic_c_tests/arraycopy1.c
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
extern void MAYALIAS(void*,void*);
extern void NOALIAS(void*,void*);
int main() {
int a, b;
int* source[2] = {&a, &b};
int* x = source[1];
MAYALIAS(&a,x);
NOALIAS(&a,x);
return 0;
}
32 changes: 14 additions & 18 deletions test_cases_bc/ae_assert_tests/BASIC_array_2d_0-0.c.bc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; ModuleID = '/home/runner/work/Test-Suite/Test-Suite/test_cases_bc/ae_assert_tests/BASIC_array_2d_0-0.c.bc'
source_filename = "/home/runner/work/Test-Suite/Test-Suite/src/ae_assert_tests/BASIC_array_2d_0-0.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; ModuleID = '/root/test/once_more/SVF/Test-Suite/test_cases_bc/ae_assert_tests/BASIC_array_2d_0-0.c.bc'
source_filename = "/root/test/once_more/SVF/Test-Suite/src/ae_assert_tests/BASIC_array_2d_0-0.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 !dbg !10 {
Expand All @@ -11,7 +11,7 @@ entry:
%b = alloca i32, align 4
%c = alloca i32, align 4
store i32 0, ptr %retval, align 4
call void @llvm.dbg.declare(metadata ptr %a, metadata !16, metadata !DIExpression()), !dbg !20
#dbg_declare(ptr %a, !16, !DIExpression(), !20)
%arrayidx = getelementptr inbounds [3 x [3 x i32]], ptr %a, i64 0, i64 0, !dbg !21
%arrayidx1 = getelementptr inbounds [3 x i32], ptr %arrayidx, i64 0, i64 0, !dbg !21
store i32 0, ptr %arrayidx1, align 16, !dbg !22
Expand Down Expand Up @@ -39,9 +39,9 @@ entry:
%arrayidx16 = getelementptr inbounds [3 x [3 x i32]], ptr %a, i64 0, i64 2, !dbg !37
%arrayidx17 = getelementptr inbounds [3 x i32], ptr %arrayidx16, i64 0, i64 2, !dbg !37
store i32 8, ptr %arrayidx17, align 8, !dbg !38
call void @llvm.dbg.declare(metadata ptr %b, metadata !39, metadata !DIExpression()), !dbg !40
#dbg_declare(ptr %b, !39, !DIExpression(), !40)
store i32 2, ptr %b, align 4, !dbg !40
call void @llvm.dbg.declare(metadata ptr %c, metadata !41, metadata !DIExpression()), !dbg !42
#dbg_declare(ptr %c, !41, !DIExpression(), !42)
store i32 2, ptr %c, align 4, !dbg !42
%0 = load i32, ptr %b, align 4, !dbg !43
%idxprom = sext i32 %0 to i64, !dbg !44
Expand All @@ -55,31 +55,27 @@ entry:
ret i32 0, !dbg !48
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1
declare void @svf_assert(i1 noundef zeroext) #1

declare void @svf_assert(i1 noundef zeroext) #2

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.dbg.cu = !{!0}
!llvm.module.flags = !{!2, !3, !4, !5, !6, !7, !8}
!llvm.ident = !{!9}

!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "clang version 16.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/home/runner/work/Test-Suite/Test-Suite/src/ae_assert_tests/BASIC_array_2d_0-0.c", directory: "/home/runner/work/Test-Suite/Test-Suite", checksumkind: CSK_MD5, checksum: "6093cd55e9bebab7f8de76c792a9a4f1")
!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1, producer: "Ubuntu clang version 20.1.3 (++20250415115034+9420327ad768-1~exp1~20250415235124.105)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
!1 = !DIFile(filename: "/root/test/once_more/SVF/Test-Suite/src/ae_assert_tests/BASIC_array_2d_0-0.c", directory: "/root/test/once_more/SVF/Test-Suite", checksumkind: CSK_MD5, checksum: "6093cd55e9bebab7f8de76c792a9a4f1")
!2 = !{i32 7, !"Dwarf Version", i32 5}
!3 = !{i32 2, !"Debug Info Version", i32 3}
!4 = !{i32 1, !"wchar_size", i32 4}
!5 = !{i32 8, !"PIC Level", i32 2}
!6 = !{i32 7, !"PIE Level", i32 2}
!7 = !{i32 7, !"uwtable", i32 2}
!8 = !{i32 7, !"frame-pointer", i32 2}
!9 = !{!"clang version 16.0.0"}
!9 = !{!"Ubuntu clang version 20.1.3 (++20250415115034+9420327ad768-1~exp1~20250415235124.105)"}
!10 = distinct !DISubprogram(name: "main", scope: !11, file: !11, line: 8, type: !12, scopeLine: 8, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !15)
!11 = !DIFile(filename: "src/ae_assert_tests/BASIC_array_2d_0-0.c", directory: "/home/runner/work/Test-Suite/Test-Suite", checksumkind: CSK_MD5, checksum: "6093cd55e9bebab7f8de76c792a9a4f1")
!11 = !DIFile(filename: "src/ae_assert_tests/BASIC_array_2d_0-0.c", directory: "/root/test/once_more/SVF/Test-Suite", checksumkind: CSK_MD5, checksum: "6093cd55e9bebab7f8de76c792a9a4f1")
!12 = !DISubroutineType(types: !13)
!13 = !{!14}
!14 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
Expand Down
36 changes: 16 additions & 20 deletions test_cases_bc/ae_assert_tests/BASIC_array_func_0-0.c.bc
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; ModuleID = '/home/runner/work/Test-Suite/Test-Suite/test_cases_bc/ae_assert_tests/BASIC_array_func_0-0.c.bc'
source_filename = "/home/runner/work/Test-Suite/Test-Suite/src/ae_assert_tests/BASIC_array_func_0-0.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; ModuleID = '/root/test/once_more/SVF/Test-Suite/test_cases_bc/ae_assert_tests/BASIC_array_func_0-0.c.bc'
source_filename = "/root/test/once_more/SVF/Test-Suite/src/ae_assert_tests/BASIC_array_func_0-0.c"
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-pc-linux-gnu"

@.str = private unnamed_addr constant [6 x i8] c"value\00", align 1, !dbg !0

Expand All @@ -11,9 +11,9 @@ entry:
%arr.addr = alloca ptr, align 8
%idx.addr = alloca i32, align 4
store ptr %arr, ptr %arr.addr, align 8
call void @llvm.dbg.declare(metadata ptr %arr.addr, metadata !24, metadata !DIExpression()), !dbg !25
#dbg_declare(ptr %arr.addr, !24, !DIExpression(), !25)
store i32 %idx, ptr %idx.addr, align 4
call void @llvm.dbg.declare(metadata ptr %idx.addr, metadata !26, metadata !DIExpression()), !dbg !27
#dbg_declare(ptr %idx.addr, !26, !DIExpression(), !27)
%0 = load ptr, ptr %arr.addr, align 8, !dbg !28
%1 = load i32, ptr %idx.addr, align 4, !dbg !29
%idxprom = sext i32 %1 to i64, !dbg !28
Expand All @@ -22,22 +22,19 @@ entry:
ret i32 %2, !dbg !30
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare void @llvm.dbg.declare(metadata, metadata, metadata) #1

; Function Attrs: noinline nounwind optnone uwtable
define dso_local i32 @main() #0 !dbg !31 {
entry:
%retval = alloca i32, align 4
%arr = alloca [2 x i32], align 4
%v = alloca i32, align 4
store i32 0, ptr %retval, align 4
call void @llvm.dbg.declare(metadata ptr %arr, metadata !34, metadata !DIExpression()), !dbg !38
#dbg_declare(ptr %arr, !34, !DIExpression(), !38)
%arrayidx = getelementptr inbounds [2 x i32], ptr %arr, i64 0, i64 0, !dbg !39
store i32 0, ptr %arrayidx, align 4, !dbg !40
%arrayidx1 = getelementptr inbounds [2 x i32], ptr %arr, i64 0, i64 1, !dbg !41
store i32 1, ptr %arrayidx1, align 4, !dbg !42
call void @llvm.dbg.declare(metadata ptr %v, metadata !43, metadata !DIExpression()), !dbg !44
#dbg_declare(ptr %v, !43, !DIExpression(), !44)
%arraydecay = getelementptr inbounds [2 x i32], ptr %arr, i64 0, i64 0, !dbg !45
%call = call i32 @getValue(ptr noundef %arraydecay, i32 noundef 1), !dbg !46
store i32 %call, ptr %v, align 4, !dbg !44
Expand All @@ -49,27 +46,26 @@ entry:
ret i32 0, !dbg !52
}

declare void @svf_print(i32 noundef, ptr noundef) #2
declare void @svf_print(i32 noundef, ptr noundef) #1

declare void @svf_assert(i1 noundef zeroext) #2
declare void @svf_assert(i1 noundef zeroext) #1

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="all" "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #1 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.dbg.cu = !{!7}
!llvm.module.flags = !{!10, !11, !12, !13, !14, !15, !16}
!llvm.ident = !{!17}

!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
!1 = distinct !DIGlobalVariable(scope: null, file: !2, line: 18, type: !3, isLocal: true, isDefinition: true)
!2 = !DIFile(filename: "src/ae_assert_tests/BASIC_array_func_0-0.c", directory: "/home/runner/work/Test-Suite/Test-Suite", checksumkind: CSK_MD5, checksum: "931965762cc5728ef8697a45cf5814db")
!2 = !DIFile(filename: "src/ae_assert_tests/BASIC_array_func_0-0.c", directory: "/root/test/once_more/SVF/Test-Suite", checksumkind: CSK_MD5, checksum: "931965762cc5728ef8697a45cf5814db")
!3 = !DICompositeType(tag: DW_TAG_array_type, baseType: !4, size: 48, elements: !5)
!4 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char)
!5 = !{!6}
!6 = !DISubrange(count: 6)
!7 = distinct !DICompileUnit(language: DW_LANG_C11, file: !8, producer: "clang version 16.0.0", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)
!8 = !DIFile(filename: "/home/runner/work/Test-Suite/Test-Suite/src/ae_assert_tests/BASIC_array_func_0-0.c", directory: "/home/runner/work/Test-Suite/Test-Suite", checksumkind: CSK_MD5, checksum: "931965762cc5728ef8697a45cf5814db")
!7 = distinct !DICompileUnit(language: DW_LANG_C11, file: !8, producer: "Ubuntu clang version 20.1.3 (++20250415115034+9420327ad768-1~exp1~20250415235124.105)", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !9, splitDebugInlining: false, nameTableKind: None)
!8 = !DIFile(filename: "/root/test/once_more/SVF/Test-Suite/src/ae_assert_tests/BASIC_array_func_0-0.c", directory: "/root/test/once_more/SVF/Test-Suite", checksumkind: CSK_MD5, checksum: "931965762cc5728ef8697a45cf5814db")
!9 = !{!0}
!10 = !{i32 7, !"Dwarf Version", i32 5}
!11 = !{i32 2, !"Debug Info Version", i32 3}
Expand All @@ -78,7 +74,7 @@ attributes #2 = { "frame-pointer"="all" "no-trapping-math"="true" "stack-protect
!14 = !{i32 7, !"PIE Level", i32 2}
!15 = !{i32 7, !"uwtable", i32 2}
!16 = !{i32 7, !"frame-pointer", i32 2}
!17 = !{!"clang version 16.0.0"}
!17 = !{!"Ubuntu clang version 20.1.3 (++20250415115034+9420327ad768-1~exp1~20250415235124.105)"}
!18 = distinct !DISubprogram(name: "getValue", scope: !2, file: !2, line: 9, type: !19, scopeLine: 9, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !7, retainedNodes: !23)
!19 = !DISubroutineType(types: !20)
!20 = !{!21, !22, !21}
Expand Down
Loading