Commit f39e12a
committed
PR34581: Don't remove an 'if (p)' guarding a call to 'operator delete(p)' under -Oz.
Summary:
This transformation is correct for a builtin call to 'free(p)', but not
for 'operator delete(p)'. There is no guarantee that a user replacement
'operator delete' has no effect when called on a null pointer.
However, the principle behind the transformation *is* correct, and can
be applied more broadly: a 'delete p' expression is permitted to
unconditionally call 'operator delete(p)'. So do that in Clang under
-Oz where possible. We do this whether or not 'p' has trivial
destruction, since the destruction might turn out to be trivial after
inlining, and even for a class-specific (but non-virtual,
non-destroying, non-array) 'operator delete'.
Reviewers: davide, dnsampaio, rjmccall
Reviewed By: dnsampaio
Subscribers: hiraditya, cfe-commits, llvm-commits
Tags: #clang, #llvm
Differential Revision: https://reviews.llvm.org/D793781 parent 61cd264 commit f39e12a
File tree
4 files changed
+78
-12
lines changed- clang
- lib/CodeGen
- test/CodeGenCXX
- llvm
- lib/Transforms/InstCombine
- test/Transforms/InstCombine
4 files changed
+78
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1874 | 1874 | | |
1875 | 1875 | | |
1876 | 1876 | | |
1877 | | - | |
| 1877 | + | |
| 1878 | + | |
| 1879 | + | |
1878 | 1880 | | |
1879 | 1881 | | |
1880 | | - | |
| 1882 | + | |
| 1883 | + | |
1881 | 1884 | | |
1882 | 1885 | | |
1883 | 1886 | | |
| |||
1924 | 1927 | | |
1925 | 1928 | | |
1926 | 1929 | | |
1927 | | - | |
| 1930 | + | |
1928 | 1931 | | |
1929 | 1932 | | |
1930 | 1933 | | |
| |||
1959 | 1962 | | |
1960 | 1963 | | |
1961 | 1964 | | |
| 1965 | + | |
| 1966 | + | |
| 1967 | + | |
| 1968 | + | |
| 1969 | + | |
| 1970 | + | |
| 1971 | + | |
1962 | 1972 | | |
| 1973 | + | |
1963 | 1974 | | |
1964 | 1975 | | |
1965 | 1976 | | |
| |||
2036 | 2047 | | |
2037 | 2048 | | |
2038 | 2049 | | |
| 2050 | + | |
| 2051 | + | |
| 2052 | + | |
| 2053 | + | |
| 2054 | + | |
| 2055 | + | |
2039 | 2056 | | |
2040 | 2057 | | |
2041 | 2058 | | |
| |||
2081 | 2098 | | |
2082 | 2099 | | |
2083 | 2100 | | |
| 2101 | + | |
2084 | 2102 | | |
2085 | | - | |
| 2103 | + | |
| 2104 | + | |
2086 | 2105 | | |
2087 | | - | |
2088 | | - | |
2089 | 2106 | | |
2090 | 2107 | | |
2091 | 2108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
9 | 10 | | |
10 | 11 | | |
11 | 12 | | |
| 13 | + | |
| 14 | + | |
12 | 15 | | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
13 | 26 | | |
14 | 27 | | |
15 | 28 | | |
| |||
22 | 35 | | |
23 | 36 | | |
24 | 37 | | |
25 | | - | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
26 | 41 | | |
27 | 42 | | |
28 | 43 | | |
| |||
49 | 64 | | |
50 | 65 | | |
51 | 66 | | |
52 | | - | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
53 | 70 | | |
54 | 71 | | |
55 | 72 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2670 | 2670 | | |
2671 | 2671 | | |
2672 | 2672 | | |
2673 | | - | |
2674 | | - | |
2675 | | - | |
| 2673 | + | |
| 2674 | + | |
| 2675 | + | |
| 2676 | + | |
| 2677 | + | |
| 2678 | + | |
| 2679 | + | |
| 2680 | + | |
| 2681 | + | |
| 2682 | + | |
2676 | 2683 | | |
2677 | 2684 | | |
2678 | 2685 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
143 | 168 | | |
144 | 169 | | |
145 | 170 | | |
| |||
0 commit comments