1*0a6a1f1dSLionel Sambuc; RUN: llc < %s -relocation-model=pic -O2 -disable-fp-elim -o - | FileCheck %s 2*0a6a1f1dSLionel Sambuc; RUN: llc < %s -relocation-model=pic -O2 -o - | FileCheck %s 3*0a6a1f1dSLionel Sambuc 4*0a6a1f1dSLionel Sambuc; This test runs twice with different options regarding the frame pointer: 5*0a6a1f1dSLionel Sambuc; first the elimination is disabled, then it is enabled. The disabled case is 6*0a6a1f1dSLionel Sambuc; the "control group". 7*0a6a1f1dSLionel Sambuc; The function 'foo' below is marked with the "no-frame-pointer-elim-non-leaf" 8*0a6a1f1dSLionel Sambuc; attribute which dictates that the frame pointer should not be eliminated 9*0a6a1f1dSLionel Sambuc; unless the function is a leaf (i.e. it doesn't call any other function). 10*0a6a1f1dSLionel Sambuc; Now, 'foo' is not a leaf function, because it performs a TLS access which on 11*0a6a1f1dSLionel Sambuc; X86 ELF in PIC mode is expanded as a library call. 12*0a6a1f1dSLionel Sambuc; This call is represented with a pseudo-instruction which doesn't appear to be 13*0a6a1f1dSLionel Sambuc; a call when inspected by the analysis passes (it doesn't have the "isCall" 14*0a6a1f1dSLionel Sambuc; flag), and the ISel lowering code creating the pseudo was not informing the 15*0a6a1f1dSLionel Sambuc; MachineFrameInfo that the function contained calls. This affected the decision 16*0a6a1f1dSLionel Sambuc; whether to eliminate the frame pointer. 17*0a6a1f1dSLionel Sambuc; With the fix, the "hasCalls" flag is set in the MFI for the function whenever 18*0a6a1f1dSLionel Sambuc; a TLS access pseudo-instruction is created, so 'foo' appears to be a non-leaf 19*0a6a1f1dSLionel Sambuc; function, and the difference in the options does not affect codegen: both 20*0a6a1f1dSLionel Sambuc; versions will have a frame pointer. 21*0a6a1f1dSLionel Sambuc 22*0a6a1f1dSLionel Sambuc; Test that there's some frame pointer usage in 'foo'... 23*0a6a1f1dSLionel Sambuc; CHECK: foo: 24*0a6a1f1dSLionel Sambuc; CHECK: pushq %rbp 25*0a6a1f1dSLionel Sambuc; CHECK: movq %rsp, %rbp 26*0a6a1f1dSLionel Sambuc; ... and the TLS library call is also present. 27*0a6a1f1dSLionel Sambuc; CHECK: leaq x@TLSGD(%rip), %rdi 28*0a6a1f1dSLionel Sambuc; CHECK: callq __tls_get_addr@PLT 29*0a6a1f1dSLionel Sambuc 30*0a6a1f1dSLionel Sambuctarget datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" 31*0a6a1f1dSLionel Sambuctarget triple = "x86_64-unknown-linux-gnu" 32*0a6a1f1dSLionel Sambuc 33*0a6a1f1dSLionel Sambuc@x = thread_local global i32 0 34*0a6a1f1dSLionel Sambucdefine i32 @foo() "no-frame-pointer-elim-non-leaf" { 35*0a6a1f1dSLionel Sambuc %a = load i32* @x, align 4 36*0a6a1f1dSLionel Sambuc ret i32 %a 37*0a6a1f1dSLionel Sambuc} 38