xref: /llvm-project/llvm/test/ThinLTO/X86/index-const-prop-cache.ll (revision 7b1d793713cf9ed9ab719f33b332f9c66a1fc5cc)
1bf46e741SEugene Leviant; Check that we correctly handle 'ReadOnly' attribute when computing cache key
2bf46e741SEugene Leviant; RUN: opt -module-summary -module-hash %s -o %t1.bc
3bf46e741SEugene Leviant; RUN: opt -module-summary -module-hash %p/Inputs/index-const-prop-cache-foo.ll -o %t2.bc
4bf46e741SEugene Leviant; RUN: opt -module-summary -module-hash %p/Inputs/index-const-prop-cache-test1.ll -o %t3.bc
5bf46e741SEugene Leviant; RUN: opt -module-summary -module-hash %p/Inputs/index-const-prop-cache-test2.ll -o %t4.bc
6bf46e741SEugene Leviant; RUN: rm -Rf %t.cache && mkdir %t.cache
7bf46e741SEugene Leviant
8bf46e741SEugene Leviant; Here @gFoo variable is writeable
9bf46e741SEugene Leviant; RUN: llvm-lto -thinlto-action=run %t1.bc %t4.bc %t2.bc \
10bf46e741SEugene Leviant; RUN:    -exported-symbol=main -exported-symbol=test -thinlto-cache-dir=%t.cache
11bf46e741SEugene Leviant; RUN: ls %t.cache/llvmcache-* | count 3
12bf46e741SEugene Leviant
13bf46e741SEugene Leviant; Now gFoo is read-only and all modules should get different cache keys.
14bf46e741SEugene Leviant; RUN: llvm-lto -thinlto-action=run %t1.bc %t3.bc %t2.bc \
15bf46e741SEugene Leviant; RUN:    -exported-symbol=main -exported-symbol=test -thinlto-cache-dir=%t.cache
16bf46e741SEugene Leviant; RUN: ls %t.cache/llvmcache-* | count 6
17bf46e741SEugene Leviant
18bf46e741SEugene Leviant; Do the same but with llvm-lto2
19bf46e741SEugene Leviant; RUN: rm -Rf %t.cache && mkdir %t.cache
20bf46e741SEugene Leviant; RUN: llvm-lto2 run  %t1.bc %t4.bc %t2.bc -cache-dir=%t.cache -o %t5 \
21bf46e741SEugene Leviant; RUN:  -r=%t1.bc,main,plx -r=%t1.bc,foo,l \
22bf46e741SEugene Leviant; RUN:  -r=%t4.bc,test,plx -r=%t4.bc,foo,l -r=%t4.bc,bar,l \
23bf46e741SEugene Leviant; RUN:  -r=%t2.bc,foo,pl -r=%t2.bc,bar,pl -r=%t2.bc,rand,
24bf46e741SEugene Leviant; RUN: ls %t.cache/llvmcache-* | count 3
25bf46e741SEugene Leviant
26bf46e741SEugene Leviant; RUN: llvm-lto2 run %t1.bc %t3.bc %t2.bc -cache-dir %t.cache -o %t6 \
27bf46e741SEugene Leviant; RUN:  -r=%t1.bc,main,plx -r=%t1.bc,foo,l \
28bf46e741SEugene Leviant; RUN:  -r=%t3.bc,test,plx -r=%t3.bc,foo,l \
29bf46e741SEugene Leviant; RUN:  -r=%t2.bc,foo,pl -r=%t2.bc,bar,pl -r=%t2.bc,rand,
30bf46e741SEugene Leviant; RUN: ls %t.cache/llvmcache-* | count 6
31bf46e741SEugene Leviant
32*7b1d7937SAmy Huangtarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
33bf46e741SEugene Levianttarget triple = "x86_64-unknown-linux-gnu"
34bf46e741SEugene Leviant
35bf46e741SEugene Leviant; Function Attrs: nounwind ssp uwtable
36bf46e741SEugene Leviantdefine i32 @main() local_unnamed_addr {
37bf46e741SEugene Leviant  %1 = tail call i32 (...) @foo()
38bf46e741SEugene Leviant  ret i32 %1
39bf46e741SEugene Leviant}
40bf46e741SEugene Leviant
41bf46e741SEugene Leviantdeclare i32 @foo(...) local_unnamed_addr
42