https://bugs.llvm.org/show_bug.cgi?id=33673
Bug ID: 33673
Summary: register promotion miscompilation: hoisting division
by zero
Product: new-bugs
Version: trunk
Hardware: PC
OS: Linux
Status: NEW
Severity: enhancement
Priority: P
Component: new bugs
Assignee: [email protected]
Reporter: [email protected]
CC: [email protected]
```
$ opt --version
LLVM (http://llvm.org/):
LLVM version 5.0.0svn
DEBUG build with assertions.
Default target: x86_64-unknown-linux-gnu
Host CPU: ivybridge
$ cat yy.ll
@G = external global i32, align 4
define void @bar() {
%p = alloca i32, align 4
%a = load i32, i32* %p, align 4
call void @foo(i32 %a)
store i32 sdiv (i32 1, i32 sub (i32 ptrtoint (i32* @G to i32), i32 ptrtoint
(i32* @G to i32))), i32* %p, align 4
ret void
}
declare void @foo(i32)
$ opt yy.ll -mem2reg -S
; ModuleID = 'yy.ll'
source_filename = "yy.ll"
@G = external global i32, align 4
define void @bar() {
call void @foo(i32 sdiv (i32 1, i32 sub (i32 ptrtoint (i32* @G to i32), i32
ptrtoint (i32* @G to i32))))
ret void
}
declare void @foo(i32)
```
This is a miscompilation, because the sdiv constant expression, which is a
division by zero, is hoisted across a function call to foo(). It may introduce
undefined behavior when foo() does not terminate.
This bug is due to rewriteSingleStoreAlloca(...) in
PromoteMemoryToRegister.cpp. It should check that the stored value is not
division by zero, when it is a constant expression.
--
You are receiving this mail because:
You are on the CC list for the bug._______________________________________________
llvm-bugs mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-bugs