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.
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
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
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]]
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
23 ; RUN: FileCheck --check-prefix=CHECK_ASM %s < %t2
24 ; CHECK_ASM-LABEL: main:
25 ; CHECK_ASM: callq logf
26 ; CHECK_ASM-LABEL: logf:
30 ; Produced from the following source-code:
32 ;extern float logf(float);
33 ;// 'src' and 'dst' are 'volatile' to prohibit optimization.
34 ;volatile float src = 3.14f;
42 ;extern float fname(float x);
43 ;float fname(float x) {
47 ;float logf(float x) __attribute__((alias("fname")));
49 target triple = "x86_64-unknown-linux-gnu"
51 @src = global float 0x40091EB860000000, align 4
52 @dst = common global float 0.000000e+00, align 4
54 @logf = alias float (float), float (float)* @fname
56 define i32 @main() local_unnamed_addr {
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
64 declare float @llvm.log.f32(float)
66 define float @fname(float %x) {
67 %add = fadd float %x, %x