[all-commits] [llvm/llvm-project] c3b06d: [InstCombine] keep assumption before sinking calls
Ralender via All-commits
all-commits at lists.llvm.org
Wed Oct 30 16:16:41 PDT 2019
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: c3b06d0c393e533eab712922911d14e5a079fa5d
https://github.com/llvm/llvm-project/commit/c3b06d0c393e533eab712922911d14e5a079fa5d
Author: tyker <tyker1 at outlook.com>
Date: 2019-10-31 (Thu, 31 Oct 2019)
Changed paths:
M llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
A llvm/test/Transforms/InstCombine/assume-replacing-call.ll
Log Message:
-----------
[InstCombine] keep assumption before sinking calls
Summary:
in the following C code the branch is not removed by clang in O3.
```
int f1(char* p) {
int i1 = __builtin_strlen(p);
if (!p)
return -1;
return i1;
}
```
The issue is that the call to strlen is sunk to the following block by instcombine. In its new place the call to strlen doesn't dominate the use in the icmp anymore so value tracking can't see that p cannot be null.
This patch resolves the issue by inserting an assumption at the place of the call before sinking a call when that call can be used to prove an argument to be nonnull.
This resolves this issue at O3.
Reviewers: majnemer, xbolva00, fhahn, jdoerfert, spatel, efriedma
Reviewed By: jdoerfert
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D69477
More information about the All-commits
mailing list