70 lines · plain
1; Given a library call that is represented as an llvm intrinsic call, but2; later transformed to an actual call, if an overriding definition of that3; library routine is provided indirectly via an alias, verify that LTO4; does not eliminate the definition. This is a test for PR38547.5;6; RUN: llvm-as -o %t1 %s7; RUN: llvm-lto -exported-symbol=main -save-merged-module -filetype=asm -o %t2 %t18; RUN: llvm-dis -o - %t2.merged.bc | FileCheck --check-prefix=CHECK_IR %s9;10; Check that the call is represented as an llvm intrinsic in the IR after LTO:11; CHECK_IR-LABEL: main12; CHECK_IR: call float @llvm.log.f3213;14; Check that the IR contains the overriding definition of the library routine15; in the IR after LTO:16; CHECK_IR: define internal float @logf(float17; CHECK_IR-NEXT: [[TMP:%.*]] = fadd float18; CHECK_IR-NEXT: ret float [[TMP]]19;20; Check that the assembly code from LTO contains the call to the expected21; library routine, and that the overriding definition of the library routine22; is present:23; RUN: FileCheck --check-prefix=CHECK_ASM %s < %t224; CHECK_ASM-LABEL: main:25; CHECK_ASM: callq logf26; CHECK_ASM-LABEL: logf:27; CHECK_ASM-NEXT: add28; CHECK_ASM-NEXT: ret29 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 452@dst = common global float 0.000000e+00, align 453 54@logf = alias float (float), ptr @fname55 56define i32 @main() local_unnamed_addr {57entry:58 %0 = load volatile float, ptr @src, align 459 %1 = tail call float @llvm.log.f32(float %0)60 store volatile float %1, ptr @dst, align 461 ret i32 062}63 64declare float @llvm.log.f32(float)65 66define float @fname(float %x) {67 %add = fadd float %x, %x68 ret float %add69}70