[llvm-dev] Question about Constant expressions

James Courtier-Dutton via llvm-dev llvm-dev at lists.llvm.org
Sun May 31 01:49:01 PDT 2020


Hi,

Why is the getelementptr part of the call instruction, instead of
being a separate instruction in the LLVM IR ?
The LLVM IR Builder adds it as a separate instruction, but it is
rolled into one call instruction in the .bc output.
I am just curious as to why it is done this way.

#include <stdint.h>
#include <stdio.h>
int test21(void);
int test21(void) {
        printf("Hello1\n");
        return 0;
}

define dso_local i32 @test21() #0 {
  %1 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x
i8], [8 x i8]* @.str, i64 0, i64 0))
  ret i32 0
}


More information about the llvm-dev mailing list