[PATCH] D139096: [DSE] Use precise loc for memcpy_chk during overwrite checks.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 2 06:34:47 PST 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.
Closed by commit rG5fc071f2b452: [DSE] Use precise loc for memcpy_chk during overwrite checks. (authored by fhahn).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139096/new/

https://reviews.llvm.org/D139096

Files:
  llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
  llvm/test/Transforms/DeadStoreElimination/libcalls-chk.ll


Index: llvm/test/Transforms/DeadStoreElimination/libcalls-chk.ll
===================================================================
--- llvm/test/Transforms/DeadStoreElimination/libcalls-chk.ll
+++ llvm/test/Transforms/DeadStoreElimination/libcalls-chk.ll
@@ -107,8 +107,7 @@
 
 define void @dse_strncpy_memcpy_chk_test1(ptr noalias %out, ptr noalias %in, i64 %n) {
 ; CHECK-LABEL: @dse_strncpy_memcpy_chk_test1(
-; CHECK-NEXT:    store i32 0, ptr [[OUT:%.*]], align 4
-; CHECK-NEXT:    [[CALL_1:%.*]] = tail call ptr @__memcpy_chk(ptr [[OUT]], ptr [[IN:%.*]], i64 100, i64 [[N:%.*]])
+; CHECK-NEXT:    [[CALL_1:%.*]] = tail call ptr @__memcpy_chk(ptr [[OUT:%.*]], ptr [[IN:%.*]], i64 100, i64 [[N:%.*]])
 ; CHECK-NEXT:    ret void
 ;
   store i32 0, ptr %out
Index: llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
+++ llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp
@@ -883,7 +883,8 @@
                                       LocationSize Size) const {
     if (auto *CB = dyn_cast<CallBase>(I)) {
       LibFunc F;
-      if (TLI.getLibFunc(*CB, F) && TLI.has(F) && F == LibFunc_memset_chk) {
+      if (TLI.getLibFunc(*CB, F) && TLI.has(F) &&
+          (F == LibFunc_memset_chk || F == LibFunc_memcpy_chk)) {
         // Use the precise location size specified by the 3rd argument
         // for determining KillingI overwrites DeadLoc if it is a memset_chk
         // instruction. memset_chk will write either the amount specified as 3rd


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139096.479617.patch
Type: text/x-patch
Size: 1577 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221202/c122453b/attachment.bin>


More information about the llvm-commits mailing list