diff options
author | Nuno Lopes <nunoplopes@sapo.pt> | 2020-01-11 11:57:29 +0000 |
---|---|---|
committer | Nuno Lopes <nunoplopes@sapo.pt> | 2020-01-11 11:57:29 +0000 |
commit | 87407fc03c82d880cc42330a8e230e7a48174e3c (patch) | |
tree | d81b5b186c5f5a686068727bf48976b9a341f16e /llvm/lib | |
parent | 142ba7d76af4a66037fd180db371da19f35ef5f3 (diff) | |
download | bcm5719-llvm-87407fc03c82d880cc42330a8e230e7a48174e3c.tar.gz bcm5719-llvm-87407fc03c82d880cc42330a8e230e7a48174e3c.zip |
DSE: fix bug where we would only check libcalls for name rather than whole decl
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp index dd87b57cbe7..1ba4aab999e 100644 --- a/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp +++ b/llvm/lib/Transforms/Scalar/DeadStoreElimination.cpp @@ -179,15 +179,18 @@ static bool hasAnalyzableMemoryWrite(Instruction *I, } if (auto CS = CallSite(I)) { if (Function *F = CS.getCalledFunction()) { - StringRef FnName = F->getName(); - if (TLI.has(LibFunc_strcpy) && FnName == TLI.getName(LibFunc_strcpy)) - return true; - if (TLI.has(LibFunc_strncpy) && FnName == TLI.getName(LibFunc_strncpy)) - return true; - if (TLI.has(LibFunc_strcat) && FnName == TLI.getName(LibFunc_strcat)) - return true; - if (TLI.has(LibFunc_strncat) && FnName == TLI.getName(LibFunc_strncat)) - return true; + LibFunc LF; + if (TLI.getLibFunc(*F, LF) && TLI.has(LF)) { + switch (LF) { + case LibFunc_strcpy: + case LibFunc_strncpy: + case LibFunc_strcat: + case LibFunc_strncat: + return true; + default: + return false; + } + } } } return false; |