Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

[X86] X86FlagsCopyLowering - Unlowered EFLAGS copy! #42159

Open Quuxplusone opened 5 years ago

Quuxplusone commented 5 years ago
Bugzilla Link PR43189
Status NEW
Importance P enhancement
Reported by Simon Pilgrim (llvm-dev@redking.me.uk)
Reported on 2019-09-01 06:56:19 -0700
Last modified on 2019-09-01 09:55:49 -0700
Version trunk
Hardware PC Windows NT
CC chandlerc@gmail.com, craig.topper@gmail.com, llvm-bugs@lists.llvm.org, llvm-dev@redking.me.uk, spatel+llvm@rotateright.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
Reduced from https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=16605

define void @ossfuzz16605() {
entry:
  %C33 = fcmp true float 0x36A0000000000000, 0x36A0000000000000
  %B43 = or i1 %C33, true
  br i1 %B43, label %bb2, label %bb8

bb8:                                              ; preds = %bb8, %bb7
  %C19 = icmp sgt i128 undef, 18446744073709551616
  %G21 = getelementptr i128, i128* null, i1 %C19
  store i128* %G21, i128** undef
  br i1 %C19, label %bb8, label %bb2

bb2:                                              ; preds = %bb8
  unreachable
}

llc -mtriple=x86_64--

Unlowered EFLAGS copy!
UNREACHABLE executed at C:\LLVM\llvm-
project\llvm\lib\Target\X86\X86FlagsCopyLowering.cpp:707!
Stack dump:
0.      Program arguments: C:\LLVM\build\Debug\bin\llc.exe -mtriple=x86_64-- -
mcpu=btver2 -o bar.s fuzz.ll
1.      Running pass 'Function Pass Manager' on module 'fuzz.ll'.
2.      Running pass 'X86 EFLAGS copy lowering' on function '@ossfuzz16605'
Quuxplusone commented 5 years ago

Looks like the EFLAGS copying pass only visits reachable code. And bb8 is unreachable due to the or in entry. We could fix the assert to only fire for code reachable from entry, but I suspect the register copying code in X86InstrInfo.cpp would still assert.

Chandler, what should we do here?