|
4 | 4 | target triple = "x86_64-unknown-linux-gnu"
|
5 | 5 |
|
6 | 6 | declare ptr @__memset_chk(ptr writeonly, i32, i64, i64) argmemonly
|
| 7 | +declare ptr @__memcpy_chk(ptr writeonly, ptr readonly, i64, i64) argmemonly nounwind |
| 8 | + |
7 | 9 | declare ptr @strncpy(ptr %dest, ptr %src, i64 %n) nounwind
|
8 | 10 | declare void @use(ptr)
|
9 | 11 |
|
@@ -106,3 +108,27 @@ define void @dse_strncpy_chk_test3(ptr noalias %out1, ptr noalias %out2, ptr noa
|
106 | 108 | %call.2 = tail call ptr @__memset_chk(ptr %out2, i32 42, i64 100, i64 %n)
|
107 | 109 | ret void
|
108 | 110 | }
|
| 111 | + |
| 112 | +define void @dse_strncpy_memcpy_chk_test1(ptr noalias %out, ptr noalias %in, i64 %n) { |
| 113 | +; CHECK-LABEL: @dse_strncpy_memcpy_chk_test1( |
| 114 | +; CHECK-NEXT: store i32 0, ptr [[OUT:%.*]], align 4 |
| 115 | +; CHECK-NEXT: [[CALL_1:%.*]] = tail call ptr @__memcpy_chk(ptr [[OUT]], ptr [[IN:%.*]], i64 100, i64 [[N:%.*]]) |
| 116 | +; CHECK-NEXT: ret void |
| 117 | +; |
| 118 | + store i32 0, ptr %out |
| 119 | + %call.1 = tail call ptr @__memcpy_chk(ptr %out, ptr %in, i64 100, i64 %n) |
| 120 | + ret void |
| 121 | +} |
| 122 | + |
| 123 | +define void @dse_strncpy_memcpy_chk_test2(ptr noalias %out, ptr noalias %in, i64 %n) { |
| 124 | +; CHECK-LABEL: @dse_strncpy_memcpy_chk_test2( |
| 125 | +; CHECK-NEXT: [[GEP:%.*]] = getelementptr inbounds i8, ptr [[OUT:%.*]], i64 100 |
| 126 | +; CHECK-NEXT: store i8 10, ptr [[GEP]], align 1 |
| 127 | +; CHECK-NEXT: [[CALL_1:%.*]] = tail call ptr @__memcpy_chk(ptr [[OUT]], ptr [[IN:%.*]], i64 100, i64 [[N:%.*]]) |
| 128 | +; CHECK-NEXT: ret void |
| 129 | +; |
| 130 | + %gep = getelementptr inbounds i8, ptr %out, i64 100 |
| 131 | + store i8 10, ptr %gep |
| 132 | + %call.1 = tail call ptr @__memcpy_chk(ptr %out, ptr %in, i64 100, i64 %n) |
| 133 | + ret void |
| 134 | +} |
0 commit comments