1; REQUIRES: x86
2; RUN: llvm-as %s -o %t.o
3; RUN: ld.lld %t.o -o %t.so -save-temps --lto-aa-pipeline=basic-aa \
4; RUN: --lto-newpm-passes=ipsccp -shared
5; RUN: ld.lld %t.o -o %t2.so -save-temps --lto-newpm-passes=loweratomic -shared
6; RUN: llvm-dis %t.so.0.4.opt.bc -o - | FileCheck %s
7; RUN: llvm-dis %t2.so.0.4.opt.bc -o - | FileCheck %s --check-prefix=ATOMIC
8
9target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
10target triple = "x86_64-unknown-linux-gnu"
11
12define void @barrier() {
13  fence seq_cst
14  ret void
15}
16
17; IPSCCP won't remove the fence.
18; CHECK: define void @barrier() {
19; CHECK-NEXT: fence seq_cst
20; CHECK-NEXT: ret void
21
22; LowerAtomic will remove the fence.
23; ATOMIC: define void @barrier() {
24; ATOMIC-NEXT: ret void
25
26; Check that invalid passes are rejected gracefully.
27; RUN: not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
28; RUN:   --lto-newpm-passes=iamnotapass -shared 2>&1 | \
29; RUN:   FileCheck %s --check-prefix=INVALID
30; INVALID: unable to parse pass pipeline description 'iamnotapass': unknown pass name 'iamnotapass'
31
32; Check that invalid AA pipelines are rejected gracefully.
33; RUN: not --crash ld.lld -m elf_x86_64 %t.o -o /dev/null \
34; RUN:   --lto-newpm-passes=globaldce --lto-aa-pipeline=patatino \
35; RUN:   -shared 2>&1 | \
36; RUN:   FileCheck %s --check-prefix=INVALIDAA
37; INVALIDAA: unknown alias analysis name 'patatino'
38