Skip to content

Commit 9adebd4

Browse files
committed
ReleaseNotes: omitting range checks for switches with unreachable defaults
llvm-svn: 370342
1 parent f8ed27f commit 9adebd4

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

llvm/docs/ReleaseNotes.rst

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,36 @@ Noteworthy optimizations
8585
`bug 42763 <https://bugs.llvm.org/show_bug.cgi?id=42763>_` and
8686
`post commit discussion <http://lists.llvm.org/pipermail/llvm-commits/Week-of-Mon-20190422/646945.html>_`.
8787

88+
* LLVM will now omit range checks for jump tables when lowering switches with
89+
unreachable default destination. For example, the switch dispatch in the C++
90+
code below
91+
92+
.. code-block:: c
93+
94+
int g(int);
95+
enum e { A, B, C, D, E };
96+
int f(e x, int y, int z) {
97+
switch(x) {
98+
case A: return g(y);
99+
case B: return g(z);
100+
case C: return g(y+z);
101+
case D: return g(x-z);
102+
case E: return g(x+z);
103+
}
104+
}
105+
106+
will result in the following x86_64 machine code when compiled with Clang.
107+
This is because falling off the end of a non-void function is undefined
108+
behaviour in C++, and the end of the function therefore being treated as
109+
unreachable:
110+
111+
.. code-block:: asm
112+
113+
_Z1f1eii:
114+
mov eax, edi
115+
jmp qword ptr [8*rax + .LJTI0_0]
116+
117+
88118
89119
Changes to the LLVM IR
90120
----------------------

0 commit comments

Comments
 (0)