[llvm-bugs] [Bug 39957] New: lli crashes during optimization when a node references itself

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 11 06:12:12 PST 2018


            Bug ID: 39957
           Summary: lli crashes during optimization when a node references
           Product: tools
           Version: 7.0
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: lli
          Assignee: unassignedbugs at nondot.org
          Reporter: jynelson at email.sc.edu
                CC: llvm-bugs at lists.llvm.org

lli (and only lli) crashes while optimizing a module where a node references
itself. llc properly notes that the module is invalid. clang generates machine
code without a warning. Strangely enough, if there's no optimization to be
done, lli does not crash, instead giving the proper warning.

▶️ cat bug.ll
declare i32 @puts(i8*)
@.true = constant [5 x i8] c"true\00"
@.false = constant [6 x i8] c"false\00"

define i32 @main() {
  %tmp15 = getelementptr [5 x i8], [5 x i8]* @.true, i32 0, i64 0
  %tmp16 = getelementptr [6 x i8], [6 x i8]* @.false, i32 0, i64 0
  %tmp17 = icmp ne i1 %tmp17, 0
  %tmp14 = select i1 %tmp17, i8* %tmp15, i8* %tmp16
  %unused_register12 = call i32 @puts (i8* %tmp14)
  ret i32 0

▶️ llc bug.ll
Only PHI nodes may reference their own value!
  %tmp17 = icmp ne i1 %tmp17, false
llc: bug.ll: error: input module is broken!

▶️ ./lli bug.ll
Stack dump:
0.      Program arguments: ./lli /home/joshua/Documents/Programming/lox/bug.ll 
1.      Running pass 'Function Pass Manager' on module
2.      Running pass 'Machine Common Subexpression Elimination' on function
#0 0x0000000000cf7934 PrintStackTraceSignalHandler(void*) (./lli+0xcf7934)
#1 0x0000000000cf595e llvm::sys::RunSignalHandlers() (./lli+0xcf595e)
#2 0x0000000000cf7af2 SignalHandler(int) (./lli+0xcf7af2)
#3 0x00007f527462e890 __restore_rt
#4 0x0000000000715a96 (anonymous
#5 0x00000000007307c9 llvm::MachineFunctionPass::runOnFunction(llvm::Function&)
#6 0x00000000009279d1 llvm::FPPassManager::runOnFunction(llvm::Function&)
#7 0x0000000000927c03 llvm::FPPassManager::runOnModule(llvm::Module&)
#8 0x000000000092814e llvm::legacy::PassManagerImpl::run(llvm::Module&)
#9 0x00000000009ffa48 llvm::MCJIT::emitObject(llvm::Module*) (./lli+0x9ffa48)
#10 0x00000000009ffca4 llvm::MCJIT::generateCodeForModule(llvm::Module*)
#11 0x0000000000a0065e llvm::MCJIT::finalizeObject() (./lli+0xa0065e)
#12 0x00000000005c7235 main (./lli+0x5c7235)
#13 0x00007f5273501b97 __libc_start_main
#14 0x00000000005c4549 _start (./lli+0x5c4549)
Segmentation fault (core dumped)

▶️ ./lli --version
LLVM (http://llvm.org/):
  LLVM version 7.0.0
  Optimized build.
  Default target: x86_64-unknown-linux-gnu
  Host CPU: skylake

▶️ cat bug2.ll
define i32 @main () {
  %tmp17 = icmp eq i32 %tmp17, 1
  ret i32 %tmp17

▶️ lli bug2.ll
lli: bug2.ll:2:3: error: instruction forward referenced with type 'i32'
  %tmp17 = icmp eq i32 %tmp17, 1

You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20181211/a7442d48/attachment.html>

More information about the llvm-bugs mailing list