2 ; Test to ensure that the Unified LTO flag is set properly in the summary, and
3 ; that we emit the correct error when linking bitcode files with different
6 ; Linking bitcode both without UnifiedLTO set should work
7 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1 %s
8 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=NOUNIFIEDLTO
9 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=NOUNIFIEDLTOFLAG
10 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t2 %s
11 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=NOUNIFIEDLTO
12 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=NOUNIFIEDLTOFLAG
13 ; RUN: llvm-lto2 run -o %t3 %t1 %t2
14 ; RUN: not llvm-lto2 run --unified-lto=thin -o %t3 %t1 %t2 2>&1 | \
15 ; RUN: FileCheck --allow-empty %s --check-prefix UNIFIEDERR
17 ; Linking bitcode with different values of UnifiedLTO should fail
18 ; RUN: opt -thinlto-bc -thinlto-split-lto-unit -o %t1 %s
19 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=NOUNIFIEDLTO
20 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=NOUNIFIEDLTOFLAG
21 ; RUN: opt -unified-lto -thinlto-bc -thinlto-split-lto-unit -o %t2 %s
22 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=UNIFIEDLTO
23 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=UNIFIEDLTOFLAG
24 ; RUN: not llvm-lto2 run --unified-lto=thin -o %t3 %t1 %t2 2>&1 | \
25 ; RUN: FileCheck --allow-empty %s --check-prefix UNIFIEDERR
27 ; Linking bitcode with identical Unified LTO flags should succeed
28 ; RUN: opt -unified-lto -thinlto-bc -thinlto-split-lto-unit -o %t1 %s
29 ; RUN: llvm-bcanalyzer -dump %t1 | FileCheck %s --check-prefix=UNIFIEDLTO
30 ; RUN: llvm-dis -o - %t1 | FileCheck %s --check-prefix=UNIFIEDLTOFLAG
31 ; RUN: opt -unified-lto -thinlto-bc -thinlto-split-lto-unit -o %t2 %s
32 ; RUN: llvm-bcanalyzer -dump %t2 | FileCheck %s --check-prefix=UNIFIEDLTO
33 ; RUN: llvm-dis -o - %t2 | FileCheck %s --check-prefix=UNIFIEDLTOFLAG
34 ; RUN: llvm-lto2 run --unified-lto=full --debug-only=lto -o %t3 %t1 %t2 2>&1 | \
35 ; RUN: FileCheck --allow-empty %s --check-prefix NOUNIFIEDERR --check-prefix FULL
36 ; RUN: llvm-lto2 run --unified-lto=thin --debug-only=lto -o %t3 %t1 %t2 2>&1 | \
37 ; RUN: FileCheck --allow-empty %s --check-prefix NOUNIFIEDERR --check-prefix THIN
38 ; RUN: llvm-lto2 run --debug-only=lto -o %t3 %t1 %t2 2>&1 | \
39 ; RUN: FileCheck --allow-empty %s --check-prefix THIN
41 ; UNIFIEDERR: unified LTO compilation must use compatible bitcode modules
42 ; NOUNIFIEDERR-NOT: unified LTO compilation must use compatible bitcode modules
44 ; The flag should be set when UnifiedLTO is enabled
45 ; UNIFIEDLTO: <FLAGS op0=520/>
46 ; NOUNIFIEDLTO: <FLAGS op0=8/>
48 ; Check that the corresponding module flag is set when expected.
49 ; UNIFIEDLTOFLAG: !{i32 1, !"UnifiedLTO", i32 1}
50 ; NOUNIFIEDLTOFLAG-NOT: !{i32 1, !"UnifiedLTO", i32 1}
52 ; FULL: Running regular LTO
53 ; THIN: Running ThinLTO
55 target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
56 target triple = "x86_64-unknown-linux-gnu"