[llvm-dev] Instruction not in sequence

Russell Wallace via llvm-dev llvm-dev at lists.llvm.org
Sun Nov 8 02:03:27 PST 2015


This code:

int main(int argc, char **argv) {
  puts("abc");
  return 0;
}

compiles to this:

@"\01??_C at _03FIKCJHKP@abc?$AA@" = linkonce_odr unnamed_addr constant [4 x
i8] c"abc\00", comdat, align 1

; Function Attrs: nounwind uwtable
define i32 @main(i32 %argc, i8** nocapture readnone %argv) #0 {
  %1 = tail call i32 @puts(i8* getelementptr inbounds ([4 x i8], [4 x i8]*
@"\01??_C at _03FIKCJHKP@abc?$AA@", i64 0, i64 0)) #2, !dbg !15
  ret i32 0, !dbg !16
}

The part I don't understand is where the call instruction refers to the
result of getelementptr without the latter appearing in the sequence of
instructions. I thought all instructions appeared in sequence in basic
blocks, so I was expecting %1 = getelementptr ..., %2 = call(%1 ...)

Is there something I'm missing about the rules for the intermediate code
representation?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20151108/0ddca11c/attachment.html>


More information about the llvm-dev mailing list