[llvm-bugs] [Bug 39961] New: Only one label allowed per block without branch - not documented

via llvm-bugs llvm-bugs at lists.llvm.org
Tue Dec 11 08:02:28 PST 2018


https://bugs.llvm.org/show_bug.cgi?id=39961

            Bug ID: 39961
           Summary: Only one label allowed per block without branch - not
                    documented
           Product: Documentation
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: enhancement
          Priority: P
         Component: General docs
          Assignee: unassignedbugs at nondot.org
          Reporter: jynelson at email.sc.edu
                CC: llvm-bugs at lists.llvm.org

Labels are only allowed at the start of any given block. Labels within a block
will throw the error 'error: expected instruction opcode'.

This is not documented anywhere and I had a really hard time figuring this out
on my own. There is some mention of basic blocks in doxygen:
http://llvm.org/doxygen/group__LLVMCCoreValueBasicBlock.html but it does not
mention that ONLY basic blocks can be used as labels.

For example, the following code is legal:

define i32 @main() {
return:
  ret i32 0                                                                     
}       

but this code is illegal:

define i32 @main() {
  %1 = add i32 0, 1
return:
  ret i32 %1
}

and this code is legal again:

@.true_str = private unnamed_addr constant  [5 x i8] c"true\00"
@.false_str = private unnamed_addr constant  [6 x i8] c"false\00"
declare i32 @puts(i8* nocapture) nounwind

define i32 @main() {
entry:
  %tmp2 = load i1, i1* @.true
  br i1 %tmp2, label %logicendlabel2, label %logicrightlabel1

logicrightlabel1:
  %tmp3 = load i1, i1* @.false
  br label %logicendlabel2

logicendlabel2:
  %tmp1 = phi i1 [ %tmp2, %entry ], [ %tmp3, %logicrightlabel1 ]
  %tmp5 = getelementptr [5 x i8], [5 x i8]* @.true_str, i32 0, i64 0
  %tmp6 = getelementptr [6 x i8], [6 x i8]* @.false_str, i32 0, i64 0
  %tmp7 = icmp eq i1 %tmp1, 1
  %tmp4 = select i1 %tmp7, i8* %tmp5, i8* %tmp6
  %unused_register0 = call i32 @puts (i8* %tmp4)
  ret i32 0
}

-- 
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/553d84e1/attachment.html>


More information about the llvm-bugs mailing list