58 lines · plain
1; REQUIRES: x862;; malloc+memset references can be combined to a calloc reference.3;; Test that we extract calloc defined in a lazy bitcode file to satisfy4;; possible references from LTO generated object files.5 6; RUN: rm -rf %t && split-file %s %t && cd %t7; RUN: llvm-as a.ll -o a.bc8; RUN: llvm-as calloc.ll -o calloc.bc9; RUN: llvm-mc -filetype=obj -triple=x86_64 lib.s -o lib.o10; RUN: ld.lld -u foo a.bc --start-lib calloc.bc lib.o --end-lib -o t --save-temps11; RUN: llvm-dis < t.0.4.opt.bc | FileCheck %s12; RUN: llvm-nm t | FileCheck %s --check-prefix=NM13 14; CHECK: define dso_local void @calloc15 16; NM-NOT: {{.}}17; NM: {{.*}} T _start18;; TODO: Currently the symbol is lazy, which lowers to a SHN_ABS symbol at address 0.19; NM-NEXT: {{.*}} T calloc20; NM-NEXT: {{.*}} T foo21; NM-NEXT: {{.*}} T malloc22; NM-NEXT: {{.*}} T memset23; NM-NOT: {{.}}24 25;--- a.ll26target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"27target triple = "x86_64-unknown-linux-gnu"28 29define ptr @foo() noinline {30entry:31 %call = tail call noalias ptr @malloc(i64 400)32 tail call void @llvm.memset.p0.i64(ptr %call, i8 0, i64 400, i1 false)33 ret ptr %call34}35 36define void @_start(ptr %a, ptr %b) {37entry:38 call ptr @foo()39 ret void40}41 42declare ptr @malloc(i64)43declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg)44 45;--- calloc.ll46target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"47target triple = "x86_64-unknown-linux-gnu"48 49define void @calloc(i64, i64) {50entry:51 ret void52}53 54;--- lib.s55.globl malloc, memset56malloc:57memset:58