Skip to content

setinlined not working in JIT mode on LLVM >= 17 #671

@norcalli

Description

@norcalli

terra-Linux-x86_64-094c5ad (1.1.1)

❯ ~/works/3rd/terra-Linux-x86_64-094c5ad/bin/terra ./tests/ainline.t
definition      {} -> int32
define dso_local i32 @"$bar"() {
entry:
  %puts.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str, i64 0, i64 0))
  %puts1.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.1, i64 0, i64 0))
  %puts2.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.2, i64 0, i64 0))
  %puts3.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.3, i64 0, i64 0))
  %puts4.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.4, i64 0, i64 0))
  %puts5.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.5, i64 0, i64 0))
  %puts6.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.6, i64 0, i64 0))
  %puts7.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.7, i64 0, i64 0))
  %puts8.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.8, i64 0, i64 0))
  %puts9.i = tail call i32 @puts(i8* nonnull dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @str.9, i64 0, i64 0))
  ret i32 4
}
assembly for function at address 0x72665b91d000
0x72665b91d000(+0):             push    rbx
0x72665b91d001(+1):             movabs  rdi, 125783948509184
0x72665b91d00b(+11):            movabs  rbx, 125783943755728
0x72665b91d015(+21):            call    rbx
0x72665b91d017(+23):            movabs  rdi, 125783948509197
0x72665b91d021(+33):            call    rbx
0x72665b91d023(+35):            movabs  rdi, 125783948509210
0x72665b91d02d(+45):            call    rbx
0x72665b91d02f(+47):            movabs  rdi, 125783948509223
0x72665b91d039(+57):            call    rbx
0x72665b91d03b(+59):            movabs  rdi, 125783948509236
0x72665b91d045(+69):            call    rbx
0x72665b91d047(+71):            movabs  rdi, 125783948509249
0x72665b91d051(+81):            call    rbx
0x72665b91d053(+83):            movabs  rdi, 125783948509262
0x72665b91d05d(+93):            call    rbx
0x72665b91d05f(+95):            movabs  rdi, 125783948509275
0x72665b91d069(+105):           call    rbx
0x72665b91d06b(+107):           movabs  rdi, 125783948509288
0x72665b91d075(+117):           call    rbx
0x72665b91d077(+119):           movabs  rdi, 125783948509301
0x72665b91d081(+129):           call    rbx
0x72665b91d083(+131):           mov     eax, 4
0x72665b91d088(+136):           pop     rbx
0x72665b91d089(+137):           ret

terra-Linux-x86_64-094c5ad (1.2.0)

❯ ~/works/3rd/terra-Linux-x86_64-cc543db/bin/terra ./tests/ainline.t
definition      {} -> int32
define dso_local i32 @"$bar"() {
entry:
  tail call void @"$foo"()
  ret i32 4
}
assembly for function at address 0x7781c8e9f000
0x7781c8e9f000(+0):             push    rax
0x7781c8e9f001(+1):             movabs  rax, 131399305261088
0x7781c8e9f00b(+11):            call    rax
0x7781c8e9f00d(+13):            mov     eax, 4
0x7781c8e9f012(+18):            pop     rcx
0x7781c8e9f013(+19):            ret

I noticed this from the disassembly on one of my personal projects, but it seems like inlining doesn't work and I checked against the existing test and that seems to be the case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions