Index: llvm/lib/IR/Globals.cpp =================================================================== --- llvm/lib/IR/Globals.cpp +++ llvm/lib/IR/Globals.cpp @@ -104,7 +104,8 @@ bool GlobalValue::canBenefitFromLocalAlias() const { // See AsmPrinter::getSymbolPreferLocal(). - return GlobalObject::isExternalLinkage(getLinkage()) && !isDeclaration() && + return hasDefaultVisibility() && + GlobalObject::isExternalLinkage(getLinkage()) && !isDeclaration() && !isa(this) && !hasComdat(); } Index: llvm/test/CodeGen/AArch64/emutls.ll =================================================================== --- llvm/test/CodeGen/AArch64/emutls.ll +++ llvm/test/CodeGen/AArch64/emutls.ll @@ -155,7 +155,6 @@ ; ARM64: .data{{$}} ; ARM64: .globl __emutls_v.i4 ; ARM64-LABEL: __emutls_v.i4: -; ARM64-NEXT: .L__emutls_v.i4$local: ; ARM64-NEXT: .xword 4 ; ARM64-NEXT: .xword 4 ; ARM64-NEXT: .xword 0 @@ -163,7 +162,6 @@ ; ARM64: .section .rodata, ; ARM64-LABEL: __emutls_t.i4: -; ARM64-NEXT: .L__emutls_t.i4$local: ; ARM64-NEXT: .word 15 ; ARM64-NOT: __emutls_v.i5: Index: llvm/test/CodeGen/ARM/emutls.ll =================================================================== --- llvm/test/CodeGen/ARM/emutls.ll +++ llvm/test/CodeGen/ARM/emutls.ll @@ -238,7 +238,6 @@ ; ARM32: .data{{$}} ; ARM32: .globl __emutls_v.i4 ; ARM32-LABEL: __emutls_v.i4: -; ARM32-NEXT: .L__emutls_v.i4$local: ; ARM32-NEXT: .long 4 ; ARM32-NEXT: .long 4 ; ARM32-NEXT: .long 0 @@ -246,7 +245,6 @@ ; ARM32: .section .rodata, ; ARM32-LABEL: __emutls_t.i4: -; ARM32-NEXT: .L__emutls_t.i4$local: ; ARM32-NEXT: .long 15 ; ARM32-NOT: __emutls_v.i5: Index: llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll =================================================================== --- llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll +++ llvm/test/CodeGen/X86/2008-03-12-ThreadLocalAlias.ll @@ -12,7 +12,7 @@ define i32 @foo() { ; CHECK-LABEL: foo: -; CHECK: leal .L__libc_resp$local@TLSLDM +; CHECK: leal __libc_resp@TLSLD entry: %retval = alloca i32 ; [#uses=1] %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] @@ -27,7 +27,7 @@ define i32 @bar() { ; CHECK-LABEL: bar: -; CHECK: leal .L__libc_resp$local@TLSLDM +; CHECK: leal __libc_resp@TLSLD entry: %retval = alloca i32 ; [#uses=1] %"alloca point" = bitcast i32 0 to i32 ; [#uses=0] Index: llvm/test/CodeGen/X86/code-model-elf-pic-nosip.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/code-model-elf-pic-nosip.ll @@ -0,0 +1,749 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; Run with --no_x86_scrub_rip because we care a lot about how globals are +; accessed in the code model. + +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=small | FileCheck %s --check-prefix=CHECK --check-prefix=SMALL-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=small | FileCheck %s --check-prefix=CHECK --check-prefix=SMALL-PIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-PIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC + +; The original version of this test was generated from this C source: +; +; static int static_data[10]; +; int global_data[10] = {1, 2}; +; extern int extern_data[10]; +; +; int *lea_static_data() { return &static_data[0]; } +; int *lea_global_data() { return &global_data[0]; } +; int *lea_extern_data() { return &extern_data[0]; } +; +; static void static_fn(void) {} +; void global_fn(void) {} +; void extern_fn(void); +; +; typedef void (*void_fn)(void); +; void_fn lea_static_fn() { return &static_fn; } +; void_fn lea_global_fn() { return &global_fn; } +; void_fn lea_extern_fn() { return &extern_fn; } + + +; ModuleID = 'model.c' +source_filename = "model.c" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64--linux" + +@hidden_data = hidden global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@dso_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@global_data = global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@static_data = internal global [10 x i32] zeroinitializer, align 16 +@extern_data = external global [10 x i32], align 16 +@thread_data = external thread_local global i32, align 4 + + +define dso_local i32* @lea_static_data() #0 { +; SMALL-STATIC-LABEL: lea_static_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $static_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_static_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $static_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_static_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $static_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_static_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq static_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_static_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $static_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_static_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L0$pb: +; LARGE-PIC-NEXT: leaq .L0$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $static_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @static_data, i64 0, i64 0) +} + +define hidden i32* @lea_hidden_data() #0 { +; SMALL-STATIC-LABEL: lea_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L1$pb: +; LARGE-PIC-NEXT: leaq .L1$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 0) +} + +define dso_local i32* @lea_dso_data() #0 { +; SMALL-STATIC-LABEL: lea_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq .Ldso_data$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L2$pb: +; LARGE-PIC-NEXT: leaq .L2$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 0) +} + +define i32* @lea_global_data() #0 { +; SMALL-STATIC-LABEL: lea_global_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $global_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_global_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_global_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_global_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq .Lglobal_data$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_global_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $.Lglobal_data$local@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_global_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L3$pb: +; LARGE-PIC-NEXT: leaq .L3$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Lglobal_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @global_data, i64 0, i64 0) +} + +define dso_local i32* @lea_extern_data() #0 { +; SMALL-STATIC-LABEL: lea_extern_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $extern_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_extern_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_extern_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_extern_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_extern_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_extern_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L4$pb: +; LARGE-PIC-NEXT: leaq .L4$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @extern_data, i64 0, i64 0) +} + +define hidden i32 @load_hidden_data() #0 { +; SMALL-STATIC-LABEL: load_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L5$pb: +; LARGE-PIC-NEXT: leaq .L5$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L5$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 2) + ret i32 %rv +} + +define dso_local i32 @load_dso_data() #0 { +; SMALL-STATIC-LABEL: load_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl dso_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl .Ldso_data$local+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L6$pb: +; LARGE-PIC-NEXT: leaq .L6$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L6$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 2) + ret i32 %rv +} + +define i32 @load_global_data() #0 { +; SMALL-STATIC-LABEL: load_global_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl global_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_global_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_global_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_global_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl .Lglobal_data$local+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_global_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $.Lglobal_data$local@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_global_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L7$pb: +; LARGE-PIC-NEXT: leaq .L7$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L7$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Lglobal_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @global_data, i64 0, i64 2) + ret i32 %rv +} + +define dso_local i32 @load_extern_data() #0 { +; SMALL-STATIC-LABEL: load_extern_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl extern_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_extern_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_extern_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_extern_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: movl 8(%rax), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_extern_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: movl 8(%rax), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_extern_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L8$pb: +; LARGE-PIC-NEXT: leaq .L8$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L8$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: movl 8(%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @extern_data, i64 0, i64 2) + ret i32 %rv +} + +define hidden void @hidden_fn() #0 { +; CHECK-LABEL: hidden_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define dso_local void @dso_fn() #0 { +; CHECK-LABEL: dso_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define void @global_fn() #0 { +; CHECK-LABEL: global_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define internal void @static_fn() #0 { +; CHECK-LABEL: static_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +declare void @extern_fn() + +define dso_local void ()* @lea_static_fn() #0 { +; SMALL-STATIC-LABEL: lea_static_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $static_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_static_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $static_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_static_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $static_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_static_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq static_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_static_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $static_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_static_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L13$pb: +; LARGE-PIC-NEXT: leaq .L13$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L13$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $static_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @static_fn +} + +define dso_local void ()* @lea_hidden_fn() #0 { +; SMALL-STATIC-LABEL: lea_hidden_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L14$pb: +; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @hidden_fn +} + +define dso_local void ()* @lea_dso_fn() #0 { +; SMALL-STATIC-LABEL: lea_dso_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: .Ldso_fn$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $.Ldso_fn$local, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L15$pb: +; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_fn$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @dso_fn +} + +define dso_local void ()* @lea_global_fn() #0 { +; SMALL-STATIC-LABEL: lea_global_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $global_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_global_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_global_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_global_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq .Lglobal_fn$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_global_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $.Lglobal_fn$local, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_global_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L16$pb: +; LARGE-PIC-NEXT: leaq .L16$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Lglobal_fn$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @global_fn +} + +define dso_local void ()* @lea_extern_fn() #0 { +; SMALL-STATIC-LABEL: lea_extern_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $extern_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_extern_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_extern_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_extern_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_fn@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_extern_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_fn@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_extern_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L17$pb: +; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_fn@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret void ()* @extern_fn +} + +define dso_local i32 @load_thread_data() #0 { +; SMALL-STATIC-LABEL: load_thread_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; SMALL-STATIC-NEXT: movl %fs:(%rax), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_thread_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; MEDIUM-STATIC-NEXT: movl %fs:(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_thread_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; LARGE-STATIC-NEXT: movl %fs:(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_thread_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC: data16 +; SMALL-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; SMALL-PIC-NEXT: data16 +; SMALL-PIC-NEXT: data16 +; SMALL-PIC-NEXT: rex64 +; SMALL-PIC-NEXT: callq __tls_get_addr@PLT +; SMALL-PIC-NEXT: movl (%rax), %eax +; SMALL-PIC-NEXT: popq %rcx +; SMALL-PIC-NEXT: .cfi_def_cfa_offset 8 +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_thread_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC: data16 +; MEDIUM-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; MEDIUM-PIC-NEXT: data16 +; MEDIUM-PIC-NEXT: data16 +; MEDIUM-PIC-NEXT: rex64 +; MEDIUM-PIC-NEXT: callq __tls_get_addr@PLT +; MEDIUM-PIC-NEXT: movl (%rax), %eax +; MEDIUM-PIC-NEXT: popq %rcx +; MEDIUM-PIC-NEXT: .cfi_def_cfa_offset 8 +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_thread_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC: data16 +; LARGE-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; LARGE-PIC-NEXT: data16 +; LARGE-PIC-NEXT: data16 +; LARGE-PIC-NEXT: rex64 +; LARGE-PIC-NEXT: callq __tls_get_addr@PLT +; LARGE-PIC-NEXT: movl (%rax), %eax +; LARGE-PIC-NEXT: popq %rcx +; LARGE-PIC-NEXT: .cfi_def_cfa_offset 8 +; LARGE-PIC-NEXT: retq +; + %1 = load i32, i32* @thread_data, align 4 + ret i32 %1 +} + +define dso_local float @load_constant_pool(float %x) #0 { +; SMALL-STATIC-LABEL: load_constant_pool: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: addss {{\.LCPI.*}}(%rip), %xmm0 +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_constant_pool: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq ${{\.LCPI.*}}, %rax +; MEDIUM-STATIC-NEXT: addss (%rax), %xmm0 +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_constant_pool: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq ${{\.LCPI.*}}, %rax +; LARGE-STATIC-NEXT: addss (%rax), %xmm0 +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_constant_pool: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: addss {{\.LCPI.*}}(%rip), %xmm0 +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_constant_pool: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq ${{\.LCPI.*}}@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: addss (%rax,%rcx), %xmm0 +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_constant_pool: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L19$pb: +; LARGE-PIC-NEXT: leaq .L19$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L19$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq ${{\.LCPI.*}}@GOTOFF, %rax +; LARGE-PIC-NEXT: addss (%rcx,%rax), %xmm0 +; LARGE-PIC-NEXT: retq + %a = fadd float %x, 1.0 + ret float %a +} + +attributes #0 = { noinline nounwind uwtable } + +!llvm.module.flags = !{!0, !1, !2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"SemanticInterposition", i32 0} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{!"clang version 7.0.0 "} Index: llvm/test/CodeGen/X86/code-model-elf-pic-sip.ll =================================================================== --- /dev/null +++ llvm/test/CodeGen/X86/code-model-elf-pic-sip.ll @@ -0,0 +1,748 @@ +; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py +; Run with --no_x86_scrub_rip because we care a lot about how globals are +; accessed in the code model. + +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=small | FileCheck %s --check-prefix=CHECK --check-prefix=SMALL-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=static -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-STATIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=small | FileCheck %s --check-prefix=CHECK --check-prefix=SMALL-PIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-PIC +; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC + +; The original version of this test was generated from this C source: +; +; static int static_data[10]; +; int global_data[10] = {1, 2}; +; extern int extern_data[10]; +; +; int *lea_static_data() { return &static_data[0]; } +; int *lea_global_data() { return &global_data[0]; } +; int *lea_extern_data() { return &extern_data[0]; } +; +; static void static_fn(void) {} +; void global_fn(void) {} +; void extern_fn(void); +; +; typedef void (*void_fn)(void); +; void_fn lea_static_fn() { return &static_fn; } +; void_fn lea_global_fn() { return &global_fn; } +; void_fn lea_extern_fn() { return &extern_fn; } + + +; ModuleID = 'model.c' +source_filename = "model.c" +target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64--linux" + +@hidden_data = hidden global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@dso_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@global_data = global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@static_data = internal global [10 x i32] zeroinitializer, align 16 +@extern_data = external global [10 x i32], align 16 +@thread_data = external thread_local global i32, align 4 + + +define dso_local i32* @lea_static_data() #0 { +; SMALL-STATIC-LABEL: lea_static_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $static_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_static_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $static_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_static_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $static_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_static_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq static_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_static_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $static_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_static_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L0$pb: +; LARGE-PIC-NEXT: leaq .L0$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L0$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $static_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @static_data, i64 0, i64 0) +} + +define hidden i32* @lea_hidden_data() #0 { +; SMALL-STATIC-LABEL: lea_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L1$pb: +; LARGE-PIC-NEXT: leaq .L1$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 0) +} + +define dso_local i32* @lea_dso_data() #0 { +; SMALL-STATIC-LABEL: lea_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq .Ldso_data$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L2$pb: +; LARGE-PIC-NEXT: leaq .L2$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 0) +} + +define i32* @lea_global_data() #0 { +; SMALL-STATIC-LABEL: lea_global_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $global_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_global_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_global_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_global_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq global_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_global_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq global_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_global_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L3$pb: +; LARGE-PIC-NEXT: leaq .L3$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $global_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @global_data, i64 0, i64 0) +} + +define dso_local i32* @lea_extern_data() #0 { +; SMALL-STATIC-LABEL: lea_extern_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $extern_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_extern_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_extern_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_extern_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_extern_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_extern_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L4$pb: +; LARGE-PIC-NEXT: leaq .L4$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @extern_data, i64 0, i64 0) +} + +define hidden i32 @load_hidden_data() #0 { +; SMALL-STATIC-LABEL: load_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L5$pb: +; LARGE-PIC-NEXT: leaq .L5$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L5$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 2) + ret i32 %rv +} + +define dso_local i32 @load_dso_data() #0 { +; SMALL-STATIC-LABEL: load_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl dso_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl .Ldso_data$local+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L6$pb: +; LARGE-PIC-NEXT: leaq .L6$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L6$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_data$local@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 2) + ret i32 %rv +} + +define i32 @load_global_data() #0 { +; SMALL-STATIC-LABEL: load_global_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl global_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_global_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_global_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_global_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq global_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: movl 8(%rax), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_global_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq global_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: movl 8(%rax), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_global_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L7$pb: +; LARGE-PIC-NEXT: leaq .L7$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L7$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $global_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: movl 8(%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @global_data, i64 0, i64 2) + ret i32 %rv +} + +define dso_local i32 @load_extern_data() #0 { +; SMALL-STATIC-LABEL: load_extern_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl extern_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_extern_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_extern_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_extern_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: movl 8(%rax), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_extern_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_data@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: movl 8(%rax), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_extern_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L8$pb: +; LARGE-PIC-NEXT: leaq .L8$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L8$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: movl 8(%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @extern_data, i64 0, i64 2) + ret i32 %rv +} + +define hidden void @hidden_fn() #0 { +; CHECK-LABEL: hidden_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define dso_local void @dso_fn() #0 { +; CHECK-LABEL: dso_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define void @global_fn() #0 { +; CHECK-LABEL: global_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define internal void @static_fn() #0 { +; CHECK-LABEL: static_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +declare void @extern_fn() + +define dso_local void ()* @lea_static_fn() #0 { +; SMALL-STATIC-LABEL: lea_static_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $static_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_static_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $static_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_static_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $static_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_static_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq static_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_static_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $static_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_static_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L13$pb: +; LARGE-PIC-NEXT: leaq .L13$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L13$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $static_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @static_fn +} + +define dso_local void ()* @lea_hidden_fn() #0 { +; SMALL-STATIC-LABEL: lea_hidden_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L14$pb: +; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @hidden_fn +} + +define dso_local void ()* @lea_dso_fn() #0 { +; SMALL-STATIC-LABEL: lea_dso_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: .Ldso_fn$local(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $.Ldso_fn$local, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L15$pb: +; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $.Ldso_fn$local@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @dso_fn +} + +define dso_local void ()* @lea_global_fn() #0 { +; SMALL-STATIC-LABEL: lea_global_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $global_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_global_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $global_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_global_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $global_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_global_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq global_fn@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_global_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq global_fn@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_global_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L16$pb: +; LARGE-PIC-NEXT: leaq .L16$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $global_fn@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret void ()* @global_fn +} + +define dso_local void ()* @lea_extern_fn() #0 { +; SMALL-STATIC-LABEL: lea_extern_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $extern_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_extern_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $extern_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_extern_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $extern_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_extern_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movq extern_fn@GOTPCREL(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_extern_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movq extern_fn@GOTPCREL(%rip), %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_extern_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L17$pb: +; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $extern_fn@GOT, %rax +; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax +; LARGE-PIC-NEXT: retq + ret void ()* @extern_fn +} + +define dso_local i32 @load_thread_data() #0 { +; SMALL-STATIC-LABEL: load_thread_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; SMALL-STATIC-NEXT: movl %fs:(%rax), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_thread_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; MEDIUM-STATIC-NEXT: movl %fs:(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_thread_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; LARGE-STATIC-NEXT: movl %fs:(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_thread_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC: data16 +; SMALL-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; SMALL-PIC-NEXT: data16 +; SMALL-PIC-NEXT: data16 +; SMALL-PIC-NEXT: rex64 +; SMALL-PIC-NEXT: callq __tls_get_addr@PLT +; SMALL-PIC-NEXT: movl (%rax), %eax +; SMALL-PIC-NEXT: popq %rcx +; SMALL-PIC-NEXT: .cfi_def_cfa_offset 8 +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_thread_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC: data16 +; MEDIUM-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; MEDIUM-PIC-NEXT: data16 +; MEDIUM-PIC-NEXT: data16 +; MEDIUM-PIC-NEXT: rex64 +; MEDIUM-PIC-NEXT: callq __tls_get_addr@PLT +; MEDIUM-PIC-NEXT: movl (%rax), %eax +; MEDIUM-PIC-NEXT: popq %rcx +; MEDIUM-PIC-NEXT: .cfi_def_cfa_offset 8 +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_thread_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC: data16 +; LARGE-PIC-NEXT: leaq thread_data@TLSGD(%rip), %rdi +; LARGE-PIC-NEXT: data16 +; LARGE-PIC-NEXT: data16 +; LARGE-PIC-NEXT: rex64 +; LARGE-PIC-NEXT: callq __tls_get_addr@PLT +; LARGE-PIC-NEXT: movl (%rax), %eax +; LARGE-PIC-NEXT: popq %rcx +; LARGE-PIC-NEXT: .cfi_def_cfa_offset 8 +; LARGE-PIC-NEXT: retq +; + %1 = load i32, i32* @thread_data, align 4 + ret i32 %1 +} + +define dso_local float @load_constant_pool(float %x) #0 { +; SMALL-STATIC-LABEL: load_constant_pool: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: addss {{\.LCPI.*}}(%rip), %xmm0 +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_constant_pool: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq ${{\.LCPI.*}}, %rax +; MEDIUM-STATIC-NEXT: addss (%rax), %xmm0 +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_constant_pool: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq ${{\.LCPI.*}}, %rax +; LARGE-STATIC-NEXT: addss (%rax), %xmm0 +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_constant_pool: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: addss {{\.LCPI.*}}(%rip), %xmm0 +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_constant_pool: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq ${{\.LCPI.*}}@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: addss (%rax,%rcx), %xmm0 +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_constant_pool: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L19$pb: +; LARGE-PIC-NEXT: leaq .L19$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L19$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq ${{\.LCPI.*}}@GOTOFF, %rax +; LARGE-PIC-NEXT: addss (%rcx,%rax), %xmm0 +; LARGE-PIC-NEXT: retq + %a = fadd float %x, 1.0 + ret float %a +} + +attributes #0 = { noinline nounwind uwtable } + +!llvm.module.flags = !{!0, !1, !2} +!llvm.ident = !{!3} + +!0 = !{i32 1, !"SemanticInterposition", i32 1} +!1 = !{i32 1, !"wchar_size", i32 4} +!2 = !{i32 7, !"PIC Level", i32 2} +!3 = !{!"clang version 7.0.0 "} Index: llvm/test/CodeGen/X86/code-model-elf-pie.ll =================================================================== --- llvm/test/CodeGen/X86/code-model-elf-pie.ll +++ llvm/test/CodeGen/X86/code-model-elf-pie.ll @@ -9,7 +9,7 @@ ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=medium | FileCheck %s --check-prefix=CHECK --check-prefix=MEDIUM-PIC ; RUN: llc -verify-machineinstrs < %s -relocation-model=pic -code-model=large | FileCheck %s --check-prefix=CHECK --check-prefix=LARGE-PIC -; Generated from this C source: +; The original version of this test was generated from this C source: ; ; static int static_data[10]; ; int global_data[10] = {1, 2}; @@ -34,7 +34,9 @@ target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" target triple = "x86_64--linux" -@global_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@hidden_data = hidden global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@dso_data = dso_local global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 +@global_data = global [10 x i32] [i32 1, i32 2, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, i32 0], align 16 @static_data = internal global [10 x i32] zeroinitializer, align 16 @extern_data = external global [10 x i32], align 16 @thread_data = external thread_local global i32, align 4 @@ -80,7 +82,87 @@ ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @static_data, i64 0, i64 0) } -define dso_local i32* @lea_global_data() #0 { +define hidden i32* @lea_hidden_data() #0 { +; SMALL-STATIC-LABEL: lea_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L1$pb: +; LARGE-PIC-NEXT: leaq .L1$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 0) +} + +define dso_local i32* @lea_dso_data() #0 { +; SMALL-STATIC-LABEL: lea_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_data, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq dso_data(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rcx +; MEDIUM-PIC-NEXT: movabsq $dso_data@GOTOFF, %rax +; MEDIUM-PIC-NEXT: addq %rcx, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L2$pb: +; LARGE-PIC-NEXT: leaq .L2$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $dso_data@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 0) +} + +define i32* @lea_global_data() #0 { ; SMALL-STATIC-LABEL: lea_global_data: ; SMALL-STATIC: # %bb.0: ; SMALL-STATIC-NEXT: movl $global_data, %eax @@ -110,9 +192,9 @@ ; ; LARGE-PIC-LABEL: lea_global_data: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L1$pb: -; LARGE-PIC-NEXT: leaq .L1$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L1$pb, %rcx +; LARGE-PIC-NEXT: .L3$pb: +; LARGE-PIC-NEXT: leaq .L3$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $global_data@GOTOFF, %rax ; LARGE-PIC-NEXT: addq %rcx, %rax @@ -148,9 +230,9 @@ ; ; LARGE-PIC-LABEL: lea_extern_data: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L2$pb: -; LARGE-PIC-NEXT: leaq .L2$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L2$pb, %rcx +; LARGE-PIC-NEXT: .L4$pb: +; LARGE-PIC-NEXT: leaq .L4$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax ; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax @@ -158,7 +240,93 @@ ret i32* getelementptr inbounds ([10 x i32], [10 x i32]* @extern_data, i64 0, i64 0) } -define dso_local i32 @load_global_data() #0 { +define hidden i32 @load_hidden_data() #0 { +; SMALL-STATIC-LABEL: load_hidden_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_hidden_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_hidden_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_hidden_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl hidden_data+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_hidden_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_hidden_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L5$pb: +; LARGE-PIC-NEXT: leaq .L5$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L5$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_data@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @hidden_data, i64 0, i64 2) + ret i32 %rv +} + +define dso_local i32 @load_dso_data() #0 { +; SMALL-STATIC-LABEL: load_dso_data: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl dso_data+8(%rip), %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: load_dso_data: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_data, %rax +; MEDIUM-STATIC-NEXT: movl 8(%rax), %eax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: load_dso_data: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_data, %rax +; LARGE-STATIC-NEXT: movl 8(%rax), %eax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: load_dso_data: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: movl dso_data+8(%rip), %eax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: load_dso_data: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: leaq _GLOBAL_OFFSET_TABLE_(%rip), %rax +; MEDIUM-PIC-NEXT: movabsq $dso_data@GOTOFF, %rcx +; MEDIUM-PIC-NEXT: movl 8(%rax,%rcx), %eax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: load_dso_data: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L6$pb: +; LARGE-PIC-NEXT: leaq .L6$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L6$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $dso_data@GOTOFF, %rax +; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax +; LARGE-PIC-NEXT: retq + %rv = load i32, i32* getelementptr inbounds ([10 x i32], [10 x i32]* @dso_data, i64 0, i64 2) + ret i32 %rv +} + +define i32 @load_global_data() #0 { ; SMALL-STATIC-LABEL: load_global_data: ; SMALL-STATIC: # %bb.0: ; SMALL-STATIC-NEXT: movl global_data+8(%rip), %eax @@ -190,9 +358,9 @@ ; ; LARGE-PIC-LABEL: load_global_data: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L3$pb: -; LARGE-PIC-NEXT: leaq .L3$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L3$pb, %rcx +; LARGE-PIC-NEXT: .L7$pb: +; LARGE-PIC-NEXT: leaq .L7$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L7$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $global_data@GOTOFF, %rax ; LARGE-PIC-NEXT: movl 8(%rcx,%rax), %eax @@ -233,9 +401,9 @@ ; ; LARGE-PIC-LABEL: load_extern_data: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L4$pb: -; LARGE-PIC-NEXT: leaq .L4$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L4$pb, %rcx +; LARGE-PIC-NEXT: .L8$pb: +; LARGE-PIC-NEXT: leaq .L8$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L8$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $extern_data@GOT, %rax ; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax @@ -245,7 +413,21 @@ ret i32 %rv } -define dso_local void @global_fn() #0 { +define hidden void @hidden_fn() #0 { +; CHECK-LABEL: hidden_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define dso_local void @dso_fn() #0 { +; CHECK-LABEL: dso_fn: +; CHECK: # %bb.0: +; CHECK-NEXT: retq + ret void +} + +define void @global_fn() #0 { ; CHECK-LABEL: global_fn: ; CHECK: # %bb.0: ; CHECK-NEXT: retq @@ -289,9 +471,9 @@ ; ; LARGE-PIC-LABEL: lea_static_fn: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L7$pb: -; LARGE-PIC-NEXT: leaq .L7$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L7$pb, %rcx +; LARGE-PIC-NEXT: .L13$pb: +; LARGE-PIC-NEXT: leaq .L13$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L13$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $static_fn@GOTOFF, %rax ; LARGE-PIC-NEXT: addq %rcx, %rax @@ -299,6 +481,82 @@ ret void ()* @static_fn } +define dso_local void ()* @lea_hidden_fn() #0 { +; SMALL-STATIC-LABEL: lea_hidden_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $hidden_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_hidden_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_hidden_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $hidden_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_hidden_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: leaq hidden_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_hidden_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $hidden_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_hidden_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L14$pb: +; LARGE-PIC-NEXT: leaq .L14$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L14$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $hidden_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @hidden_fn +} + +define dso_local void ()* @lea_dso_fn() #0 { +; SMALL-STATIC-LABEL: lea_dso_fn: +; SMALL-STATIC: # %bb.0: +; SMALL-STATIC-NEXT: movl $dso_fn, %eax +; SMALL-STATIC-NEXT: retq +; +; MEDIUM-STATIC-LABEL: lea_dso_fn: +; MEDIUM-STATIC: # %bb.0: +; MEDIUM-STATIC-NEXT: movabsq $dso_fn, %rax +; MEDIUM-STATIC-NEXT: retq +; +; LARGE-STATIC-LABEL: lea_dso_fn: +; LARGE-STATIC: # %bb.0: +; LARGE-STATIC-NEXT: movabsq $dso_fn, %rax +; LARGE-STATIC-NEXT: retq +; +; SMALL-PIC-LABEL: lea_dso_fn: +; SMALL-PIC: # %bb.0: +; SMALL-PIC-NEXT: dso_fn(%rip), %rax +; SMALL-PIC-NEXT: retq +; +; MEDIUM-PIC-LABEL: lea_dso_fn: +; MEDIUM-PIC: # %bb.0: +; MEDIUM-PIC-NEXT: movabsq $dso_fn, %rax +; MEDIUM-PIC-NEXT: retq +; +; LARGE-PIC-LABEL: lea_dso_fn: +; LARGE-PIC: # %bb.0: +; LARGE-PIC-NEXT: .L15$pb: +; LARGE-PIC-NEXT: leaq .L15$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L15$pb, %rcx +; LARGE-PIC-NEXT: addq %rax, %rcx +; LARGE-PIC-NEXT: movabsq $dso_fn@GOTOFF, %rax +; LARGE-PIC-NEXT: addq %rcx, %rax +; LARGE-PIC-NEXT: retq + ret void ()* @dso_fn +} + define dso_local void ()* @lea_global_fn() #0 { ; SMALL-STATIC-LABEL: lea_global_fn: ; SMALL-STATIC: # %bb.0: @@ -327,9 +585,9 @@ ; ; LARGE-PIC-LABEL: lea_global_fn: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L8$pb: -; LARGE-PIC-NEXT: leaq .L8$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L8$pb, %rcx +; LARGE-PIC-NEXT: .L16$pb: +; LARGE-PIC-NEXT: leaq .L16$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L16$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $global_fn@GOTOFF, %rax ; LARGE-PIC-NEXT: addq %rcx, %rax @@ -365,9 +623,9 @@ ; ; LARGE-PIC-LABEL: lea_extern_fn: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L9$pb: -; LARGE-PIC-NEXT: leaq .L9$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L9$pb, %rcx +; LARGE-PIC-NEXT: .L17$pb: +; LARGE-PIC-NEXT: leaq .L17$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L17$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq $extern_fn@GOT, %rax ; LARGE-PIC-NEXT: movq (%rcx,%rax), %rax @@ -375,64 +633,41 @@ ret void ()* @extern_fn } -; FIXME: The result is same for small, medium and large model, because we -; specify pie option in the test case. And the type of tls is initial exec tls. -; For pic code. The large model code for pic tls should be emitted as below. - -; .L3: -; leaq .L3(%rip), %rbx -; movabsq $_GLOBAL_OFFSET_TABLE_-.L3, %r11 -; addq %r11, %rbx -; leaq thread_data@TLSGD(%rip), %rdi -; movabsq $__tls_get_addr@PLTOFF, %rax -; addq %rbx, %rax -; call *%rax -; movl (%rax), %eax - -; The medium and small model code for pic tls should be emitted as below. -; data16 -; leaq thread_data@TLSGD(%rip), %rdi -; data16 -; data16 -; rex64 -; callq __tls_get_addr@PLT -; movl (%rax), %eax - define dso_local i32 @load_thread_data() #0 { ; SMALL-STATIC-LABEL: load_thread_data: ; SMALL-STATIC: # %bb.0: -; SMALL-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; SMALL-STATIC-NEXT: movl %fs:(%rax), %eax +; SMALL-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; SMALL-STATIC-NEXT: movl %fs:(%rax), %eax ; SMALL-STATIC-NEXT: retq ; ; MEDIUM-STATIC-LABEL: load_thread_data: ; MEDIUM-STATIC: # %bb.0: -; MEDIUM-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; MEDIUM-STATIC-NEXT: movl %fs:(%rax), %eax +; MEDIUM-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; MEDIUM-STATIC-NEXT: movl %fs:(%rax), %eax ; MEDIUM-STATIC-NEXT: retq ; ; LARGE-STATIC-LABEL: load_thread_data: ; LARGE-STATIC: # %bb.0: -; LARGE-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; LARGE-STATIC-NEXT: movl %fs:(%rax), %eax +; LARGE-STATIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; LARGE-STATIC-NEXT: movl %fs:(%rax), %eax ; LARGE-STATIC-NEXT: retq ; ; SMALL-PIC-LABEL: load_thread_data: ; SMALL-PIC: # %bb.0: -; SMALL-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; SMALL-PIC-NEXT: movl %fs:(%rax), %eax +; SMALL-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; SMALL-PIC-NEXT: movl %fs:(%rax), %eax ; SMALL-PIC-NEXT: retq ; ; MEDIUM-PIC-LABEL: load_thread_data: ; MEDIUM-PIC: # %bb.0: -; MEDIUM-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; MEDIUM-PIC-NEXT: movl %fs:(%rax), %eax +; MEDIUM-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; MEDIUM-PIC-NEXT: movl %fs:(%rax), %eax ; MEDIUM-PIC-NEXT: retq ; ; LARGE-PIC-LABEL: load_thread_data: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax -; LARGE-PIC-NEXT: movl %fs:(%rax), %eax +; LARGE-PIC-NEXT: movq thread_data@GOTTPOFF(%rip), %rax +; LARGE-PIC-NEXT: movl %fs:(%rax), %eax ; LARGE-PIC-NEXT: retq ; %1 = load i32, i32* @thread_data, align 4 @@ -471,9 +706,9 @@ ; ; LARGE-PIC-LABEL: load_constant_pool: ; LARGE-PIC: # %bb.0: -; LARGE-PIC-NEXT: .L11$pb: -; LARGE-PIC-NEXT: leaq .L11$pb(%rip), %rax -; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L11$pb, %rcx +; LARGE-PIC-NEXT: .L19$pb: +; LARGE-PIC-NEXT: leaq .L19$pb(%rip), %rax +; LARGE-PIC-NEXT: movabsq $_GLOBAL_OFFSET_TABLE_-.L19$pb, %rcx ; LARGE-PIC-NEXT: addq %rax, %rcx ; LARGE-PIC-NEXT: movabsq ${{\.LCPI.*}}@GOTOFF, %rax ; LARGE-PIC-NEXT: addss (%rcx,%rax), %xmm0 Index: llvm/test/CodeGen/X86/semantic-interposition-comdat.ll =================================================================== --- llvm/test/CodeGen/X86/semantic-interposition-comdat.ll +++ llvm/test/CodeGen/X86/semantic-interposition-comdat.ll @@ -3,7 +3,7 @@ $comdat_func = comdat any ; CHECK-LABEL: func2: -; CHECK-NEXT: .Lfunc2$local +; CHECK-NOT: .Lfunc2$local declare void @func() Index: llvm/test/CodeGen/X86/tailcallpic1.ll =================================================================== --- llvm/test/CodeGen/X86/tailcallpic1.ll +++ llvm/test/CodeGen/X86/tailcallpic1.ll @@ -12,5 +12,5 @@ entry: %tmp11 = tail call fastcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] ret i32 %tmp11 -; CHECK: jmp .Ltailcallee$local +; CHECK: jmp tailcallee } Index: llvm/test/CodeGen/X86/tailcallpic3.ll =================================================================== --- llvm/test/CodeGen/X86/tailcallpic3.ll +++ llvm/test/CodeGen/X86/tailcallpic3.ll @@ -16,7 +16,7 @@ ret void } ; CHECK: tailcall_hidden: -; CHECK: jmp .Ltailcallee_hidden$local +; CHECK: jmp tailcallee_hidden define internal void @tailcallee_internal() { entry: Index: llvm/test/CodeGen/X86/tailccpic1.ll =================================================================== --- llvm/test/CodeGen/X86/tailccpic1.ll +++ llvm/test/CodeGen/X86/tailccpic1.ll @@ -12,5 +12,5 @@ entry: %tmp11 = tail call tailcc i32 @tailcallee( i32 %in1, i32 %in2, i32 %in1, i32 %in2 ) ; [#uses=1] ret i32 %tmp11 -; CHECK: jmp .Ltailcallee$local +; CHECK: jmp tailcallee }