From 261aeef43c710e0f5c9b7c6a89138ae52e133d89 Mon Sep 17 00:00:00 2001 From: jumormt Date: Mon, 5 Feb 2024 14:14:22 +1100 Subject: [PATCH] sync with SVF --- .vscode/c_cpp_properties.json | 2 +- .vscode/tasks.json | 2 +- Assignment-2/testcase/bc/test1.ll | 32 ++--- Assignment-2/testcase/bc/test2.ll | 28 +++-- Assignment-2/testcase/dot/test1.ll.icfg.dot | 98 +++++++-------- Assignment-2/testcase/dot/test2.ll.icfg.dot | 88 ++++++------- Assignment-3/testcase/bc/CI-global.ll | 26 ++-- Assignment-3/testcase/bc/CI-local.ll | 28 ++--- Assignment-3/testcase/bc/no_alias.ll | 26 ++-- Assignment-3/testcase/dot/CI-global.dot | 33 ----- Assignment-3/testcase/dot/CI-global_final.dot | 29 +++++ Assignment-3/testcase/dot/CI-local.dot | 49 -------- Assignment-3/testcase/dot/CI-local_final.dot | 28 +++++ Assignment-3/testcase/dot/no_alias.dot | 25 ---- Assignment-3/testcase/dot/no_alias_final.dot | 27 ++++ Assignment-4/Test4.cpp | 4 +- Assignment-4/testcase/bc/test1.ll | 78 ++++-------- Assignment-4/testcase/bc/test2.ll | 81 ++++-------- Assignment-4/testcase/bc/test3.ll | 119 +++++------------- Assignment-4/testcase/bc/test4.ll | 104 +++++---------- CMakeLists.txt | 16 ++- CodeGraph/compile.sh | 2 +- Dockerfile | 2 +- env.sh | 33 +++-- 24 files changed, 391 insertions(+), 569 deletions(-) delete mode 100644 Assignment-3/testcase/dot/CI-global.dot create mode 100644 Assignment-3/testcase/dot/CI-global_final.dot delete mode 100644 Assignment-3/testcase/dot/CI-local.dot create mode 100644 Assignment-3/testcase/dot/CI-local_final.dot delete mode 100644 Assignment-3/testcase/dot/no_alias.dot create mode 100644 Assignment-3/testcase/dot/no_alias_final.dot mode change 100644 => 100755 CodeGraph/compile.sh diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json index 7dff717..4527ca1 100644 --- a/.vscode/c_cpp_properties.json +++ b/.vscode/c_cpp_properties.json @@ -7,7 +7,7 @@ "/usr/local/include/**", "/home/SVF-tools/SVF/**", "${workspaceFolder}/**", - "/home/SVF-tools/SVF/llvm-14.0.0.obj/**" + "/home/SVF-tools/SVF/llvm-16.0.0.obj/**" ], "defines": [], "compilerPath": "/usr/bin/g++", diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 3b950ee..c148a98 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ "label": "C/C++: cpp build active file", "type": "shell", // if you run SVF-Teaching not in docker container, you need to change the LLVM_DIR and SVF_DIR - "command": "cmake -g -DCMAKE_BUILD_TYPE=Debug -DSVF_DIR=/home/SVF-tools/SVF -DLLVM_DIR=/home/SVF-tools/SVF/llvm-14.0.0.obj -DZ3_DIR=/home/SVF-tools/SVF/z3.obj . && make", + "command": "cmake -g -DCMAKE_BUILD_TYPE=Debug -DSVF_DIR=/home/SVF-tools/SVF -DLLVM_DIR=/home/SVF-tools/SVF/llvm-16.0.0.obj -DZ3_DIR=/home/SVF-tools/SVF/z3.obj . && make", "options": { "cwd": "${workspaceFolder}" }, diff --git a/Assignment-2/testcase/bc/test1.ll b/Assignment-2/testcase/bc/test1.ll index 0c1cc88..616f49c 100644 --- a/Assignment-2/testcase/bc/test1.ll +++ b/Assignment-2/testcase/bc/test1.ll @@ -1,10 +1,10 @@ -; ModuleID = '../bc/test1.ll' +; ModuleID = 'test1.ll' source_filename = "test1.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" ; Function Attrs: noinline nounwind uwtable -define dso_local void @source(i32* %s) #0 { +define dso_local void @source(ptr noundef %s) #0 { entry: call void @sink() ret void @@ -20,20 +20,20 @@ entry: define dso_local i32 @main() #0 { entry: %a = alloca i32, align 4 - store i32 1, i32* %a, align 4 + store i32 1, ptr %a, align 4 br label %while.cond while.cond: ; preds = %while.body, %entry - %0 = load i32, i32* %a, align 4 + %0 = load i32, ptr %a, align 4 %cmp = icmp sle i32 %0, 1 br i1 %cmp, label %while.body, label %while.end while.body: ; preds = %while.cond - call void @source(i32* %a) - %1 = load i32, i32* %a, align 4 + call void @source(ptr noundef %a) + %1 = load i32, ptr %a, align 4 %inc = add nsw i32 %1, 1 - store i32 %inc, i32* %a, align 4 - br label %while.cond, !llvm.loop !4 + store i32 %inc, ptr %a, align 4 + br label %while.cond, !llvm.loop !6 while.end: ; preds = %while.cond ret i32 0 @@ -41,12 +41,14 @@ while.end: ; preds = %while.cond attributes #0 = { noinline nounwind 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" } -!llvm.module.flags = !{!0, !1, !2} -!llvm.ident = !{!3} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} !0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 7, !"uwtable", i32 1} -!2 = !{i32 7, !"frame-pointer", i32 2} -!3 = !{!"clang version 14.0.0"} -!4 = distinct !{!4, !5} -!5 = !{!"llvm.loop.mustprogress"} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} +!6 = distinct !{!6, !7} +!7 = !{!"llvm.loop.mustprogress"} diff --git a/Assignment-2/testcase/bc/test2.ll b/Assignment-2/testcase/bc/test2.ll index e458da3..ebc4c3a 100644 --- a/Assignment-2/testcase/bc/test2.ll +++ b/Assignment-2/testcase/bc/test2.ll @@ -1,10 +1,10 @@ -; ModuleID = '../bc/test2.ll' +; ModuleID = 'test2.ll' source_filename = "test2.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" ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @bar(i32 %s) #0 { +define dso_local i32 @bar(i32 noundef %s) #0 { entry: ret i32 %s } @@ -17,30 +17,32 @@ entry: br i1 %cmp, label %if.then, label %if.else if.then: ; preds = %entry - %call1 = call i32 @bar(i32 %call) - call void @sink(i32 %call1) + %call1 = call i32 @bar(i32 noundef %call) + call void @sink(i32 noundef %call1) br label %if.end if.else: ; preds = %entry - %call2 = call i32 @bar(i32 %call) - call void @sink(i32 %call2) + %call2 = call i32 @bar(i32 noundef %call) + call void @sink(i32 noundef %call2) br label %if.end if.end: ; preds = %if.else, %if.then ret i32 0 } -declare dso_local i32 @source(...) #1 +declare i32 @source(...) #1 -declare dso_local void @sink(i32) #1 +declare void @sink(i32 noundef) #1 attributes #0 = { noinline nounwind 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 = { "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" } -!llvm.module.flags = !{!0, !1, !2} -!llvm.ident = !{!3} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} !0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 7, !"uwtable", i32 1} -!2 = !{i32 7, !"frame-pointer", i32 2} -!3 = !{!"clang version 14.0.0"} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-2/testcase/dot/test1.ll.icfg.dot b/Assignment-2/testcase/dot/test1.ll.icfg.dot index 2c3cc7f..8812ec0 100644 --- a/Assignment-2/testcase/dot/test1.ll.icfg.dot +++ b/Assignment-2/testcase/dot/test1.ll.icfg.dot @@ -1,52 +1,52 @@ digraph "ICFG" { label="ICFG"; - Node0x5593c9c16ff0 [shape=record,color=black,label="{IntraICFGNode23 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode13 \n br label %while.cond, !llvm.loop !4 }"]; - Node0x5593c9c16ff0 -> Node0x5593c9c15cc0[style=solid]; - Node0x5593c9c16e10 [shape=record,color=black,label="{IntraICFGNode22 \{fun: main\}\nStoreStmt: [Var17 \<-- Var28] \n store i32 %inc, i32* %a, align 4 }"]; - Node0x5593c9c16e10 -> Node0x5593c9c16ff0[style=solid]; - Node0x5593c9c16c30 [shape=record,color=black,label="{IntraICFGNode21 \{fun: main\}\nBinaryOPStmt: [Var28 \<-- (Var27 opcode13 Var20)] \n %inc = add nsw i32 %1, 1 }"]; - Node0x5593c9c16c30 -> Node0x5593c9c16e10[style=solid]; - Node0x5593c9c16a60 [shape=record,color=green,label="{FunExitICFGNode20 \{fun: main\}\nPhiStmt: [Var16 \<-- ([Var32, ICFGNode18],)] \n ret i32 0 }"]; - Node0x5593c9c16880 [shape=record,color=black,label="{IntraICFGNode19 \{fun: main\}\nLoadStmt: [Var27 \<-- Var17] \n %1 = load i32, i32* %a, align 4 }"]; - Node0x5593c9c16880 -> Node0x5593c9c16c30[style=solid]; - Node0x5593c9c166a0 [shape=record,color=black,label="{IntraICFGNode18 \{fun: main\}\n ret i32 0 }"]; - Node0x5593c9c166a0 -> Node0x5593c9c16a60[style=solid]; - Node0x5593c9c163d0 [shape=record,color=blue,label="{RetICFGNode17 \{fun: main\}}"]; - Node0x5593c9c163d0 -> Node0x5593c9c16880[style=solid]; - Node0x5593c9c01c20 [shape=record,color=red,label="{CallICFGNode16 \{fun: main\}\nCallPE: [Var7 \<-- Var17] \n call void @source(i32* %a) |{0x5593c9c05110}}"]; - Node0x5593c9c01c20:s0 -> Node0x5593c9c05f90[style=solid,color=red]; - Node0x5593c9c16170 [shape=record,color=black,label="{IntraICFGNode15 \{fun: main\}\nBranchStmt: [Condition Var24]\nSuccessor 0 ICFGNode16 Successor 1 ICFGNode18 \n br i1 %cmp, label %while.body, label %while.end }"]; - Node0x5593c9c16170 -> Node0x5593c9c01c20[style=solid]; - Node0x5593c9c16170 -> Node0x5593c9c166a0[style=solid]; - Node0x5593c9c15f90 [shape=record,color=black,label="{IntraICFGNode14 \{fun: main\}\nCmpStmt: [Var24 \<-- (Var23 predicate41 Var20)] \n %cmp = icmp sle i32 %0, 1 }"]; - Node0x5593c9c15f90 -> Node0x5593c9c16170[style=solid]; - Node0x5593c9c15cc0 [shape=record,color=black,label="{IntraICFGNode13 \{fun: main\}\nLoadStmt: [Var23 \<-- Var17] \n %0 = load i32, i32* %a, align 4 }"]; - Node0x5593c9c15cc0 -> Node0x5593c9c15f90[style=solid]; - Node0x5593c9bffb50 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n i8* null \{ constant data \}\nAddrStmt: [Var20 \<-- Var3] \n i32 1 \{ constant data \}\nAddrStmt: [Var32 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var4 \<-- Var5] \n source \nAddrStmt: [Var9 \<-- Var10] \n sink \nAddrStmt: [Var14 \<-- Var15] \n main }"]; - Node0x5593c9bffb50 -> Node0x5593c9c15630[style=solid]; - Node0x5593c9c05f90 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: source\}}"]; - Node0x5593c9c05f90 -> Node0x5593c9c00530[style=solid]; - Node0x5593c9c00530 [shape=record,color=red,label="{CallICFGNode2 \{fun: source\}|{0x5593c9c03f60}}"]; - Node0x5593c9c00530:s0 -> Node0x5593c9c14e60[style=solid,color=red]; - Node0x5593c9c14d20 [shape=record,color=blue,label="{RetICFGNode3 \{fun: source\}}"]; - Node0x5593c9c14d20 -> Node0x5593c9c151f0[style=solid]; - Node0x5593c9c14e60 [shape=record,color=yellow,label="{FunEntryICFGNode4 \{fun: sink\}}"]; - Node0x5593c9c14e60 -> Node0x5593c9c15490[style=solid]; - Node0x5593c9c14f30 [shape=record,color=green,label="{FunExitICFGNode5 \{fun: sink\}|{0x5593c9c03f60}}"]; - Node0x5593c9c14f30:s0 -> Node0x5593c9c14d20[style=solid,color=blue]; - Node0x5593c9c151f0 [shape=record,color=black,label="{IntraICFGNode6 \{fun: source\}\n ret void }"]; - Node0x5593c9c151f0 -> Node0x5593c9c15380[style=solid]; - Node0x5593c9c15380 [shape=record,color=green,label="{FunExitICFGNode7 \{fun: source\}|{0x5593c9c05110}}"]; - Node0x5593c9c15380:s0 -> Node0x5593c9c163d0[style=solid,color=blue]; - Node0x5593c9c15490 [shape=record,color=black,label="{IntraICFGNode8 \{fun: sink\}\n ret void }"]; - Node0x5593c9c15490 -> Node0x5593c9c14f30[style=solid]; - Node0x5593c9c15630 [shape=record,color=yellow,label="{FunEntryICFGNode9 \{fun: main\}}"]; - Node0x5593c9c15630 -> Node0x5593c9c15760[style=solid]; - Node0x5593c9c15760 [shape=record,color=black,label="{IntraICFGNode10 \{fun: main\}\nAddrStmt: [Var17 \<-- Var18] \n %a = alloca i32, align 4 }"]; - Node0x5593c9c15760 -> Node0x5593c9c15920[style=solid]; - Node0x5593c9c15920 [shape=record,color=black,label="{IntraICFGNode11 \{fun: main\}\nStoreStmt: [Var17 \<-- Var20] \n store i32 1, i32* %a, align 4 }"]; - Node0x5593c9c15920 -> Node0x5593c9c15ae0[style=solid]; - Node0x5593c9c15ae0 [shape=record,color=black,label="{IntraICFGNode12 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode13 \n br label %while.cond }"]; - Node0x5593c9c15ae0 -> Node0x5593c9c15cc0[style=solid]; -} \ No newline at end of file + Node0x1ad97f0 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n ptr null \{ constant data \}\nAddrStmt: [Var32 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var19 \<-- Var3] \n i32 1 \{ constant data \}\nAddrStmt: [Var4 \<-- Var5] \nFunction: source \nAddrStmt: [Var9 \<-- Var10] \nFunction: sink \nAddrStmt: [Var14 \<-- Var15] \nFunction: main }"]; + Node0x1ad97f0 -> Node0x1a52f60[style=solid]; + Node0x1a623c0 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: source\}}"]; + Node0x1a623c0 -> Node0x1a65c80[style=solid]; + Node0x1a65c80 [shape=record,color=red,label="{CallICFGNode2 \{fun: source\}|{0x1ad91a0}}"]; + Node0x1a65c80:s0 -> Node0x1a58b10[style=solid,color=red]; + Node0x1a60360 [shape=record,color=blue,label="{RetICFGNode3 \{fun: source\}}"]; + Node0x1a60360 -> Node0x1acb6c0[style=solid]; + Node0x1a58b10 [shape=record,color=yellow,label="{FunEntryICFGNode4 \{fun: sink\}}"]; + Node0x1a58b10 -> Node0x1aeae20[style=solid]; + Node0x1ad9d60 [shape=record,color=green,label="{FunExitICFGNode5 \{fun: sink\}|{0x1ad91a0}}"]; + Node0x1ad9d60:s0 -> Node0x1a60360[style=solid,color=blue]; + Node0x1acb6c0 [shape=record,color=black,label="{IntraICFGNode6 \{fun: source\}\n ret void }"]; + Node0x1acb6c0 -> Node0x1aa1d20[style=solid]; + Node0x1aa1d20 [shape=record,color=green,label="{FunExitICFGNode7 \{fun: source\}|{0x1aeb5d0}}"]; + Node0x1aa1d20:s0 -> Node0x1a7a650[style=solid,color=blue]; + Node0x1aeae20 [shape=record,color=black,label="{IntraICFGNode8 \{fun: sink\}\n ret void }"]; + Node0x1aeae20 -> Node0x1ad9d60[style=solid]; + Node0x1a52f60 [shape=record,color=yellow,label="{FunEntryICFGNode9 \{fun: main\}}"]; + Node0x1a52f60 -> Node0x1a9d210[style=solid]; + Node0x1a9d210 [shape=record,color=black,label="{IntraICFGNode10 \{fun: main\}\nAddrStmt: [Var17 \<-- Var18] \n %a = alloca i32, align 4 }"]; + Node0x1a9d210 -> Node0x1a70370[style=solid]; + Node0x1a70370 [shape=record,color=black,label="{IntraICFGNode11 \{fun: main\}\nStoreStmt: [Var17 \<-- Var19] \n store i32 1, ptr %a, align 4 }"]; + Node0x1a70370 -> Node0x1a56230[style=solid]; + Node0x1a56230 [shape=record,color=black,label="{IntraICFGNode12 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode13 \n br label %while.cond }"]; + Node0x1a56230 -> Node0x1a73420[style=solid]; + Node0x1a73420 [shape=record,color=black,label="{IntraICFGNode13 \{fun: main\}\nLoadStmt: [Var23 \<-- Var17] \n %0 = load i32, ptr %a, align 4 }"]; + Node0x1a73420 -> Node0x1ad4db0[style=solid]; + Node0x1ad4db0 [shape=record,color=black,label="{IntraICFGNode14 \{fun: main\}\nCmpStmt: [Var24 \<-- (Var23 predicate41 Var19)] \n %cmp = icmp sle i32 %0, 1 }"]; + Node0x1ad4db0 -> Node0x1ae28a0[style=solid]; + Node0x1ae28a0 [shape=record,color=black,label="{IntraICFGNode15 \{fun: main\}\nBranchStmt: [Condition Var24]\nSuccessor 0 ICFGNode16 Successor 1 ICFGNode18 \n br i1 %cmp, label %while.body, label %while.end }"]; + Node0x1ae28a0 -> Node0x1a992d0[style=solid]; + Node0x1ae28a0 -> Node0x1ad4010[style=solid]; + Node0x1a992d0 [shape=record,color=red,label="{CallICFGNode16 \{fun: main\}\nCallPE: [Var7 \<-- Var17] \n call void @source(ptr noundef %a) |{0x1aeb5d0}}"]; + Node0x1a992d0:s0 -> Node0x1a623c0[style=solid,color=red]; + Node0x1a7a650 [shape=record,color=blue,label="{RetICFGNode17 \{fun: main\}}"]; + Node0x1a7a650 -> Node0x1ae4680[style=solid]; + Node0x1ad4010 [shape=record,color=black,label="{IntraICFGNode18 \{fun: main\}\n ret i32 0 }"]; + Node0x1ad4010 -> Node0x1a85d20[style=solid]; + Node0x1ae4680 [shape=record,color=black,label="{IntraICFGNode19 \{fun: main\}\nLoadStmt: [Var27 \<-- Var17] \n %1 = load i32, ptr %a, align 4 }"]; + Node0x1ae4680 -> Node0x1a85620[style=solid]; + Node0x1a85d20 [shape=record,color=green,label="{FunExitICFGNode20 \{fun: main\}\nPhiStmt: [Var16 \<-- ([Var32, ICFGNode18],)] \n ret i32 0 }"]; + Node0x1a85620 [shape=record,color=black,label="{IntraICFGNode21 \{fun: main\}\nBinaryOPStmt: [Var28 \<-- (Var27 opcode13 Var19)] \n %inc = add nsw i32 %1, 1 }"]; + Node0x1a85620 -> Node0x1ae2040[style=solid]; + Node0x1ae2040 [shape=record,color=black,label="{IntraICFGNode22 \{fun: main\}\nStoreStmt: [Var17 \<-- Var28] \n store i32 %inc, ptr %a, align 4 }"]; + Node0x1ae2040 -> Node0x1a6a460[style=solid]; + Node0x1a6a460 [shape=record,color=black,label="{IntraICFGNode23 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode13 \n br label %while.cond, !llvm.loop !6 }"]; + Node0x1a6a460 -> Node0x1a73420[style=solid]; +} diff --git a/Assignment-2/testcase/dot/test2.ll.icfg.dot b/Assignment-2/testcase/dot/test2.ll.icfg.dot index 6155be0..7551608 100644 --- a/Assignment-2/testcase/dot/test2.ll.icfg.dot +++ b/Assignment-2/testcase/dot/test2.ll.icfg.dot @@ -1,47 +1,47 @@ digraph "ICFG" { label="ICFG"; - Node0x5593c9c0b430 [shape=record,color=green,label="{FunExitICFGNode20 \{fun: main\}\nPhiStmt: [Var11 \<-- ([Var16, ICFGNode19],)] \n ret i32 0 }"]; - Node0x5593c9c0b1b0 [shape=record,color=black,label="{IntraICFGNode19 \{fun: main\}\n ret i32 0 }"]; - Node0x5593c9c0b1b0 -> Node0x5593c9c0b430[style=solid]; - Node0x5593c9c31f50 [shape=record,color=black,label="{IntraICFGNode18 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode19 \n br label %if.end }"]; - Node0x5593c9c31f50 -> Node0x5593c9c0b1b0[style=solid]; - Node0x5593c9c16ff0 [shape=record,color=black,label="{IntraICFGNode17 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode19 \n br label %if.end }"]; - Node0x5593c9c16ff0 -> Node0x5593c9c0b1b0[style=solid]; - Node0x5593c9c0ace0 [shape=record,color=blue,label="{RetICFGNode16 \{fun: main\}}"]; - Node0x5593c9c0ace0 -> Node0x5593c9c31f50[style=solid]; - Node0x5593c9c01140 [shape=record,color=red,label="{CallICFGNode15 \{fun: main\}}"]; - Node0x5593c9c01140 -> Node0x5593c9c0ace0[style=solid]; - Node0x5593c9c31e20 [shape=record,color=blue,label="{RetICFGNode14 \{fun: main\}}"]; - Node0x5593c9c31e20 -> Node0x5593c9c16ff0[style=solid]; - Node0x5593c9c01e20 [shape=record,color=red,label="{CallICFGNode13 \{fun: main\}}"]; - Node0x5593c9c01e20 -> Node0x5593c9c31e20[style=solid]; - Node0x5593c9c166a0 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n i8* null \{ constant data \}\nAddrStmt: [Var16 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var4 \<-- Var5] \n bar \nAddrStmt: [Var9 \<-- Var10] \n main \nAddrStmt: [Var13 \<-- Var14] \n source \nAddrStmt: [Var20 \<-- Var21] \n sink }"]; - Node0x5593c9c166a0 -> Node0x5593c9c14d20[style=solid]; - Node0x5593c9c14f30 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: bar\}}"]; - Node0x5593c9c14f30 -> Node0x5593c9c16880[style=solid]; - Node0x5593c9c16880 [shape=record,color=black,label="{IntraICFGNode2 \{fun: bar\}\n ret i32 %s }"]; - Node0x5593c9c16880 -> Node0x5593c9c14e60[style=solid]; - Node0x5593c9c14e60 [shape=record,color=green,label="{FunExitICFGNode3 \{fun: bar\}\nPhiStmt: [Var6 \<-- ([Var7, ICFGNode2],)] \n ret i32 %s |{0x5593c9c09680|0x5593c9c097c0}}"]; - Node0x5593c9c14e60:s0 -> Node0x5593c9c163d0[style=solid,color=blue]; - Node0x5593c9c14e60:s1 -> Node0x5593c9c16a60[style=solid,color=blue]; - Node0x5593c9c14d20 [shape=record,color=yellow,label="{FunEntryICFGNode4 \{fun: main\}}"]; - Node0x5593c9c14d20 -> Node0x5593c9c03cd0[style=solid]; - Node0x5593c9c03cd0 [shape=record,color=red,label="{CallICFGNode5 \{fun: main\}}"]; - Node0x5593c9c03cd0 -> Node0x5593c9c05f90[style=solid]; - Node0x5593c9c05f90 [shape=record,color=blue,label="{RetICFGNode6 \{fun: main\}}"]; - Node0x5593c9c05f90 -> Node0x5593c9c16c30[style=solid]; - Node0x5593c9c16c30 [shape=record,color=black,label="{IntraICFGNode7 \{fun: main\}\nCmpStmt: [Var15 \<-- (Var12 predicate38 Var16)] \n %cmp = icmp sgt i32 %call, 0 }"]; - Node0x5593c9c16c30 -> Node0x5593c9c16e10[style=solid]; - Node0x5593c9c16e10 [shape=record,color=black,label="{IntraICFGNode8 \{fun: main\}\nBranchStmt: [Condition Var15]\nSuccessor 0 ICFGNode9 Successor 1 ICFGNode11 \n br i1 %cmp, label %if.then, label %if.else }"]; - Node0x5593c9c16e10 -> Node0x5593c9c00530[style=solid]; - Node0x5593c9c16e10 -> Node0x5593c9c01c20[style=solid]; - Node0x5593c9c00530 [shape=record,color=red,label="{CallICFGNode9 \{fun: main\}\nCallPE: [Var7 \<-- Var12] \n %call1 = call i32 @bar(i32 %call) |{0x5593c9c09680}}"]; - Node0x5593c9c00530:s0 -> Node0x5593c9c14f30[style=solid,color=red]; - Node0x5593c9c163d0 [shape=record,color=blue,label="{RetICFGNode10 \{fun: main\}\nRetPE: [Var18 \<-- Var6] \n %call1 = call i32 @bar(i32 %call) }"]; - Node0x5593c9c163d0 -> Node0x5593c9c01e20[style=solid]; - Node0x5593c9c01c20 [shape=record,color=red,label="{CallICFGNode11 \{fun: main\}\nCallPE: [Var7 \<-- Var12] \n %call2 = call i32 @bar(i32 %call) |{0x5593c9c097c0}}"]; - Node0x5593c9c01c20:s0 -> Node0x5593c9c14f30[style=solid,color=red]; - Node0x5593c9c16a60 [shape=record,color=blue,label="{RetICFGNode12 \{fun: main\}\nRetPE: [Var24 \<-- Var6] \n %call2 = call i32 @bar(i32 %call) }"]; - Node0x5593c9c16a60 -> Node0x5593c9c01140[style=solid]; -} \ No newline at end of file + Node0x1a6bf20 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n ptr null \{ constant data \}\nAddrStmt: [Var16 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var4 \<-- Var5] \nFunction: bar \nAddrStmt: [Var9 \<-- Var10] \nFunction: main \nAddrStmt: [Var13 \<-- Var14] \nFunction: source \nAddrStmt: [Var20 \<-- Var21] \nFunction: sink }"]; + Node0x1a6bf20 -> Node0x1a623c0[style=solid]; + Node0x1a60360 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: bar\}}"]; + Node0x1a60360 -> Node0x1ad9d60[style=solid]; + Node0x1ad9d60 [shape=record,color=black,label="{IntraICFGNode2 \{fun: bar\}\n ret i32 %s }"]; + Node0x1ad9d60 -> Node0x1a803d0[style=solid]; + Node0x1a803d0 [shape=record,color=green,label="{FunExitICFGNode3 \{fun: bar\}\nPhiStmt: [Var6 \<-- ([Var7, ICFGNode2],)] \n ret i32 %s |{0x1a80770|0x1a801c0}}"]; + Node0x1a803d0:s0 -> Node0x1a6bfe0[style=solid,color=blue]; + Node0x1a803d0:s1 -> Node0x1a760f0[style=solid,color=blue]; + Node0x1a623c0 [shape=record,color=yellow,label="{FunEntryICFGNode4 \{fun: main\}}"]; + Node0x1a623c0 -> Node0x1ab0880[style=solid]; + Node0x1ab0880 [shape=record,color=red,label="{CallICFGNode5 \{fun: main\}}"]; + Node0x1ab0880 -> Node0x1a8ace0[style=solid]; + Node0x1a8ace0 [shape=record,color=blue,label="{RetICFGNode6 \{fun: main\}}"]; + Node0x1a8ace0 -> Node0x1a56230[style=solid]; + Node0x1a56230 [shape=record,color=black,label="{IntraICFGNode7 \{fun: main\}\nCmpStmt: [Var15 \<-- (Var12 predicate38 Var16)] \n %cmp = icmp sgt i32 %call, 0 }"]; + Node0x1a56230 -> Node0x1a687a0[style=solid]; + Node0x1a687a0 [shape=record,color=black,label="{IntraICFGNode8 \{fun: main\}\nBranchStmt: [Condition Var15]\nSuccessor 0 ICFGNode9 Successor 1 ICFGNode11 \n br i1 %cmp, label %if.then, label %if.else }"]; + Node0x1a687a0 -> Node0x1ad8f40[style=solid]; + Node0x1a687a0 -> Node0x1ab9340[style=solid]; + Node0x1ad8f40 [shape=record,color=red,label="{CallICFGNode9 \{fun: main\}\nCallPE: [Var7 \<-- Var12] \n %call1 = call i32 @bar(i32 noundef %call) |{0x1a80770}}"]; + Node0x1ad8f40:s0 -> Node0x1a60360[style=solid,color=red]; + Node0x1a6bfe0 [shape=record,color=blue,label="{RetICFGNode10 \{fun: main\}\nRetPE: [Var18 \<-- Var6] \n %call1 = call i32 @bar(i32 noundef %call) }"]; + Node0x1a6bfe0 -> Node0x1ac4690[style=solid]; + Node0x1ab9340 [shape=record,color=red,label="{CallICFGNode11 \{fun: main\}\nCallPE: [Var7 \<-- Var12] \n %call2 = call i32 @bar(i32 noundef %call) |{0x1a801c0}}"]; + Node0x1ab9340:s0 -> Node0x1a60360[style=solid,color=red]; + Node0x1a760f0 [shape=record,color=blue,label="{RetICFGNode12 \{fun: main\}\nRetPE: [Var24 \<-- Var6] \n %call2 = call i32 @bar(i32 noundef %call) }"]; + Node0x1a760f0 -> Node0x1aa24b0[style=solid]; + Node0x1ac4690 [shape=record,color=red,label="{CallICFGNode13 \{fun: main\}}"]; + Node0x1ac4690 -> Node0x1a6c270[style=solid]; + Node0x1a6c270 [shape=record,color=blue,label="{RetICFGNode14 \{fun: main\}}"]; + Node0x1a6c270 -> Node0x1ad09e0[style=solid]; + Node0x1aa24b0 [shape=record,color=red,label="{CallICFGNode15 \{fun: main\}}"]; + Node0x1aa24b0 -> Node0x1ae9910[style=solid]; + Node0x1ae9910 [shape=record,color=blue,label="{RetICFGNode16 \{fun: main\}}"]; + Node0x1ae9910 -> Node0x1a620c0[style=solid]; + Node0x1ad09e0 [shape=record,color=black,label="{IntraICFGNode17 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode19 \n br label %if.end }"]; + Node0x1ad09e0 -> Node0x1a6a4d0[style=solid]; + Node0x1a620c0 [shape=record,color=black,label="{IntraICFGNode18 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode19 \n br label %if.end }"]; + Node0x1a620c0 -> Node0x1a6a4d0[style=solid]; + Node0x1a6a4d0 [shape=record,color=black,label="{IntraICFGNode19 \{fun: main\}\n ret i32 0 }"]; + Node0x1a6a4d0 -> Node0x1a6c380[style=solid]; + Node0x1a6c380 [shape=record,color=green,label="{FunExitICFGNode20 \{fun: main\}\nPhiStmt: [Var11 \<-- ([Var16, ICFGNode19],)] \n ret i32 0 }"]; +} diff --git a/Assignment-3/testcase/bc/CI-global.ll b/Assignment-3/testcase/bc/CI-global.ll index 7d03b06..9f804e5 100644 --- a/Assignment-3/testcase/bc/CI-global.ll +++ b/Assignment-3/testcase/bc/CI-global.ll @@ -1,15 +1,15 @@ -; ModuleID = '../bc/CI-global.ll' +; ModuleID = 'CI-global.ll' source_filename = "CI-global.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" @global = dso_local global i32 0, align 4 -@p_global = dso_local global i32* null, align 8 +@p_global = dso_local global ptr null, align 8 ; Function Attrs: noinline nounwind uwtable define dso_local void @foo() #0 { entry: - store i32* @global, i32** @p_global, align 8 + store ptr @global, ptr @p_global, align 8 ret void } @@ -17,22 +17,22 @@ entry: define dso_local i32 @main() #0 { entry: call void @foo() - %0 = bitcast i32* @global to i8* - %1 = load i32*, i32** @p_global, align 8 - %2 = bitcast i32* %1 to i8* - call void @MAYALIAS(i8* %0, i8* %2) + %0 = load ptr, ptr @p_global, align 8 + call void @MAYALIAS(ptr noundef @global, ptr noundef %0) ret i32 0 } -declare dso_local void @MAYALIAS(i8*, i8*) #1 +declare void @MAYALIAS(ptr noundef, ptr noundef) #1 attributes #0 = { noinline nounwind 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 = { "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" } -!llvm.module.flags = !{!0, !1, !2} -!llvm.ident = !{!3} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} !0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 7, !"uwtable", i32 1} -!2 = !{i32 7, !"frame-pointer", i32 2} -!3 = !{!"clang version 14.0.0"} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-3/testcase/bc/CI-local.ll b/Assignment-3/testcase/bc/CI-local.ll index eae5a50..baabead 100644 --- a/Assignment-3/testcase/bc/CI-local.ll +++ b/Assignment-3/testcase/bc/CI-local.ll @@ -1,34 +1,32 @@ -; ModuleID = '../bc/CI-local.ll' +; ModuleID = 'CI-local.ll' source_filename = "CI-local.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" ; Function Attrs: noinline nounwind uwtable -define dso_local void @foo(i32* %m, i32* %n) #0 { +define dso_local void @foo(ptr noundef %m, ptr noundef %n) #0 { entry: - %0 = bitcast i32* %m to i8* - %1 = bitcast i32* %n to i8* - call void @MAYALIAS(i8* %0, i8* %1) + call void @MAYALIAS(ptr noundef %m, ptr noundef %n) ret void } -declare dso_local void @MAYALIAS(i8*, i8*) #1 +declare void @MAYALIAS(ptr noundef, ptr noundef) #1 ; Function Attrs: noinline nounwind uwtable define dso_local i32 @main() #0 { entry: %a = alloca i32, align 4 %b = alloca i32, align 4 - %0 = load i32, i32* %a, align 4 + %0 = load i32, ptr %a, align 4 %tobool = icmp ne i32 %0, 0 br i1 %tobool, label %if.then, label %if.else if.then: ; preds = %entry - call void @foo(i32* %a, i32* %b) + call void @foo(ptr noundef %a, ptr noundef %b) br label %if.end if.else: ; preds = %entry - call void @foo(i32* %b, i32* %a) + call void @foo(ptr noundef %b, ptr noundef %a) br label %if.end if.end: ; preds = %if.else, %if.then @@ -38,10 +36,12 @@ if.end: ; preds = %if.else, %if.then attributes #0 = { noinline nounwind 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 = { "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" } -!llvm.module.flags = !{!0, !1, !2} -!llvm.ident = !{!3} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} !0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 7, !"uwtable", i32 1} -!2 = !{i32 7, !"frame-pointer", i32 2} -!3 = !{!"clang version 14.0.0"} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-3/testcase/bc/no_alias.ll b/Assignment-3/testcase/bc/no_alias.ll index 1f880a6..ead12bd 100644 --- a/Assignment-3/testcase/bc/no_alias.ll +++ b/Assignment-3/testcase/bc/no_alias.ll @@ -1,32 +1,32 @@ -; ModuleID = '../bc/no_alias.ll' +; ModuleID = 'no_alias.ll' source_filename = "no_alias.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" @global_obj_f = dso_local global i32 0, align 4 -@global_ptr_f = dso_local global i32* @global_obj_f, align 8 +@global_ptr_f = dso_local global ptr @global_obj_f, align 8 ; Function Attrs: noinline nounwind uwtable define dso_local i32 @main() #0 { entry: %a = alloca i32, align 4 - store i32 5, i32* %a, align 4 - %0 = load i32*, i32** @global_ptr_f, align 8 - %1 = bitcast i32* %0 to i8* - %2 = bitcast i32* %a to i8* - call void @NOALIAS(i8* %1, i8* %2) + store i32 5, ptr %a, align 4 + %0 = load ptr, ptr @global_ptr_f, align 8 + call void @NOALIAS(ptr noundef %0, ptr noundef %a) ret i32 0 } -declare dso_local void @NOALIAS(i8*, i8*) #1 +declare void @NOALIAS(ptr noundef, ptr noundef) #1 attributes #0 = { noinline nounwind 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 = { "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" } -!llvm.module.flags = !{!0, !1, !2} -!llvm.ident = !{!3} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} !0 = !{i32 1, !"wchar_size", i32 4} -!1 = !{i32 7, !"uwtable", i32 1} -!2 = !{i32 7, !"frame-pointer", i32 2} -!3 = !{!"clang version 14.0.0"} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-3/testcase/dot/CI-global.dot b/Assignment-3/testcase/dot/CI-global.dot deleted file mode 100644 index 0852151..0000000 --- a/Assignment-3/testcase/dot/CI-global.dot +++ /dev/null @@ -1,33 +0,0 @@ -digraph "ICFG" { - label="ICFG"; - - Node0x558798083670 [shape=record,color=green,label="{FunExitICFGNode14 \{fun: main\}\nPhiStmt: [Var17 \<-- ([Var5, ICFGNode13],)] \n ret i32 0 }"]; - Node0x5587980833a0 [shape=record,color=black,label="{IntraICFGNode13 \{fun: main\}\n ret i32 0 }"]; - Node0x5587980833a0 -> Node0x558798083670[style=solid]; - Node0x55879806dfc0 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n i8* null \{ constant data \}\nAddrStmt: [Var5 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var4 \<-- Var6] \n @global = dso_local global i32 0, align 4 \{ Glob \}\nStoreStmt: [Var4 \<-- Var5] \n i32 0 \{ constant data \}\nAddrStmt: [Var7 \<-- Var9] \n @p_global = dso_local global i32* null, align 8 \{ Glob \}\nStoreStmt: [Var7 \<-- Var0] \n i32* null \{ constant data \}\nAddrStmt: [Var10 \<-- Var11] \n foo \nAddrStmt: [Var15 \<-- Var16] \n main \nAddrStmt: [Var23 \<-- Var24] \n MAYALIAS }"]; - Node0x55879806dfc0 -> Node0x558798082890[style=solid]; - Node0x558798073020 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: foo\}}"]; - Node0x558798073020 -> Node0x558798082450[style=solid]; - Node0x558798082450 [shape=record,color=black,label="{IntraICFGNode2 \{fun: foo\}\nStoreStmt: [Var7 \<-- Var4] \n store i32* @global, i32** @p_global, align 8 }"]; - Node0x558798082450 -> Node0x5587980826c0[style=solid]; - Node0x5587980826c0 [shape=record,color=black,label="{IntraICFGNode3 \{fun: foo\}\n ret void }"]; - Node0x5587980826c0 -> Node0x558798073550[style=solid]; - Node0x558798073550 [shape=record,color=green,label="{FunExitICFGNode4 \{fun: foo\}|{0x558798072ab0}}"]; - Node0x558798073550:s0 -> Node0x558798082960[style=solid,color=blue]; - Node0x558798082890 [shape=record,color=yellow,label="{FunEntryICFGNode5 \{fun: main\}}"]; - Node0x558798082890 -> Node0x55879806e0e0[style=solid]; - Node0x55879806e0e0 [shape=record,color=red,label="{CallICFGNode6 \{fun: main\}|{0x558798072ab0}}"]; - Node0x55879806e0e0:s0 -> Node0x558798073020[style=solid,color=red]; - Node0x558798082960 [shape=record,color=blue,label="{RetICFGNode7 \{fun: main\}}"]; - Node0x558798082960 -> Node0x558798082b90[style=solid]; - Node0x558798082b90 [shape=record,color=black,label="{IntraICFGNode8 \{fun: main\}\nCopyStmt: [Var19 \<-- Var4] \n %0 = bitcast i32* @global to i8* }"]; - Node0x558798082b90 -> Node0x558798082cc0[style=solid]; - Node0x558798082cc0 [shape=record,color=black,label="{IntraICFGNode9 \{fun: main\}\nLoadStmt: [Var20 \<-- Var7] \n %1 = load i32*, i32** @p_global, align 8 }"]; - Node0x558798082cc0 -> Node0x558798082ea0[style=solid]; - Node0x558798082ea0 [shape=record,color=black,label="{IntraICFGNode10 \{fun: main\}\nCopyStmt: [Var21 \<-- Var20] \n %2 = bitcast i32* %1 to i8* }"]; - Node0x558798082ea0 -> Node0x55879806f980[style=solid]; - Node0x55879806f980 [shape=record,color=red,label="{CallICFGNode11 \{fun: main\}}"]; - Node0x55879806f980 -> Node0x5587980830e0[style=solid]; - Node0x5587980830e0 [shape=record,color=blue,label="{RetICFGNode12 \{fun: main\}}"]; - Node0x5587980830e0 -> Node0x5587980833a0[style=solid]; -} diff --git a/Assignment-3/testcase/dot/CI-global_final.dot b/Assignment-3/testcase/dot/CI-global_final.dot new file mode 100644 index 0000000..fc83b9d --- /dev/null +++ b/Assignment-3/testcase/dot/CI-global_final.dot @@ -0,0 +1,29 @@ +digraph "ConstraintG" { + label="ConstraintG"; + + Node0x1d2afb0 [shape=record,shape=box,label="{0:}"]; + Node0x1d2afb0 -> Node0x1cf7680[color=black]; + Node0x1d2afb0 -> Node0x1cd7b40[color=black]; + Node0x1d2afb0 -> Node0x1d17890[color=blue]; + Node0x1cf7680 [shape=record,shape=diamond,label="{1:dummyVal}"]; + Node0x1ce0580 [shape=record,shape=box,label="{4:global}"]; + Node0x1ce0580 -> Node0x1cd7b40[color=black]; + Node0x1ce0580 -> Node0x1d17890[color=blue]; + Node0x1d5b290 [shape=record,shape=box3d,label="{6}"]; + Node0x1d5b290 -> Node0x1ce0580[color=green]; + Node0x1d17890 [shape=record,shape=box,label="{7:p_global}"]; + Node0x1d17890 -> Node0x1ce77f0[color=red]; + Node0x1cd7b40 [shape=record,shape=box3d,label="{8}"]; + Node0x1cd7b40 -> Node0x1d17890[color=green]; + Node0x1cd7b40 -> Node0x1ce77f0[color=black]; + Node0x1d1bd00 [shape=record,shape=box,label="{9:foo}"]; + Node0x1cffd70 [shape=record,shape=box3d,label="{10}"]; + Node0x1cffd70 -> Node0x1d1bd00[color=green]; + Node0x1d4c6e0 [shape=record,shape=box,label="{14:main}"]; + Node0x1d37150 [shape=record,shape=box3d,label="{15}"]; + Node0x1d37150 -> Node0x1d4c6e0[color=green]; + Node0x1ce77f0 [shape=record,shape=box,label="{18:}"]; + Node0x1d304c0 [shape=record,shape=box,label="{20:MAYALIAS}"]; + Node0x1d4a9c0 [shape=record,shape=box3d,label="{21}"]; + Node0x1d4a9c0 -> Node0x1d304c0[color=green]; +} diff --git a/Assignment-3/testcase/dot/CI-local.dot b/Assignment-3/testcase/dot/CI-local.dot deleted file mode 100644 index 6d62510..0000000 --- a/Assignment-3/testcase/dot/CI-local.dot +++ /dev/null @@ -1,49 +0,0 @@ -digraph "ICFG" { - label="ICFG"; - - Node0x55d5b1c7d000 [shape=record,color=green,label="{FunExitICFGNode21 \{fun: main\}\nPhiStmt: [Var20 \<-- ([Var27, ICFGNode20],)] \n ret i32 0 }"]; - Node0x55d5b1c7cd80 [shape=record,color=black,label="{IntraICFGNode20 \{fun: main\}\n ret i32 0 }"]; - Node0x55d5b1c7cd80 -> Node0x55d5b1c7d000[style=solid]; - Node0x55d5b1c7cba0 [shape=record,color=black,label="{IntraICFGNode19 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode20 \n br label %if.end }"]; - Node0x55d5b1c7cba0 -> Node0x55d5b1c7cd80[style=solid]; - Node0x55d5b1c7c9c0 [shape=record,color=black,label="{IntraICFGNode18 \{fun: main\}\nBranchStmt: [ Unconditional branch]\nSuccessor 0 ICFGNode20 \n br label %if.end }"]; - Node0x55d5b1c7c9c0 -> Node0x55d5b1c7cd80[style=solid]; - Node0x55d5b1c7c6d0 [shape=record,color=blue,label="{RetICFGNode17 \{fun: main\}}"]; - Node0x55d5b1c7c6d0 -> Node0x55d5b1c7cba0[style=solid]; - Node0x55d5b1c68c60 [shape=record,color=red,label="{CallICFGNode16 \{fun: main\}\nCallPE: [Var7 \<-- Var23] \n call void @foo(i32* %b, i32* %a) \nCallPE: [Var8 \<-- Var21] \n call void @foo(i32* %b, i32* %a) |{0x55d5b1c6c060}}"]; - Node0x55d5b1c68c60:s0 -> Node0x55d5b1c6c1f0[style=solid,color=red]; - Node0x55d5b1c7c3a0 [shape=record,color=blue,label="{RetICFGNode15 \{fun: main\}}"]; - Node0x55d5b1c7c3a0 -> Node0x55d5b1c7c9c0[style=solid]; - Node0x55d5b1c68a60 [shape=record,color=red,label="{CallICFGNode14 \{fun: main\}\nCallPE: [Var7 \<-- Var21] \n call void @foo(i32* %a, i32* %b) \nCallPE: [Var8 \<-- Var23] \n call void @foo(i32* %a, i32* %b) |{0x55d5b1c6be70}}"]; - Node0x55d5b1c68a60:s0 -> Node0x55d5b1c6c1f0[style=solid,color=red]; - Node0x55d5b1c7c050 [shape=record,color=black,label="{IntraICFGNode13 \{fun: main\}\nBranchStmt: [Condition Var26]\nSuccessor 0 ICFGNode14 Successor 1 ICFGNode16 \n br i1 %tobool, label %if.then, label %if.else }"]; - Node0x55d5b1c7c050 -> Node0x55d5b1c68a60[style=solid]; - Node0x55d5b1c7c050 -> Node0x55d5b1c68c60[style=solid]; - Node0x55d5b1c66970 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n i8* null \{ constant data \}\nAddrStmt: [Var27 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var4 \<-- Var5] \n foo \nAddrStmt: [Var12 \<-- Var13] \n MAYALIAS \nAddrStmt: [Var18 \<-- Var19] \n main }"]; - Node0x55d5b1c66970 -> Node0x55d5b1c7b880[style=solid]; - Node0x55d5b1c6c1f0 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: foo\}}"]; - Node0x55d5b1c6c1f0 -> Node0x55d5b1c7b0d0[style=solid]; - Node0x55d5b1c7b0d0 [shape=record,color=black,label="{IntraICFGNode2 \{fun: foo\}\nCopyStmt: [Var9 \<-- Var7] \n %0 = bitcast i32* %m to i8* }"]; - Node0x55d5b1c7b0d0 -> Node0x55d5b1c7b340[style=solid]; - Node0x55d5b1c7b340 [shape=record,color=black,label="{IntraICFGNode3 \{fun: foo\}\nCopyStmt: [Var10 \<-- Var8] \n %1 = bitcast i32* %n to i8* }"]; - Node0x55d5b1c7b340 -> Node0x55d5b1c6f250[style=solid]; - Node0x55d5b1c6f250 [shape=record,color=red,label="{CallICFGNode4 \{fun: foo\}}"]; - Node0x55d5b1c6f250 -> Node0x55d5b1c6c750[style=solid]; - Node0x55d5b1c6c750 [shape=record,color=blue,label="{RetICFGNode5 \{fun: foo\}}"]; - Node0x55d5b1c6c750 -> Node0x55d5b1c7b5e0[style=solid]; - Node0x55d5b1c7b5e0 [shape=record,color=black,label="{IntraICFGNode6 \{fun: foo\}\n ret void }"]; - Node0x55d5b1c7b5e0 -> Node0x55d5b1c7b700[style=solid]; - Node0x55d5b1c7b700 [shape=record,color=green,label="{FunExitICFGNode7 \{fun: foo\}|{0x55d5b1c6be70|0x55d5b1c6c060}}"]; - Node0x55d5b1c7b700:s0 -> Node0x55d5b1c7c3a0[style=solid,color=blue]; - Node0x55d5b1c7b700:s1 -> Node0x55d5b1c7c6d0[style=solid,color=blue]; - Node0x55d5b1c7b880 [shape=record,color=yellow,label="{FunEntryICFGNode8 \{fun: main\}}"]; - Node0x55d5b1c7b880 -> Node0x55d5b1c7b950[style=solid]; - Node0x55d5b1c7b950 [shape=record,color=black,label="{IntraICFGNode9 \{fun: main\}\nAddrStmt: [Var21 \<-- Var22] \n %a = alloca i32, align 4 }"]; - Node0x55d5b1c7b950 -> Node0x55d5b1c7bb10[style=solid]; - Node0x55d5b1c7bb10 [shape=record,color=black,label="{IntraICFGNode10 \{fun: main\}\nAddrStmt: [Var23 \<-- Var24] \n %b = alloca i32, align 4 }"]; - Node0x55d5b1c7bb10 -> Node0x55d5b1c7bcd0[style=solid]; - Node0x55d5b1c7bcd0 [shape=record,color=black,label="{IntraICFGNode11 \{fun: main\}\nLoadStmt: [Var25 \<-- Var21] \n %0 = load i32, i32* %a, align 4 }"]; - Node0x55d5b1c7bcd0 -> Node0x55d5b1c7be90[style=solid]; - Node0x55d5b1c7be90 [shape=record,color=black,label="{IntraICFGNode12 \{fun: main\}\nCmpStmt: [Var26 \<-- (Var25 predicate33 Var27)] \n %tobool = icmp ne i32 %0, 0 }"]; - Node0x55d5b1c7be90 -> Node0x55d5b1c7c050[style=solid]; -} diff --git a/Assignment-3/testcase/dot/CI-local_final.dot b/Assignment-3/testcase/dot/CI-local_final.dot new file mode 100644 index 0000000..c636770 --- /dev/null +++ b/Assignment-3/testcase/dot/CI-local_final.dot @@ -0,0 +1,28 @@ +digraph "ConstraintG" { + label="ConstraintG"; + + Node0x1d004d0 [shape=record,shape=box,label="{0:}"]; + Node0x1d004d0 -> Node0x1cdaeb0[color=black]; + Node0x1cdaeb0 [shape=record,shape=diamond,label="{1:dummyVal}"]; + Node0x1d48cf0 [shape=record,shape=box,label="{4:foo}"]; + Node0x1d036a0 [shape=record,shape=box3d,label="{5}"]; + Node0x1d036a0 -> Node0x1d48cf0[color=green]; + Node0x1d5d8f0 [shape=record,shape=box,label="{7:m}"]; + Node0x1d03c70 [shape=record,shape=box,label="{8:n}"]; + Node0x1ce7860 [shape=record,shape=box,label="{10:MAYALIAS}"]; + Node0x1cf7e70 [shape=record,shape=box3d,label="{11}"]; + Node0x1cf7e70 -> Node0x1ce7860[color=green]; + Node0x1d12f20 [shape=record,shape=box,label="{16:main}"]; + Node0x1d09f40 [shape=record,shape=box3d,label="{17}"]; + Node0x1d09f40 -> Node0x1d12f20[color=green]; + Node0x1d115d0 [shape=record,shape=box,label="{19:}"]; + Node0x1d115d0 -> Node0x1d5d8f0[color=black]; + Node0x1d115d0 -> Node0x1d03c70[color=black]; + Node0x1d35e80 [shape=record,shape=box3d,label="{20}"]; + Node0x1d35e80 -> Node0x1d115d0[color=green]; + Node0x1d52750 [shape=record,shape=box,label="{22:}"]; + Node0x1d52750 -> Node0x1d5d8f0[color=black]; + Node0x1d52750 -> Node0x1d03c70[color=black]; + Node0x1d5f860 [shape=record,shape=box3d,label="{23}"]; + Node0x1d5f860 -> Node0x1d52750[color=green]; +} diff --git a/Assignment-3/testcase/dot/no_alias.dot b/Assignment-3/testcase/dot/no_alias.dot deleted file mode 100644 index 5f22194..0000000 --- a/Assignment-3/testcase/dot/no_alias.dot +++ /dev/null @@ -1,25 +0,0 @@ -digraph "ICFG" { - label="ICFG"; - - Node0x55cc83e74600 [shape=record,color=green,label="{FunExitICFGNode10 \{fun: main\}\nPhiStmt: [Var11 \<-- ([Var5, ICFGNode9],)] \n ret i32 0 }"]; - Node0x55cc83e74420 [shape=record,color=black,label="{IntraICFGNode9 \{fun: main\}\n ret i32 0 }"]; - Node0x55cc83e74420 -> Node0x55cc83e74600[style=solid]; - Node0x55cc83e64dc0 [shape=record,color=blue,label="{RetICFGNode8 \{fun: main\}}"]; - Node0x55cc83e64dc0 -> Node0x55cc83e74420[style=solid]; - Node0x55cc83e5fda0 [shape=record,color=red,label="{CallICFGNode7 \{fun: main\}}"]; - Node0x55cc83e5fda0 -> Node0x55cc83e64dc0[style=solid]; - Node0x55cc83e74150 [shape=record,color=black,label="{IntraICFGNode6 \{fun: main\}\nCopyStmt: [Var18 \<-- Var12] \n %2 = bitcast i32* %a to i8* }"]; - Node0x55cc83e74150 -> Node0x55cc83e5fda0[style=solid]; - Node0x55cc83e74030 [shape=record,color=black,label="{IntraICFGNode5 \{fun: main\}\nCopyStmt: [Var17 \<-- Var16] \n %1 = bitcast i32* %0 to i8* }"]; - Node0x55cc83e74030 -> Node0x55cc83e74150[style=solid]; - Node0x55cc83e73f10 [shape=record,color=black,label="{IntraICFGNode4 \{fun: main\}\nLoadStmt: [Var16 \<-- Var7] \n %0 = load i32*, i32** @global_ptr_f, align 8 }"]; - Node0x55cc83e73f10 -> Node0x55cc83e74030[style=solid]; - Node0x55cc83e73df0 [shape=record,color=black,label="{IntraICFGNode3 \{fun: main\}\nStoreStmt: [Var12 \<-- Var15] \n store i32 5, i32* %a, align 4 }"]; - Node0x55cc83e73df0 -> Node0x55cc83e73f10[style=solid]; - Node0x55cc83e73b80 [shape=record,color=black,label="{IntraICFGNode2 \{fun: main\}\nAddrStmt: [Var12 \<-- Var13] \n %a = alloca i32, align 4 }"]; - Node0x55cc83e73b80 -> Node0x55cc83e73df0[style=solid]; - Node0x55cc83e64890 [shape=record,color=yellow,label="{FunEntryICFGNode1 \{fun: main\}}"]; - Node0x55cc83e64890 -> Node0x55cc83e73b80[style=solid]; - Node0x55cc83e5f7f0 [shape=record,color=purple,label="{GlobalICFGNode0\nCopyStmt: [Var1 \<-- Var0] \n i8* null \{ constant data \}\nAddrStmt: [Var5 \<-- Var3] \n i32 0 \{ constant data \}\nAddrStmt: [Var15 \<-- Var3] \n i32 5 \{ constant data \}\nAddrStmt: [Var4 \<-- Var6] \n @global_obj_f = dso_local global i32 0, align 4 \{ Glob \}\nStoreStmt: [Var4 \<-- Var5] \n i32 0 \{ constant data \}\nAddrStmt: [Var7 \<-- Var8] \n @global_ptr_f = dso_local global i32* @global_obj_f, align 8 \{ Glob \}\nStoreStmt: [Var7 \<-- Var4] \n @global_obj_f = dso_local global i32 0, align 4 \{ Glob \}\nAddrStmt: [Var9 \<-- Var10] \n main \nAddrStmt: [Var20 \<-- Var21] \n NOALIAS }"]; - Node0x55cc83e5f7f0 -> Node0x55cc83e64890[style=solid]; -} diff --git a/Assignment-3/testcase/dot/no_alias_final.dot b/Assignment-3/testcase/dot/no_alias_final.dot new file mode 100644 index 0000000..f588419 --- /dev/null +++ b/Assignment-3/testcase/dot/no_alias_final.dot @@ -0,0 +1,27 @@ +digraph "ConstraintG" { + label="ConstraintG"; + + Node0x1d08ed0 [shape=record,shape=box,label="{0:}"]; + Node0x1d08ed0 -> Node0x1d29660[color=black]; + Node0x1d29660 [shape=record,shape=diamond,label="{1:dummyVal}"]; + Node0x1ce4210 [shape=record,shape=box,label="{4:global_obj_f}"]; + Node0x1ce4210 -> Node0x1d5a900[color=black]; + Node0x1ce4210 -> Node0x1d57430[color=blue]; + Node0x1d48fe0 [shape=record,shape=box3d,label="{6}"]; + Node0x1d48fe0 -> Node0x1ce4210[color=green]; + Node0x1d57430 [shape=record,shape=box,label="{7:global_ptr_f}"]; + Node0x1d57430 -> Node0x1cdd9a0[color=red]; + Node0x1d5a900 [shape=record,shape=box3d,label="{8}"]; + Node0x1d5a900 -> Node0x1d57430[color=green]; + Node0x1d5a900 -> Node0x1cdd9a0[color=black]; + Node0x1d227b0 [shape=record,shape=box,label="{9:main}"]; + Node0x1d2c620 [shape=record,shape=box3d,label="{10}"]; + Node0x1d2c620 -> Node0x1d227b0[color=green]; + Node0x1d44ae0 [shape=record,shape=box,label="{12:}"]; + Node0x1ceccf0 [shape=record,shape=box3d,label="{13}"]; + Node0x1ceccf0 -> Node0x1d44ae0[color=green]; + Node0x1cdd9a0 [shape=record,shape=box,label="{17:}"]; + Node0x1d0c6e0 [shape=record,shape=box,label="{19:NOALIAS}"]; + Node0x1d2fdf0 [shape=record,shape=box3d,label="{20}"]; + Node0x1d2fdf0 -> Node0x1d0c6e0[color=green]; +} diff --git a/Assignment-4/Test4.cpp b/Assignment-4/Test4.cpp index e660c5c..9e4bb4d 100644 --- a/Assignment-4/Test4.cpp +++ b/Assignment-4/Test4.cpp @@ -45,7 +45,7 @@ void Test1() SVF::SVFIR *pag = builder.build(); TaintGraphTraversal* taint = new TaintGraphTraversal(pag); taint->taintChecking(); - set expected = {"START: 6->1->2->3->4->7->8->9->10->END"}; + set expected = {"START: 5->1->2->3->6->7->8->9->END"}; assert(taint->getPaths() == expected && " \n wrong paths generated - test1 failed !"); cout << "\n test1 passed !" << endl; SVF::LLVMModuleSet::releaseLLVMModuleSet(); @@ -97,7 +97,7 @@ void Test4() TaintGraphTraversal* taint = new TaintGraphTraversal(pag); taint->taintChecking(); - set expected = {"START: 6->1->2->3->4->7->8->9->10->11->13->15->END"}; + set expected = {"START: 5->1->2->3->6->7->8->9->10->12->14->END"}; assert(taint->getPaths() == expected && " \n wrong paths generated - test4 failed !"); cout << "\n test4 passed !" << endl; SVF::LLVMModuleSet::releaseLLVMModuleSet(); diff --git a/Assignment-4/testcase/bc/test1.ll b/Assignment-4/testcase/bc/test1.ll index 1ce3845..b5da097 100644 --- a/Assignment-4/testcase/bc/test1.ll +++ b/Assignment-4/testcase/bc/test1.ll @@ -1,74 +1,38 @@ ; ModuleID = 'test1.ll' -source_filename = "Assignment-4/testcase/src/test1.c" +source_filename = "test1.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" -@tgetstr.initstr = internal global [25 x i8] c"select* From City ..\00\00\00\00\00", align 16, !dbg !0 +@tgetstr.initstr = internal global [25 x i8] c"select* From City ..\00\00\00\00\00", align 16 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @tgetstr() #0 !dbg !2 { +define dso_local ptr @tgetstr() #0 { entry: - ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @tgetstr.initstr, i64 0, i64 0), !dbg !18 + ret ptr @tgetstr.initstr } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !19 { +define dso_local i32 @main() #0 { entry: - %call = call i8* @tgetstr(), !dbg !23 - call void @llvm.dbg.value(metadata i8* %call, metadata !24, metadata !DIExpression()), !dbg !25 - call void @llvm.dbg.value(metadata i8* %call, metadata !26, metadata !DIExpression()), !dbg !25 - call void @llvm.dbg.value(metadata i8* %call, metadata !27, metadata !DIExpression()), !dbg !25 - call void @MAYALIAS(i8* %call, i8* %call), !dbg !28 - call void @broadcast(i8* %call), !dbg !29 - ret i32 0, !dbg !30 + %call = call ptr @tgetstr() + call void @MAYALIAS(ptr noundef %call, ptr noundef %call) + call void @broadcast(ptr noundef %call) + ret i32 0 } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +declare void @MAYALIAS(ptr noundef, ptr noundef) #1 -declare dso_local void @MAYALIAS(i8*, i8*) #2 +declare void @broadcast(ptr noundef) #1 -declare dso_local void @broadcast(i8*) #2 +attributes #0 = { noinline nounwind 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 = { "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" } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} -attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone speculatable willreturn } -attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!8} -!llvm.module.flags = !{!14, !15, !16} -!llvm.ident = !{!17} - -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "initstr", scope: !2, file: !3, line: 7, type: !11, isLocal: true, isDefinition: true) -!2 = distinct !DISubprogram(name: "tgetstr", scope: !3, file: !3, line: 5, type: !4, scopeLine: 5, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !9) -!3 = !DIFile(filename: "Assignment-4/testcase/src/test1.c", directory: "/home/SVF-tools/SVF-Teaching") -!4 = !DISubroutineType(types: !5) -!5 = !{!6} -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) -!8 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !9, globals: !10, splitDebugInlining: false, nameTableKind: None) -!9 = !{} -!10 = !{!0} -!11 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 200, elements: !12) -!12 = !{!13} -!13 = !DISubrange(count: 25) -!14 = !{i32 7, !"Dwarf Version", i32 4} -!15 = !{i32 2, !"Debug Info Version", i32 3} -!16 = !{i32 1, !"wchar_size", i32 4} -!17 = !{!"clang version 10.0.0 "} -!18 = !DILocation(line: 8, column: 5, scope: !2) -!19 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 12, type: !20, scopeLine: 12, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !9) -!20 = !DISubroutineType(types: !21) -!21 = !{!22} -!22 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!23 = !DILocation(line: 13, column: 23, scope: !19) -!24 = !DILocalVariable(name: "injection", scope: !19, file: !3, line: 13, type: !6) -!25 = !DILocation(line: 0, scope: !19) -!26 = !DILocalVariable(name: "s", scope: !19, file: !3, line: 14, type: !6) -!27 = !DILocalVariable(name: "b", scope: !19, file: !3, line: 15, type: !6) -!28 = !DILocation(line: 16, column: 5, scope: !19) -!29 = !DILocation(line: 17, column: 5, scope: !19) -!30 = !DILocation(line: 19, column: 5, scope: !19) +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-4/testcase/bc/test2.ll b/Assignment-4/testcase/bc/test2.ll index 13753d1..aa1b6bc 100644 --- a/Assignment-4/testcase/bc/test2.ll +++ b/Assignment-4/testcase/bc/test2.ll @@ -1,78 +1,39 @@ ; ModuleID = 'test2.ll' -source_filename = "./Assignment-4/testcase/src/test2.c" +source_filename = "test2.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" -@tgetstr.initstr = internal global [25 x i8] c"select* From City ..\00\00\00\00\00", align 16, !dbg !0 +@tgetstr.initstr = internal global [25 x i8] c"select* From City ..\00\00\00\00\00", align 16 @.str = private unnamed_addr constant [6 x i8] c"hello\00", align 1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @tgetstr() #0 !dbg !2 { +define dso_local ptr @tgetstr() #0 { entry: - ret i8* getelementptr inbounds ([25 x i8], [25 x i8]* @tgetstr.initstr, i64 0, i64 0), !dbg !19 + ret ptr @tgetstr.initstr } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !20 { +define dso_local i32 @main() #0 { entry: - %call = call i8* @tgetstr(), !dbg !24 - call void @llvm.dbg.value(metadata i8* %call, metadata !25, metadata !DIExpression()), !dbg !26 - call void @llvm.dbg.value(metadata i8* %call, metadata !27, metadata !DIExpression()), !dbg !26 - call void @llvm.dbg.value(metadata i8* %call, metadata !28, metadata !DIExpression()), !dbg !26 - call void @llvm.dbg.value(metadata i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), metadata !29, metadata !DIExpression()), !dbg !26 - call void @broadcast(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)), !dbg !30 - call void @NOALIAS(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i8* %call), !dbg !31 - ret i32 0, !dbg !32 + %call = call ptr @tgetstr() + call void @broadcast(ptr noundef @.str) + call void @NOALIAS(ptr noundef @.str, ptr noundef %call) + ret i32 0 } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 +declare void @broadcast(ptr noundef) #1 -declare dso_local void @broadcast(i8*) #2 +declare void @NOALIAS(ptr noundef, ptr noundef) #1 -declare dso_local void @NOALIAS(i8*, i8*) #2 +attributes #0 = { noinline nounwind 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 = { "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" } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} -attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone speculatable willreturn } -attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } - -!llvm.dbg.cu = !{!8} -!llvm.module.flags = !{!15, !16, !17} -!llvm.ident = !{!18} - -!0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression()) -!1 = distinct !DIGlobalVariable(name: "initstr", scope: !2, file: !3, line: 8, type: !12, isLocal: true, isDefinition: true) -!2 = distinct !DISubprogram(name: "tgetstr", scope: !3, file: !3, line: 6, type: !4, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !10) -!3 = !DIFile(filename: "./Assignment-4/testcase/src/test2.c", directory: "/home/SVF-tools/SVF-Teaching") -!4 = !DISubroutineType(types: !5) -!5 = !{!6} -!6 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !7, size: 64) -!7 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) -!8 = distinct !DICompileUnit(language: DW_LANG_C99, file: !9, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !10, globals: !11, splitDebugInlining: false, nameTableKind: None) -!9 = !DIFile(filename: "Assignment-4/testcase/src/test2.c", directory: "/home/SVF-tools/SVF-Teaching") -!10 = !{} -!11 = !{!0} -!12 = !DICompositeType(tag: DW_TAG_array_type, baseType: !7, size: 200, elements: !13) -!13 = !{!14} -!14 = !DISubrange(count: 25) -!15 = !{i32 7, !"Dwarf Version", i32 4} -!16 = !{i32 2, !"Debug Info Version", i32 3} -!17 = !{i32 1, !"wchar_size", i32 4} -!18 = !{!"clang version 10.0.0 "} -!19 = !DILocation(line: 9, column: 5, scope: !2) -!20 = distinct !DISubprogram(name: "main", scope: !3, file: !3, line: 13, type: !21, scopeLine: 13, spFlags: DISPFlagDefinition, unit: !8, retainedNodes: !10) -!21 = !DISubroutineType(types: !22) -!22 = !{!23} -!23 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!24 = !DILocation(line: 14, column: 23, scope: !20) -!25 = !DILocalVariable(name: "injection", scope: !20, file: !3, line: 14, type: !6) -!26 = !DILocation(line: 0, scope: !20) -!27 = !DILocalVariable(name: "s", scope: !20, file: !3, line: 15, type: !6) -!28 = !DILocalVariable(name: "b", scope: !20, file: !3, line: 16, type: !6) -!29 = !DILocalVariable(name: "safe_token", scope: !20, file: !3, line: 17, type: !6) -!30 = !DILocation(line: 18, column: 5, scope: !20) -!31 = !DILocation(line: 19, column: 5, scope: !20) -!32 = !DILocation(line: 20, column: 5, scope: !20) +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} diff --git a/Assignment-4/testcase/bc/test3.ll b/Assignment-4/testcase/bc/test3.ll index 1187d53..48688dc 100644 --- a/Assignment-4/testcase/bc/test3.ll +++ b/Assignment-4/testcase/bc/test3.ll @@ -1,119 +1,64 @@ ; ModuleID = 'test3.ll' -source_filename = "./Assignment-4/testcase/src/test3.c" +source_filename = "test3.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" @.str = private unnamed_addr constant [6 x i8] c"hello\00", align 1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @foo(i8* %token) #0 !dbg !7 { +define dso_local ptr @foo(ptr noundef %token) #0 { entry: - call void @llvm.dbg.value(metadata i8* %token, metadata !13, metadata !DIExpression()), !dbg !14 - ret i8* %token, !dbg !15 + ret ptr %token } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !16 { +define dso_local i32 @main() #0 { entry: - call void @llvm.dbg.value(metadata i8 1, metadata !20, metadata !DIExpression()), !dbg !22 - call void @llvm.dbg.value(metadata i8 0, metadata !23, metadata !DIExpression()), !dbg !22 - %call = call i8* (...) @getchar(), !dbg !24 - call void @llvm.dbg.value(metadata i8* %call, metadata !25, metadata !DIExpression()), !dbg !22 - call void @llvm.dbg.value(metadata i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), metadata !26, metadata !DIExpression()), !dbg !22 - br label %while.cond, !dbg !27 + %call = call ptr (...) @getchar() + br label %while.cond while.cond: ; preds = %if.end, %entry - %tobool = trunc i8 1 to i1, !dbg !28 - br i1 %tobool, label %while.body, label %while.end, !dbg !27 + %tobool = trunc i8 1 to i1 + br i1 %tobool, label %while.body, label %while.end while.body: ; preds = %while.cond - %tobool1 = trunc i8 0 to i1, !dbg !29 - br i1 %tobool1, label %if.then, label %if.else, !dbg !32 + %tobool1 = trunc i8 0 to i1 + br i1 %tobool1, label %if.then, label %if.else if.then: ; preds = %while.body - %call2 = call i8* @foo(i8* %call), !dbg !33 - call void @llvm.dbg.value(metadata i8* %call2, metadata !35, metadata !DIExpression()), !dbg !36 - br label %if.end, !dbg !37 + %call2 = call ptr @foo(ptr noundef %call) + br label %if.end if.else: ; preds = %while.body - %call3 = call i8* @foo(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0)), !dbg !38 - call void @llvm.dbg.value(metadata i8* %call3, metadata !40, metadata !DIExpression()), !dbg !41 - call void (i8*, ...) bitcast (void (...)* @broadcast to void (i8*, ...)*)(i8* %call3), !dbg !42 - call void @NOALIAS(i8* %call, i8* %call3), !dbg !43 + %call3 = call ptr @foo(ptr noundef @.str) + call void (ptr, ...) @broadcast(ptr noundef %call3) + call void @NOALIAS(ptr noundef %call, ptr noundef %call3) br label %if.end if.end: ; preds = %if.else, %if.then - br label %while.cond, !dbg !27, !llvm.loop !44 + br label %while.cond, !llvm.loop !6 while.end: ; preds = %while.cond - ret i32 0, !dbg !46 + ret i32 0 } -declare dso_local i8* @getchar(...) #2 - -declare dso_local void @broadcast(...) #2 - -declare dso_local void @NOALIAS(i8*, i8*) #2 +declare ptr @getchar(...) #1 -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare void @broadcast(...) #1 -attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone speculatable willreturn } -attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +declare void @NOALIAS(ptr noundef, ptr noundef) #1 -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} +attributes #0 = { noinline nounwind 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 = { "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" } -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) -!1 = !DIFile(filename: "Assignment-4/testcase/src/test3.c", directory: "/home/SVF-tools/SVF-Teaching") -!2 = !{} -!3 = !{i32 7, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{!"clang version 10.0.0 "} -!7 = distinct !DISubprogram(name: "foo", scope: !8, file: !8, line: 4, type: !9, scopeLine: 4, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!8 = !DIFile(filename: "./Assignment-4/testcase/src/test3.c", directory: "/home/SVF-tools/SVF-Teaching") -!9 = !DISubroutineType(types: !10) -!10 = !{!11, !11} -!11 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) -!12 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) -!13 = !DILocalVariable(name: "token", arg: 1, scope: !7, file: !8, line: 4, type: !11) -!14 = !DILocation(line: 0, scope: !7) -!15 = !DILocation(line: 4, column: 29, scope: !7) -!16 = distinct !DISubprogram(name: "main", scope: !8, file: !8, line: 6, type: !17, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!17 = !DISubroutineType(types: !18) -!18 = !{!19} -!19 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!20 = !DILocalVariable(name: "loopCondition", scope: !16, file: !8, line: 7, type: !21) -!21 = !DIBasicType(name: "_Bool", size: 8, encoding: DW_ATE_boolean) -!22 = !DILocation(line: 0, scope: !16) -!23 = !DILocalVariable(name: "BranchCondition", scope: !16, file: !8, line: 8, type: !21) -!24 = !DILocation(line: 9, column: 25, scope: !16) -!25 = !DILocalVariable(name: "secretToken", scope: !16, file: !8, line: 9, type: !11) -!26 = !DILocalVariable(name: "publicToken", scope: !16, file: !8, line: 10, type: !11) -!27 = !DILocation(line: 11, column: 5, scope: !16) -!28 = !DILocation(line: 11, column: 11, scope: !16) -!29 = !DILocation(line: 12, column: 12, scope: !30) -!30 = distinct !DILexicalBlock(scope: !31, file: !8, line: 12, column: 12) -!31 = distinct !DILexicalBlock(scope: !16, file: !8, line: 11, column: 25) -!32 = !DILocation(line: 12, column: 12, scope: !31) -!33 = !DILocation(line: 13, column: 22, scope: !34) -!34 = distinct !DILexicalBlock(scope: !30, file: !8, line: 12, column: 28) -!35 = !DILocalVariable(name: "b", scope: !34, file: !8, line: 13, type: !11) -!36 = !DILocation(line: 0, scope: !34) -!37 = !DILocation(line: 14, column: 9, scope: !34) -!38 = !DILocation(line: 16, column: 23, scope: !39) -!39 = distinct !DILexicalBlock(scope: !30, file: !8, line: 15, column: 13) -!40 = !DILocalVariable(name: "a", scope: !39, file: !8, line: 16, type: !11) -!41 = !DILocation(line: 0, scope: !39) -!42 = !DILocation(line: 17, column: 13, scope: !39) -!43 = !DILocation(line: 18, column: 13, scope: !39) -!44 = distinct !{!44, !27, !45} -!45 = !DILocation(line: 20, column: 5, scope: !16) -!46 = !DILocation(line: 21, column: 1, scope: !16) +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} +!6 = distinct !{!6, !7} +!7 = !{!"llvm.loop.mustprogress"} diff --git a/Assignment-4/testcase/bc/test4.ll b/Assignment-4/testcase/bc/test4.ll index b38ff64..8337993 100644 --- a/Assignment-4/testcase/bc/test4.ll +++ b/Assignment-4/testcase/bc/test4.ll @@ -1,5 +1,5 @@ ; ModuleID = 'test4.ll' -source_filename = "Assignment-4/testcase/src/test4.c" +source_filename = "test4.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" @@ -7,101 +7,55 @@ target triple = "x86_64-unknown-linux-gnu" @.str.1 = private unnamed_addr constant [6 x i8] c"hello\00", align 1 ; Function Attrs: noinline nounwind uwtable -define dso_local i8* @getchar() #0 !dbg !7 { +define dso_local ptr @getchar() #0 { entry: - ret i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), !dbg !12 + ret ptr @.str } ; Function Attrs: noinline nounwind uwtable -define dso_local i32 @main() #0 !dbg !13 { +define dso_local i32 @main() #0 { entry: - call void @llvm.dbg.value(metadata i8 1, metadata !17, metadata !DIExpression()), !dbg !19 - call void @llvm.dbg.value(metadata i8 1, metadata !20, metadata !DIExpression()), !dbg !19 - %call = call i8* @getchar(), !dbg !21 - call void @llvm.dbg.value(metadata i8* %call, metadata !22, metadata !DIExpression()), !dbg !19 - br label %while.cond, !dbg !23 + %call = call ptr @getchar() + br label %while.cond while.cond: ; preds = %if.end, %entry - %tobool = trunc i8 1 to i1, !dbg !24 - br i1 %tobool, label %while.body, label %while.end, !dbg !23 + %tobool = trunc i8 1 to i1 + br i1 %tobool, label %while.body, label %while.end while.body: ; preds = %while.cond - %tobool1 = trunc i8 1 to i1, !dbg !25 - br i1 %tobool1, label %if.then, label %if.else, !dbg !28 + %tobool1 = trunc i8 1 to i1 + br i1 %tobool1, label %if.then, label %if.else if.then: ; preds = %while.body - call void @llvm.dbg.value(metadata i8* %call, metadata !29, metadata !DIExpression()), !dbg !31 - call void (i8*, ...) bitcast (void (...)* @broadcast to void (i8*, ...)*)(i8* %call), !dbg !32 - call void @MAYALIAS(i8* %call, i8* %call), !dbg !33 - br label %if.end, !dbg !34 + call void (ptr, ...) @broadcast(ptr noundef %call) + call void @MAYALIAS(ptr noundef %call, ptr noundef %call) + br label %if.end if.else: ; preds = %while.body - call void @llvm.dbg.value(metadata i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), metadata !35, metadata !DIExpression()), !dbg !37 br label %if.end if.end: ; preds = %if.else, %if.then - br label %while.cond, !dbg !23, !llvm.loop !38 + br label %while.cond, !llvm.loop !6 while.end: ; preds = %while.cond - ret i32 0, !dbg !40 + ret i32 0 } -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.declare(metadata, metadata, metadata) #1 - -declare dso_local void @broadcast(...) #2 - -declare dso_local void @MAYALIAS(i8*, i8*) #2 +declare void @broadcast(...) #1 -; Function Attrs: nounwind readnone speculatable willreturn -declare void @llvm.dbg.value(metadata, metadata, metadata) #1 +declare void @MAYALIAS(ptr noundef, ptr noundef) #1 -attributes #0 = { noinline nounwind uwtable "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "min-legal-vector-width"="0" "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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } -attributes #1 = { nounwind readnone speculatable willreturn } -attributes #2 = { "correctly-rounded-divide-sqrt-fp-math"="false" "disable-tail-calls"="false" "frame-pointer"="all" "less-precise-fpmad"="false" "no-infs-fp-math"="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"="+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "unsafe-fp-math"="false" "use-soft-float"="false" } +attributes #0 = { noinline nounwind 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 = { "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" } -!llvm.dbg.cu = !{!0} -!llvm.module.flags = !{!3, !4, !5} -!llvm.ident = !{!6} +!llvm.module.flags = !{!0, !1, !2, !3, !4} +!llvm.ident = !{!5} -!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 10.0.0 ", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, splitDebugInlining: false, nameTableKind: None) -!1 = !DIFile(filename: "Assignment-4/testcase/src/test4.c", directory: "/home/SVF-tools/SVF-Teaching") -!2 = !{} -!3 = !{i32 7, !"Dwarf Version", i32 4} -!4 = !{i32 2, !"Debug Info Version", i32 3} -!5 = !{i32 1, !"wchar_size", i32 4} -!6 = !{!"clang version 10.0.0 "} -!7 = distinct !DISubprogram(name: "getchar", scope: !1, file: !1, line: 4, type: !8, scopeLine: 4, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!8 = !DISubroutineType(types: !9) -!9 = !{!10} -!10 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !11, size: 64) -!11 = !DIBasicType(name: "char", size: 8, encoding: DW_ATE_signed_char) -!12 = !DILocation(line: 4, column: 21, scope: !7) -!13 = distinct !DISubprogram(name: "main", scope: !1, file: !1, line: 6, type: !14, scopeLine: 6, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !2) -!14 = !DISubroutineType(types: !15) -!15 = !{!16} -!16 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) -!17 = !DILocalVariable(name: "loopCondition", scope: !13, file: !1, line: 7, type: !18) -!18 = !DIBasicType(name: "_Bool", size: 8, encoding: DW_ATE_boolean) -!19 = !DILocation(line: 0, scope: !13) -!20 = !DILocalVariable(name: "BranchCondition", scope: !13, file: !1, line: 8, type: !18) -!21 = !DILocation(line: 9, column: 25, scope: !13) -!22 = !DILocalVariable(name: "secretToken", scope: !13, file: !1, line: 9, type: !10) -!23 = !DILocation(line: 10, column: 5, scope: !13) -!24 = !DILocation(line: 10, column: 11, scope: !13) -!25 = !DILocation(line: 11, column: 12, scope: !26) -!26 = distinct !DILexicalBlock(scope: !27, file: !1, line: 11, column: 12) -!27 = distinct !DILexicalBlock(scope: !13, file: !1, line: 10, column: 25) -!28 = !DILocation(line: 11, column: 12, scope: !27) -!29 = !DILocalVariable(name: "a", scope: !30, file: !1, line: 12, type: !10) -!30 = distinct !DILexicalBlock(scope: !26, file: !1, line: 11, column: 28) -!31 = !DILocation(line: 0, scope: !30) -!32 = !DILocation(line: 13, column: 13, scope: !30) -!33 = !DILocation(line: 14, column: 13, scope: !30) -!34 = !DILocation(line: 15, column: 9, scope: !30) -!35 = !DILocalVariable(name: "b", scope: !36, file: !1, line: 17, type: !10) -!36 = distinct !DILexicalBlock(scope: !26, file: !1, line: 16, column: 13) -!37 = !DILocation(line: 0, scope: !36) -!38 = distinct !{!38, !23, !39} -!39 = !DILocation(line: 19, column: 5, scope: !13) -!40 = !DILocation(line: 20, column: 1, scope: !13) +!0 = !{i32 1, !"wchar_size", i32 4} +!1 = !{i32 8, !"PIC Level", i32 2} +!2 = !{i32 7, !"PIE Level", i32 2} +!3 = !{i32 7, !"uwtable", i32 2} +!4 = !{i32 7, !"frame-pointer", i32 2} +!5 = !{!"clang version 16.0.0"} +!6 = distinct !{!6, !7} +!7 = !{!"llvm.loop.mustprogress"} diff --git a/CMakeLists.txt b/CMakeLists.txt index 216bd4d..5f78ba2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,15 +1,23 @@ -cmake_minimum_required(VERSION 3.4.3) +cmake_minimum_required(VERSION 3.23) + +project(Teaching-Software-Analysis + VERSION 1.0 + DESCRIPTION "Teaching-Software-Analysis is an open course for learning software analysis" + HOMEPAGE_URL "https://github.com/SVF-tools/Teaching-Software-Analysis" + LANGUAGES C CXX +) + if (DEFINED LLVM_DIR) set(ENV{LLVM_DIR} "${LLVM_DIR}") endif() if (DEFINED ENV{LLVM_DIR}) # We need to match the build environment for LLVM: # In particular, we need C++11 and the -fno-rtti flag - set(CMAKE_CXX_STANDARD 14) + set(CMAKE_CXX_STANDARD 17) if(CMAKE_BUILD_TYPE MATCHES "Debug") - set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++14 -O0 -fno-rtti -Wno-deprecated") + set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++17 -O0 -fno-rtti -Wno-deprecated") else() - set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++14 -O3 -fno-rtti -Wno-deprecated") + set(CMAKE_CXX_FLAGS "-fPIC -std=gnu++17 -O3 -fno-rtti -Wno-deprecated") endif() set(CMAKE_C_FLAGS "-fPIC") diff --git a/CodeGraph/compile.sh b/CodeGraph/compile.sh old mode 100644 new mode 100755 index bd1ad57..da283ec --- a/CodeGraph/compile.sh +++ b/CodeGraph/compile.sh @@ -2,7 +2,7 @@ if [ -n $1 ]; then file=$(basename $1 .c) clang -S -c -Xclang -disable-O0-optnone -fno-discard-value-names -emit-llvm $1 -o $file.ll - opt -S -mem2reg $file.ll -o $file.ll + opt -S -p=mem2reg $file.ll -o $file.ll else echo "please give the .c file" fi diff --git a/Dockerfile b/Dockerfile index 2058549..dc0daf8 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ ENV DEBIAN_FRONTEND noninteractive RUN set -e # Define LLVM version. -ENV llvm_version=14.0.0 +ENV llvm_version=16.0.0 # Define home directory ENV HOME=/home/SVF-tools diff --git a/env.sh b/env.sh index 5036926..2b0fae2 100755 --- a/env.sh +++ b/env.sh @@ -2,23 +2,32 @@ PROJECTHOME=$(pwd) sysOS=`uname -s` -LLVMHome="llvm-14.0.0.obj" +MajorLLVMVer=16 +LLVMVer=${MajorLLVMVer}.0.0 + +LLVMHome="${LLVMVer}.obj" Z3Home="z3.obj" install_path=`npm root` -export LLVM_DIR=$install_path/$LLVMHome -export Z3_DIR=$install_path/$Z3Home + +if [[ $sysOS == "Darwin" ]] +then + LLVM_DIR="$(brew --prefix llvm@${MajorLLVMVer})" +elif [[ $sysOS == "Linux" ]] +then + LLVM_DIR=$install_path/$LLVMHome +fi + +Z3_DIR=$install_path/$Z3Home + +export LLVM_DIR=$LLVM_DIR +export Z3_DIR=$Z3_DIR export PATH=$LLVM_DIR/bin:$PATH export PATH=$PROJECTHOME/bin:$PATH -echo "export LLVM_DIR=$install_path/$LLVMHome" >> ~/.bashrc -echo "export Z3_DIR=$install_path/$Z3Home" >> ~/.bashrc + +echo "export LLVM_DIR=$LLVM_DIR" >> ~/.bashrc +echo "export Z3_DIR=$Z3_DIR" >> ~/.bashrc echo "export PATH=$LLVM_DIR/bin:$PROJECTHOME/bin:$PATH" >> ~/.bashrc -if [[ $sysOS == "Darwin" ]] -then - export SVF_DIR=$install_path/SVF/ -elif [[ $sysOS == "Linux" ]] -then - export SVF_DIR=$install_path/SVF/ -fi +export SVF_DIR=$install_path/SVF/ echo "LLVM_DIR="$LLVM_DIR echo "SVF_DIR="$SVF_DIR