Quuxplusone / LLVMBugzillaTest

0 stars 0 forks source link

Module Verify is accepting bad LLVM IR #8680

Open Quuxplusone opened 14 years ago

Quuxplusone commented 14 years ago
Bugzilla Link PR8308
Status NEW
Importance P normal
Reported by Brian West (bnwest@rice.edu)
Reported on 2010-10-05 17:48:15 -0700
Last modified on 2010-10-06 09:29:10 -0700
Version trunk
Hardware PC All
CC baldrick@free.fr, llvm-bugs@lists.llvm.org, nicholas@mxc.ca, nlewycky@google.com
Fixed by commit(s)
Attachments
Blocks
Blocked by
See also
As seen at revision 115615, the following IR is bad yet verify accepts:

define float @bug_loop_v2(float* %a, i32 %start, i32 %stop, i32 %incr) nounwind
ssp {
entry:
  %"alloca point" = bitcast i32 0 to i32
  %0 = sub nsw i32 %start, 1
  %1 = sext i32 %0 to i64
  %2 = getelementptr float* %a, i64 %1
  br label %bb1

bb:                                               ; preds = %bb1
  %3 = load float* %8, align 1
  %4 = fadd float %3, %sum.0
  %5 = getelementptr float* %8, %8
  %6 = add i64 %9, %9
  %7 = add nsw i32 %i.0, %i.0
  br label %bb1

bb1:                                              ; preds = %bb, %entry
  %8 = phi float* [ %2, %entry ], [ %5, %bb ]
  %9 = phi i64 [ %1, %entry ], [ %6, %bb ]
  %i.0 = phi i32 [ %0, %entry ], [ %7, %bb ]
  %sum.0 = phi float [ 0.000000e+00, %entry ], [ %4, %bb ]
  %10 = icmp slt i32 %i.0, %stop
  br i1 %10, label %bb, label %bb2

bb2:                                              ; preds = %bb1
  br label %return

return:                                           ; preds = %bb2
  ret float %sum.0
}

---

%5 = getelementptr float* %8, %8

is the bad IR.
Quuxplusone commented 14 years ago
I'm having trouble reproducing this, because the .ll file doesn't parse:

  nlewycky@ducttape:~$ llvm/Debug+Asserts/bin/llvm-as < pr8308.ll
  llvm/Debug+Asserts/bin/llvm-as: <stdin>:13:33: error: getelementptr index must be an integer
    %5 = getelementptr float* %8, %8
                                  ^

The .ll printer is designed to handle invalid IR so that we can look at our
code as things are going wrong, but that doesn't mean the text it generates can
be parsed again. Do you know how I can produce the IR in memory which prints
like this but passes the verifier?
Quuxplusone commented 14 years ago

I am working a new optimization pass (-osr). I do not get a LLVM IR for either of the below:

% opt test.ssa.ll -S -o test.osr.ll -stats -osr -time-passes

or

% opt test.ssa.ll -S -o test.osr.ll -stats -osr -verify -time-passes

-time-passes shows the module verifier is run in both cases; thus, my confusion.

I do see the parse error if I run another opt pass or llc.

Brian