[llvm-dev] CHECK-LABLE or CHECK?

陳韋任 via llvm-dev llvm-dev at lists.llvm.org
Sat Apr 1 07:29:08 PDT 2017


Hi Tim,

  You're right, "CHECK-LABEL: define void @test1" solves the problem.

  Turns out the *.ll looks kinda of like:

    @test1 = whatsoever ...
    @test2 = whatsoever ...

    define void @test1() {
      ... code ...

      call void @llvm.memcpy.p0i8.p0i8.i32
    }

    define void @test2() {
      ... code ...

      callvoid @llvm.memcpy.p0i8.p0i8.i32
    }

"CHECK-LABEL: @test1" and "CHECK-LABEL: @test2" divide above code into
the following blocks:

    ----------------------------------------------------
   |@test1 = whatsoever ...                         |
    -----------------------------------------------------

    ----------------------------------------------------
   |@test2 = whatsoever ...                         |
   |                                                               |
   |define void @test1() {                            |
   |  ... code ...                                             |
   |                                                               |
   |  call void @llvm.memcpy.p0i8.p0i8.i32 |
   |}                                                              |
   |                                                               |
   |define void @test2() {                             |
   |  ... code ...                                             |
   |                                                               |
   |  callvoid @llvm.memcpy.p0i8.p0i8.i32  |
   |}                                                              |
    ----------------------------------------------------

Apparently, we can't match llvm.memcpy in the first block.

Adding function dummy with "CHECK-LABEL: @dummy" between function
test1 and test2 just happen to divide
the *.ll into three blocks. Fist and third block contain llvm.memcpy
correspondingly.

    ----------------------------------------------------
   |@test1 = whatsoever ...                         |
   |@test2 = whatsoever ...                         |
   |                                                               |
   |define void @test1() {                            |
   |  ... code ...                                             |
   |                                                               |
   |  call void @llvm.memcpy.p0i8.p0i8.i32 |
   |}                                                              |
    ----------------------------------------------------

    ----------------------------------------------------
   |define void @dummy() {                        |
   |  ... code ...                                            |
   |}                                                             |
    ----------------------------------------------------

    ----------------------------------------------------
                                               |
   |define void @test2() {                             |
   |  ... code ...                                             |
   |                                                               |
   |  callvoid @llvm.memcpy.p0i8.p0i8.i32  |
   |}                                                              |
    ----------------------------------------------------

The right solution is "CHECK-LABEL: define void @test1" and
"CHECK-LABEL: define void @test2",
which divide the *.ll into two blocks and match llvm.memcpy as we expect.

    ----------------------------------------------------
   |define void @test1() {                            |
   |  ... code ...                                             |
   |                                                               |
   |  call void @llvm.memcpy.p0i8.p0i8.i32 |
   |}                                                              |
    ----------------------------------------------------
    ----------------------------------------------------
   |                                                               |
   |define void @test2() {                             |
   |  ... code ...                                             |
   |                                                               |
   |  callvoid @llvm.memcpy.p0i8.p0i8.i32  |
   |}                                                              |
    ----------------------------------------------------


Thanks, Tim. Hope this thread can help others. :p

Regards,
chenwj

-- 
Wei-Ren Chen (陳韋任)
Homepage: https://people.cs.nctu.edu.tw/~chenwj


More information about the llvm-dev mailing list