Modify the LLVM assembly output so that it uses references to represent function attributes.

This makes the LLVM assembly look better. E.g.:

     define void @foo() #0 { ret void }
     attributes #0 = { nounwind noinline ssp }

llvm-svn: 175605
diff --git a/llvm/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll b/llvm/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
index d81c8bd..2387a10 100644
--- a/llvm/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
+++ b/llvm/test/Transforms/ArgumentPromotion/2008-02-01-ReturnAttrs.ll
@@ -1,6 +1,6 @@
 ; RUN: opt < %s -argpromotion -S | FileCheck %s
 
-; CHECK: define internal i32 @deref(i32 %x.val) nounwind {
+; CHECK: define internal i32 @deref(i32 %x.val) #0 {
 define internal i32 @deref(i32* %x) nounwind {
 entry:
   %tmp2 = load i32* %x, align 4
@@ -15,3 +15,5 @@
   %tmp1 = call i32 @deref( i32* %x_addr ) nounwind
   ret i32 %tmp1
 }
+
+; CHECK: attributes #0 = { nounwind }
diff --git a/llvm/test/Transforms/BBVectorize/simple-int.ll b/llvm/test/Transforms/BBVectorize/simple-int.ll
index d7b7d6b..e4d5152 100644
--- a/llvm/test/Transforms/BBVectorize/simple-int.ll
+++ b/llvm/test/Transforms/BBVectorize/simple-int.ll
@@ -124,8 +124,10 @@
 ; CHECK: ret double %R
 }
 
-; CHECK: declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) nounwind readnone
-; CHECK: declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) nounwind readnone
-; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) nounwind readonly
-; CHECK: declare <2 x double> @llvm.powi.v2f64(<2 x double>, i32) nounwind readonly
+; CHECK: declare <2 x double> @llvm.fma.v2f64(<2 x double>, <2 x double>, <2 x double>) #0
+; CHECK: declare <2 x double> @llvm.fmuladd.v2f64(<2 x double>, <2 x double>, <2 x double>) #0
+; CHECK: declare <2 x double> @llvm.cos.v2f64(<2 x double>) #1
+; CHECK: declare <2 x double> @llvm.powi.v2f64(<2 x double>, i32) #1
 
+; CHECK: attributes #0 = { nounwind readnone }
+; CHECK: attributes #1 = { nounwind readonly }
diff --git a/llvm/test/Transforms/DeadArgElim/2007-12-20-ParamAttrs.ll b/llvm/test/Transforms/DeadArgElim/2007-12-20-ParamAttrs.ll
index 20b5da5..72a269b 100644
--- a/llvm/test/Transforms/DeadArgElim/2007-12-20-ParamAttrs.ll
+++ b/llvm/test/Transforms/DeadArgElim/2007-12-20-ParamAttrs.ll
@@ -4,7 +4,7 @@
 
 @g = global i8 0
 
-; CHECK: define internal void @foo(i8 signext %y) nounwind
+; CHECK: define internal void @foo(i8 signext %y) #0
 
 define internal zeroext i8 @foo(i8* inreg %p, i8 signext %y, ... )  nounwind {
   store i8 %y, i8* @g
@@ -16,3 +16,5 @@
   %A = call zeroext i8(i8*, i8, ...)* @foo(i8* inreg null, i8 signext 1, %struct* byval null ) nounwind
   ret i32 0
 }
+
+; CHECK: attributes #0 = { nounwind }
diff --git a/llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll b/llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
index 2f820ba..fc63da1 100644
--- a/llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
+++ b/llvm/test/Transforms/DeadArgElim/2010-04-30-DbgInfo.ll
@@ -15,7 +15,7 @@
 
 declare void @llvm.dbg.declare(metadata, metadata) nounwind readnone
 
-define internal fastcc i8* @add_name_internal(i8* %name, i32 %len, i32 %hash, i8 zeroext %extra, i32 %flags) nounwind noinline ssp {
+define internal fastcc i8* @add_name_internal(i8* %name, i32 %len, i32 %hash, i8 zeroext %extra, i32 %flags) noinline nounwind ssp {
 entry:
   call void @llvm.dbg.value(metadata !{i8* %name}, i64 0, metadata !15)
   call void @llvm.dbg.value(metadata !{i32 %len}, i64 0, metadata !20)
@@ -38,6 +38,10 @@
 
 declare void @llvm.dbg.value(metadata, i64, metadata) nounwind readnone
 
+; CHECK: attributes #0 = { nounwind ssp }
+; CHECK: attributes #1 = { nounwind readnone }
+; CHECK: attributes #2 = { noinline nounwind ssp }
+
 !0 = metadata !{i32 524545, metadata !1, metadata !"name", metadata !2, i32 8, metadata !6} ; [ DW_TAG_arg_variable ]
 !1 = metadata !{i32 524334, i32 0, metadata !2, metadata !"vfs_addname", metadata !"vfs_addname", metadata !"vfs_addname", metadata !2, i32 12, metadata !4, i1 false, i1 true, i32 0, i32 0, null, i1 false} ; [ DW_TAG_subprogram ]
 !2 = metadata !{i32 524329, metadata !"tail.c", metadata !"/Users/echeng/LLVM/radars/r7927803/", metadata !3} ; [ DW_TAG_file_type ]
diff --git a/llvm/test/Transforms/DeadArgElim/keepalive.ll b/llvm/test/Transforms/DeadArgElim/keepalive.ll
index dc92dc9..e41110c 100644
--- a/llvm/test/Transforms/DeadArgElim/keepalive.ll
+++ b/llvm/test/Transforms/DeadArgElim/keepalive.ll
@@ -1,6 +1,4 @@
-; RUN: opt < %s -deadargelim -S > %t
-; RUN: grep "define internal zeroext i32 @test1() nounwind" %t
-; RUN: grep "define internal <{ i32, i32 }> @test2" %t
+; RUN: opt < %s -deadargelim -S | FileCheck %s
 
 %Ty = type <{ i32, i32 }>
 
@@ -9,11 +7,13 @@
 ; the function and then changing too much.
 
 ; This checks if the return value attributes are not removed
+; CHECK: define internal zeroext i32 @test1() #0
 define internal zeroext i32 @test1(i32 %DEADARG1) nounwind {
         ret i32 1
 }
 
 ; This checks if the struct doesn't get non-packed
+; CHECK: define internal <{ i32, i32 }> @test2
 define internal <{ i32, i32 }> @test2(i32 %DEADARG1) {
         ret <{ i32, i32 }> <{ i32 1, i32 2 }>
 }
@@ -28,3 +28,4 @@
         ret void
 }
 
+; CHECK: attributes #0 = { nounwind }
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
index 2e88a13..36a7658 100644
--- a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadNone.ll
@@ -1,22 +1,24 @@
 ; RUN: opt < %s -basicaa -functionattrs -S | FileCheck %s
 @x = global i32 0
 
-; CHECK: declare i32 @e() readnone
+; CHECK: declare i32 @e() #0
 declare i32 @e() readnone
 
-; CHECK: define i32 @f() readnone
+; CHECK: define i32 @f() #0
 define i32 @f() {
 	%tmp = call i32 @e( )		; <i32> [#uses=1]
 	ret i32 %tmp
 }
 
-; CHECK: define i32 @g() readnone
+; CHECK: define i32 @g() #0
 define i32 @g() readonly {
 	ret i32 0
 }
 
-; CHECK: define i32 @h() readnone
+; CHECK: define i32 @h() #0
 define i32 @h() readnone {
 	%tmp = load i32* @x		; <i32> [#uses=1]
 	ret i32 %tmp
 }
+
+; CHECK: attributes #0 = { readnone }
diff --git a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
index 0b03fc8..d8256ae 100644
--- a/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
+++ b/llvm/test/Transforms/FunctionAttrs/2008-09-03-ReadOnly.ll
@@ -1,11 +1,13 @@
 ; RUN: opt < %s -basicaa -functionattrs -S | FileCheck %s
 
-; CHECK: define i32 @f() readonly
+; CHECK: define i32 @f() #0
 define i32 @f() {
 entry:
   %tmp = call i32 @e( )
   ret i32 %tmp
 }
 
-; CHECK: declare i32 @e() readonly
+; CHECK: declare i32 @e() #0
 declare i32 @e() readonly
+
+; CHECK: attributes #0 = { readonly }
diff --git a/llvm/test/Transforms/FunctionAttrs/atomic.ll b/llvm/test/Transforms/FunctionAttrs/atomic.ll
index df916e2..027ee0f 100644
--- a/llvm/test/Transforms/FunctionAttrs/atomic.ll
+++ b/llvm/test/Transforms/FunctionAttrs/atomic.ll
@@ -3,7 +3,7 @@
 ; Atomic load/store to local doesn't affect whether a function is
 ; readnone/readonly.
 define i32 @test1(i32 %x) uwtable ssp {
-; CHECK: define i32 @test1(i32 %x) readnone ssp uwtable {
+; CHECK: define i32 @test1(i32 %x) #0 {
 entry:
   %x.addr = alloca i32, align 4
   store atomic i32 %x, i32* %x.addr seq_cst, align 4
@@ -13,9 +13,11 @@
 
 ; A function with an Acquire load is not readonly.
 define i32 @test2(i32* %x) uwtable ssp {
-; CHECK: define i32 @test2(i32* nocapture %x) ssp uwtable {
+; CHECK: define i32 @test2(i32* nocapture %x) #1 {
 entry:
   %r = load atomic i32* %x seq_cst, align 4
   ret i32 %r
 }
 
+; CHECK: attributes #0 = { readnone ssp uwtable }
+; CHECK: attributes #1 = { ssp uwtable }
diff --git a/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll b/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll
index 402ea41..ccbd91b 100644
--- a/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll
+++ b/llvm/test/Transforms/IPConstantProp/user-with-multiple-uses.ll
@@ -4,7 +4,7 @@
 ; IPSCCP should propagate the 0 argument, eliminate the switch, and propagate
 ; the result.
 
-; CHECK: define i32 @main() noreturn nounwind {
+; CHECK: define i32 @main() #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT: %call2 = tail call i32 @wwrite(i64 0) nounwind
 ; CHECK-NEXT: ret i32 123
@@ -28,3 +28,6 @@
 return:
   ret i32 0
 }
+
+; CHECK: attributes #0 = { noreturn nounwind }
+; CHECK: attributes #1 = { nounwind readnone }
diff --git a/llvm/test/Transforms/Inline/inline_ssp.ll b/llvm/test/Transforms/Inline/inline_ssp.ll
index e3835e0..a4b43a7 100644
--- a/llvm/test/Transforms/Inline/inline_ssp.ll
+++ b/llvm/test/Transforms/Inline/inline_ssp.ll
@@ -39,35 +39,35 @@
 
 define void @inline_req_req() nounwind sspreq uwtable {
 entry:
-; CHECK: @inline_req_req() nounwind sspreq uwtable 
+; CHECK: @inline_req_req() #0
   call void @fun_sspreq()
   ret void
 }
 
 define void @inline_req_strong() nounwind sspstrong uwtable {
 entry:
-; CHECK: @inline_req_strong() nounwind sspreq uwtable 
+; CHECK: @inline_req_strong() #0
   call void @fun_sspreq()
   ret void
 }
 
 define void @inline_req_ssp() nounwind ssp uwtable {
 entry:
-; CHECK: @inline_req_ssp() nounwind sspreq uwtable 
+; CHECK: @inline_req_ssp() #0
   call void @fun_sspreq()
   ret void
 }
 
 define void @inline_req_nossp() nounwind uwtable {
 entry:
-; CHECK: @inline_req_nossp() nounwind sspreq uwtable 
+; CHECK: @inline_req_nossp() #0
   call void @fun_sspreq()
   ret void
 }
 
 define void @inline_strong_req() nounwind sspreq uwtable {
 entry:
-; CHECK: @inline_strong_req() nounwind sspreq uwtable 
+; CHECK: @inline_strong_req() #0
   call void @fun_sspstrong()
   ret void
 }
@@ -75,28 +75,28 @@
 
 define void @inline_strong_strong() nounwind sspstrong uwtable {
 entry:
-; CHECK: @inline_strong_strong() nounwind sspstrong uwtable
+; CHECK: @inline_strong_strong() #1
   call void @fun_sspstrong()
   ret void
 }
 
 define void @inline_strong_ssp() nounwind ssp uwtable {
 entry:
-; CHECK: @inline_strong_ssp() nounwind sspstrong uwtable
+; CHECK: @inline_strong_ssp() #1
   call void @fun_sspstrong()
   ret void
 }
 
 define void @inline_strong_nossp() nounwind uwtable {
 entry:
-; CHECK: @inline_strong_nossp() nounwind sspstrong uwtable
+; CHECK: @inline_strong_nossp() #1
   call void @fun_sspstrong()
   ret void
 }
 
 define void @inline_ssp_req() nounwind sspreq uwtable {
 entry:
-; CHECK: @inline_ssp_req() nounwind sspreq uwtable
+; CHECK: @inline_ssp_req() #0
   call void @fun_ssp()
   ret void
 }
@@ -104,28 +104,28 @@
 
 define void @inline_ssp_strong() nounwind sspstrong uwtable {
 entry:
-; CHECK: @inline_ssp_strong() nounwind sspstrong uwtable
+; CHECK: @inline_ssp_strong() #1
   call void @fun_ssp()
   ret void
 }
 
 define void @inline_ssp_ssp() nounwind ssp uwtable {
 entry:
-; CHECK: @inline_ssp_ssp() nounwind ssp uwtable
+; CHECK: @inline_ssp_ssp() #2
   call void @fun_ssp()
   ret void
 }
 
 define void @inline_ssp_nossp() nounwind uwtable {
 entry:
-; CHECK: @inline_ssp_nossp() nounwind ssp uwtable
+; CHECK: @inline_ssp_nossp() #2
   call void @fun_ssp()
   ret void
 }
 
 define void @inline_nossp_req() nounwind uwtable sspreq {
 entry:
-; CHECK: @inline_nossp_req() nounwind sspreq uwtable
+; CHECK: @inline_nossp_req() #0
   call void @fun_nossp()
   ret void
 }
@@ -133,23 +133,28 @@
 
 define void @inline_nossp_strong() nounwind sspstrong uwtable {
 entry:
-; CHECK: @inline_nossp_strong() nounwind sspstrong uwtable
+; CHECK: @inline_nossp_strong() #1
   call void @fun_nossp()
   ret void
 }
 
 define void @inline_nossp_ssp() nounwind ssp uwtable {
 entry:
-; CHECK: @inline_nossp_ssp() nounwind ssp uwtable
+; CHECK: @inline_nossp_ssp() #2
   call void @fun_nossp()
   ret void
 }
 
 define void @inline_nossp_nossp() nounwind uwtable {
 entry:
-; CHECK: @inline_nossp_nossp() nounwind uwtable
+; CHECK: @inline_nossp_nossp() #3
   call void @fun_nossp()
   ret void
 }
 
 declare i32 @printf(i8*, ...)
+
+; CHECK: attributes #0 = { nounwind sspreq uwtable }
+; CHECK: attributes #1 = { nounwind sspstrong uwtable }
+; CHECK: attributes #2 = { nounwind ssp uwtable }
+; CHECK: attributes #3 = { nounwind uwtable }
diff --git a/llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll b/llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll
index 5a21672..4278ef1 100644
--- a/llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll
+++ b/llvm/test/Transforms/LoopDeletion/simplify-then-delete.ll
@@ -4,7 +4,7 @@
 ; Indvars and loop deletion should be able to eliminate all looping
 ; in this testcase.
 
-; CHECK:      define i32 @pmat(i32 %m, i32 %n, double* %y) nounwind {
+; CHECK:      define i32 @pmat(i32 %m, i32 %n, double* %y) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   ret i32 0
 ; CHECK-NEXT: }
@@ -63,3 +63,5 @@
 w.e12:
   ret i32 0
 }
+
+; CHECK: attributes #0 = { nounwind }
diff --git a/llvm/test/Transforms/ObjCARC/cfg-hazards.ll b/llvm/test/Transforms/ObjCARC/cfg-hazards.ll
index 1519423..58832b6 100644
--- a/llvm/test/Transforms/ObjCARC/cfg-hazards.ll
+++ b/llvm/test/Transforms/ObjCARC/cfg-hazards.ll
@@ -86,7 +86,7 @@
 
 ; Delete nested retain+release pairs around loops.
 
-;      CHECK: define void @test3(i8* %a) nounwind {
+;      CHECK: define void @test3(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   br label %loop
@@ -112,7 +112,7 @@
   ret void
 }
 
-;      CHECK: define void @test4(i8* %a) nounwind {
+;      CHECK: define void @test4(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   br label %loop
@@ -142,7 +142,7 @@
   ret void
 }
 
-;      CHECK: define void @test5(i8* %a) nounwind {
+;      CHECK: define void @test5(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   call void @callee()
@@ -176,7 +176,7 @@
   ret void
 }
 
-;      CHECK: define void @test6(i8* %a) nounwind {
+;      CHECK: define void @test6(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   br label %loop
@@ -209,7 +209,7 @@
   ret void
 }
 
-;      CHECK: define void @test7(i8* %a) nounwind {
+;      CHECK: define void @test7(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   call void @callee()
@@ -242,7 +242,7 @@
   ret void
 }
 
-;      CHECK: define void @test8(i8* %a) nounwind {
+;      CHECK: define void @test8(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   br label %loop
@@ -274,7 +274,7 @@
   ret void
 }
 
-;      CHECK: define void @test9(i8* %a) nounwind {
+;      CHECK: define void @test9(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   br label %loop
 ;  CHECK-NOT:   @objc_
@@ -303,7 +303,7 @@
   ret void
 }
 
-;      CHECK: define void @test10(i8* %a) nounwind {
+;      CHECK: define void @test10(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   br label %loop
 ;  CHECK-NOT:   @objc_
@@ -332,7 +332,7 @@
   ret void
 }
 
-;      CHECK: define void @test11(i8* %a) nounwind {
+;      CHECK: define void @test11(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   br label %loop
 ;  CHECK-NOT:   @objc_
@@ -362,7 +362,7 @@
 
 ; Don't delete anything if they're not balanced.
 
-;      CHECK: define void @test12(i8* %a) nounwind {
+;      CHECK: define void @test12(i8* %a) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   %outer = tail call i8* @objc_retain(i8* %a) nounwind
 ; CHECK-NEXT:   %inner = tail call i8* @objc_retain(i8* %a) nounwind
@@ -394,4 +394,6 @@
   ret void
 }
 
+; CHECK: attributes #0 = { nounwind }
+
 !0 = metadata !{}
diff --git a/llvm/test/Transforms/ObjCARC/weak-copies.ll b/llvm/test/Transforms/ObjCARC/weak-copies.ll
index e1a94bb..b576295 100644
--- a/llvm/test/Transforms/ObjCARC/weak-copies.ll
+++ b/llvm/test/Transforms/ObjCARC/weak-copies.ll
@@ -39,7 +39,7 @@
 
 ; Eliminate unnecessary weak pointer copies in a block initialization.
 
-; CHECK:      define void @qux(i8* %me) nounwind {
+; CHECK:      define void @qux(i8* %me) #0 {
 ; CHECK-NEXT: entry:
 ; CHECK-NEXT:   %block = alloca %1, align 8
 ; CHECK-NOT:    alloca
@@ -84,4 +84,6 @@
 declare void @use(i8*) nounwind
 declare void @objc_destroyWeak(i8**)
 
+; CHECK: attributes #0 = { nounwind }
+
 !0 = metadata !{}
diff --git a/llvm/test/Transforms/SimplifyLibCalls/2009-01-04-Annotate.ll b/llvm/test/Transforms/SimplifyLibCalls/2009-01-04-Annotate.ll
index f5f6d4c..16791e2 100644
--- a/llvm/test/Transforms/SimplifyLibCalls/2009-01-04-Annotate.ll
+++ b/llvm/test/Transforms/SimplifyLibCalls/2009-01-04-Annotate.ll
@@ -1,12 +1,12 @@
 ; RUN: opt < %s -simplify-libcalls -S | FileCheck %s
 
-; CHECK: declare noalias i8* @fopen(i8* nocapture, i8* nocapture) nounwind
+; CHECK: declare noalias i8* @fopen(i8* nocapture, i8* nocapture) #0
 declare i8* @fopen(i8*, i8*)
 
-; CHECK: declare i8 @strlen(i8* nocapture) nounwind readonly
+; CHECK: declare i8 @strlen(i8* nocapture) #1
 declare i8 @strlen(i8*)
 
-; CHECK: declare noalias i32* @realloc(i32* nocapture, i32) nounwind
+; CHECK: declare noalias i32* @realloc(i32* nocapture, i32) #0
 declare i32* @realloc(i32*, i32)
 
 ; Test deliberately wrong declaration
@@ -16,3 +16,6 @@
 ; CHECK-NOT: strcpy{{.*}}nocapture
 ; CHECK-NOT: strcpy{{.*}}nounwind
 ; CHECK-NOT: strcpy{{.*}}readonly
+
+; CHECK: attributes #0 = { nounwind }
+; CHECK: attributes #1 = { nounwind readonly }