120faf789Smodimo; REQUIRES: x86-registered-target
220faf789Smodimo
320faf789Smodimo; Test that FunctionAttr Propagation is generating correct summaries
420faf789Smodimo
520faf789Smodimo; RUN: split-file %s %t
620faf789Smodimo; RUN: opt -module-summary %t/a.ll -o %t/a.bc
720faf789Smodimo; RUN: opt -module-summary %t/b.ll -o %t/b.bc
820faf789Smodimo
920faf789Smodimo; RUN: llvm-lto2 run -disable-thinlto-funcattrs=0 %t/a.bc %t/b.bc -o %t1.o -save-temps \
1020faf789Smodimo; RUN:   -r=%t/a.bc,call_extern,plx \
1120faf789Smodimo; RUN:   -r=%t/a.bc,extern, \
1220faf789Smodimo; RUN:   -r=%t/b.bc,extern,p
1320faf789Smodimo
1420faf789Smodimo; RUN: llvm-dis %t1.o.index.bc -o - | FileCheck %s --check-prefix=CHECK-INDEX
1520faf789Smodimo; RUN: llvm-dis %t1.o.1.1.promote.bc -o - | FileCheck %s --check-prefix=CHECK-IR
1620faf789Smodimo
1720faf789Smodimo;; Summary for call_extern. Note that llvm-lto2 writes out the index before propagation occurs so call_extern doesn't have its flags updated.
1820faf789Smodimo; CHECK-INDEX: ^2 = gv: (guid: 13959900437860518209, summaries: (function: (module: ^0, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 1, canAutoHide: 0), insts: 2, calls: ((callee: ^3)))))
1920faf789Smodimo;; Summary for extern
20*09a704c5SMingming Liu; CHECK-INDEX: ^3 = gv: (guid: 14959766916849974397, summaries: (function: (module: ^1, flags: (linkage: external, visibility: default, notEligibleToImport: 0, live: 1, dsoLocal: 0, canAutoHide: 0), insts: 1, funcFlags: (readNone: 0, readOnly: 0, noRecurse: 1, returnDoesNotAlias: 0, noInline: 0, alwaysInline: 0, noUnwind: 1, mayThrow: 0, hasUnknownCall: 0, mustBeUnreachable: 0))))
2120faf789Smodimo
2220faf789Smodimo;--- a.ll
2320faf789Smodimotarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
2420faf789Smodimotarget triple = "x86_64-unknown-linux-gnu"
2520faf789Smodimo
2620faf789Smodimodeclare void @extern()
2720faf789Smodimo
2820faf789Smodimo; CHECK-IR: Function Attrs: norecurse nounwind
2920faf789Smodimo; CHECK-IR-NEXT: define dso_local void @call_extern()
3020faf789Smodimodefine void @call_extern() {
3120faf789Smodimo    call void @extern()
3220faf789Smodimo    ret void
3320faf789Smodimo}
3420faf789Smodimo
3520faf789Smodimo;--- b.ll
3620faf789Smodimotarget datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
3720faf789Smodimotarget triple = "x86_64-unknown-linux-gnu"
3820faf789Smodimo
3920faf789Smodimoattributes #0 = { nounwind norecurse }
4020faf789Smodimo
4120faf789Smodimodefine void @extern() #0 {
4220faf789Smodimo  ret void
4320faf789Smodimo}
44