xref: /llvm-project/llvm/test/Transforms/FunctionImport/funcimport_var.ll (revision 4638eb26603c8d1cd3c46167734356e2585afdfe)
1;; This test makes sure a static var is not selected as a callee target (it will
2;; have a different GUID). Similarly, ensure that a callee GUID annotated from a
3;; sample pgo profile that matches a global variable GUID (either due to code
4;; changes or a hash collision), does not get considered for importing. Either
5;; of these can crash compilation.
6; RUN: opt -module-summary %s -o %t.bc
7; RUN: opt -module-summary %p/Inputs/funcimport_var2.ll -o %t2.bc
8; RUN: llvm-lto -thinlto -thinlto-action=thinlink -o %t3 %t.bc %t2.bc
9; RUN: llvm-lto -thinlto -thinlto-action=import -thinlto-index=%t3 %t.bc %t2.bc
10; RUN: llvm-lto -thinlto -thinlto-action=run %t.bc %t2.bc -exported-symbol=_Z4LinkPKcS0_
11; RUN: llvm-nm %t.bc.thinlto.o | FileCheck %s --implicit-check-not=globalvar
12; RUN: llvm-lto2 run %t.bc %t2.bc -o %t.out \
13; RUN:   -r %t.bc,_Z4LinkPKcS0_,plx \
14; RUN:   -r %t.bc,link,l \
15; RUN:   -r %t2.bc,globalvar,plx \
16; RUN:   -r %t2.bc,get_link,plx
17; RUN: llvm-nm %t.out.1 | FileCheck %s --implicit-check-not=globalvar
18; CHECK: U link
19
20; REQUIRES: x86-registered-target
21
22target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
23target triple = "x86_64-unknown-linux-gnu"
24
25define i32 @_Z4LinkPKcS0_(ptr, ptr) local_unnamed_addr !prof !1 {
26  %3 = tail call i32 @link(ptr %0, ptr %1) #2
27  ret i32 %3
28}
29
30; Function Attrs: nounwind
31declare i32 @link(ptr, ptr) local_unnamed_addr
32
33;; This matches the GUID of global variable @globalvar in the other input.
34!1 = !{!"function_entry_count", i64 110, i64 12887606300320728018}
35