1; Given a library call that is represented as an llvm intrinsic call, but 2; later transformed to an actual call, if an overriding definition of that 3; library routine is provided indirectly via an alias, verify that LTO 4; does not eliminate the definition. This is a test for PR38547. 5; 6; RUN: llvm-as -o %t1 %s 7; RUN: llvm-lto -exported-symbol=main -save-merged-module -filetype=asm -o %t2 %t1 8; RUN: llvm-dis -o - %t2.merged.bc | FileCheck --check-prefix=CHECK_IR %s 9; 10; Check that the call is represented as an llvm intrinsic in the IR after LTO: 11; CHECK_IR-LABEL: main 12; CHECK_IR: call float @llvm.log.f32 13; 14; Check that the IR contains the overriding definition of the library routine 15; in the IR after LTO: 16; CHECK_IR: define internal float @logf(float 17; CHECK_IR-NEXT: [[TMP:%.*]] = fadd float 18; CHECK_IR-NEXT: ret float [[TMP]] 19; 20; Check that the assembly code from LTO contains the call to the expected 21; library routine, and that the overriding definition of the library routine 22; is present: 23; RUN: FileCheck --check-prefix=CHECK_ASM %s < %t2 24; CHECK_ASM-LABEL: main: 25; CHECK_ASM: callq logf 26; CHECK_ASM-LABEL: logf: 27; CHECK_ASM-NEXT: add 28; CHECK_ASM-NEXT: ret 29 30; Produced from the following source-code: 31; 32;extern float logf(float); 33;// 'src' and 'dst' are 'volatile' to prohibit optimization. 34;volatile float src = 3.14f; 35;volatile float dst; 36; 37;int main() { 38; dst = logf(src); 39; return 0; 40;} 41; 42;extern float fname(float x); 43;float fname(float x) { 44; return x + x; 45;} 46; 47;float logf(float x) __attribute__((alias("fname"))); 48; 49target triple = "x86_64-unknown-linux-gnu" 50 51@src = global float 0x40091EB860000000, align 4 52@dst = common global float 0.000000e+00, align 4 53 54@logf = alias float (float), float (float)* @fname 55 56define i32 @main() local_unnamed_addr { 57entry: 58 %0 = load volatile float, float* @src, align 4 59 %1 = tail call float @llvm.log.f32(float %0) 60 store volatile float %1, float* @dst, align 4 61 ret i32 0 62} 63 64declare float @llvm.log.f32(float) 65 66define float @fname(float %x) { 67 %add = fadd float %x, %x 68 ret float %add 69} 70