<div dir="auto">The large model should work if you create a non-PIC executable, rename function to _start and provide a definition of the global. Then in your test case link with small and large models and test for absence/presence of movabs instruction.<div dir="auto"><br></div><div dir="auto">Peter<br><div dir="auto"><br><div class="gmail_extra"><br><div class="gmail_quote">On Feb 20, 2017 03:52, "Martell Malone via Phabricator" <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br type="attribution"><blockquote class="quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">martell added a comment.<br>
<div class="quoted-text"><br>
In <a href="https://reviews.llvm.org/D29445#675329" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D29445#675329</a>, @pcc wrote:<br>
<br>
> It looks like you could adapt the test case `llvm/test/CodeGen/X86/<wbr>codemodel.ll`.<br>
<br>
<br>
</div>I created a test case based on `llvm/test/CodeGen/X86/<wbr>codemodel.ll`<br>
<br>
  ; REQUIRES: x86<br>
  ; RUN: llvm-as %s -o %t.o<br>
  ; RUN: ld.lld -m elf_x86_64 %t.o -o %ts.so -mllvm -code-model=small -shared<br>
  ; RUN: ld.lld -m elf_x86_64 %t.o -o %tk.so -mllvm -code-model=kernel -shared<br>
  ; RUN: llvm-objdump -d %ts.so -o - | FileCheck %s --check-prefix=SMALL<br>
  ; RUN: llvm-objdump -d %tk.so -o - | FileCheck %s --check-prefix=KERNEL<br>
<br>
  target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-<wbr>i16:16:16-i32:32:32-i64:64:64-<wbr>f32:32:32-f64:64:64-v64:64:64-<wbr>v128:128:128-a0:0:64-s0:64:64-<wbr>f80:128:128"<br>
  target triple = "x86_64-unknown-linux-gnu"<br>
  @data = external global [0 x i32] ; <[0 x i32]*> [#uses=5]<br>
<br>
  define i32 @foo() nounwind readonly {<br>
  entry:<br>
  ; CHECK-SMALL-LABEL:  foo:<br>
  ; CHECK-SMALL:   movl 4233(%rip), %eax<br>
  ; CHECK-KERNEL-LABEL: foo:<br>
  ; CHECK-KERNEL:  movl 4233, %eax<br>
      %0 = load i32, i32* getelementptr ([0 x i32], [0 x i32]* @data, i64 0, i64 0), align 4 ; <i32> [#uses=1]<br>
      ret i32 %0<br>
  }<br>
<br>
This is the result I am getting from the `llvm-objdump` stage<br>
<br>
  codemodels.so:  file format ELF64-x86-64<br>
  Disassembly of section .text:<br>
  foo:<br>
      1000:       48 8b 05 89 10 00 00    movq    4233(%rip), %rax<br>
      1007:       8b 00   movl    (%rax), %eax<br>
      1009:       c3      retq<br>
<br>
  codemodelk.so:  file format ELF64-x86-64<br>
  Disassembly of section .text:<br>
  foo:<br>
      1000:       48 8b 05 89 10 00 00    movq    4233(%rip), %rax<br>
      1007:       8b 00   movl    (%rax), %eax<br>
      1009:       c3      retq<br>
<br>
The assumption I am making is that `llvm-as` only converts `llvm-ir` in a text format to a binary format.<br>
So as a result I should be able to use the code model passed after `-mllvm` to decide what is generated.<br>
I also tried changing the target to `i686` or `i386` with no joy.<br>
<br>
Just for a test I did pass `-code-model=large` and I get errors<br>
`ld.lld: error: ld-temp.o:(function foo): can't create dynamic relocation R_X86_64_64 against symbol 'data' defined in codemodel.o`<br>
this makes sense because of `@data = external global [0 x i32] ; <[0 x i32]*> [#uses=5]`<br>
<div class="elided-text"><br>
<br>
Repository:<br>
  rL LLVM<br>
<br>
<a href="https://reviews.llvm.org/D29445" rel="noreferrer" target="_blank">https://reviews.llvm.org/<wbr>D29445</a><br>
<br>
<br>
<br>
</div></blockquote></div><br></div></div></div></div>