From: Chris Lattner Date: Tue, 20 Apr 2010 05:44:43 +0000 (+0000) Subject: don't slap noalias attribute on stret result arguments. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fb97cf24158aa7f1fd74374052f99733ef331bb9;p=clang don't slap noalias attribute on stret result arguments. This mirror's Dan's patch for llvm-gcc in r97989, and fixes the miscompilation in PR6525. There is some contention over whether this is the right thing to do, but it is the conservative answer and demonstrably fixes a miscompilation. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@101877 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/CodeGen/CGCall.cpp b/lib/CodeGen/CGCall.cpp index 145d693649..8b5c3a0f6c 100644 --- a/lib/CodeGen/CGCall.cpp +++ b/lib/CodeGen/CGCall.cpp @@ -586,8 +586,7 @@ void CodeGenModule::ConstructAttributeList(const CGFunctionInfo &FI, case ABIArgInfo::Indirect: PAL.push_back(llvm::AttributeWithIndex::get(Index, - llvm::Attribute::StructRet | - llvm::Attribute::NoAlias)); + llvm::Attribute::StructRet)); ++Index; // sret disables readnone and readonly FuncAttrs &= ~(llvm::Attribute::ReadOnly | diff --git a/test/CodeGen/arm-arguments.c b/test/CodeGen/arm-arguments.c index d313a9b331..cc5af89a6a 100644 --- a/test/CodeGen/arm-arguments.c +++ b/test/CodeGen/arm-arguments.c @@ -28,13 +28,13 @@ struct s4 { struct s4_0 { int f0; } f0; }; struct s4 f4(void) {} // APCS-GNU: define arm_apcscc void @f5( -// APCS-GNU: struct.s5* noalias sret +// APCS-GNU: struct.s5* sret // AAPCS: define arm_aapcscc i32 @f5() struct s5 { struct { } f0; int f1; }; struct s5 f5(void) {} // APCS-GNU: define arm_apcscc void @f6( -// APCS-GNU: struct.s6* noalias sret +// APCS-GNU: struct.s6* sret // AAPCS: define arm_aapcscc i32 @f6() struct s6 { int f0[1]; }; struct s6 f6(void) {} @@ -45,7 +45,7 @@ struct s7 { struct { int : 0; } f0; }; struct s7 f7(void) {} // APCS-GNU: define arm_apcscc void @f8( -// APCS-GNU: struct.s8* noalias sret +// APCS-GNU: struct.s8* sret // AAPCS: define arm_aapcscc void @f8() struct s8 { struct { int : 0; } f0[1]; }; struct s8 f8(void) {} @@ -61,7 +61,7 @@ struct s10 { int f0; int : 0; int : 0; }; struct s10 f10(void) {} // APCS-GNU: define arm_apcscc void @f11( -// APCS-GNU: struct.s10* noalias sret +// APCS-GNU: struct.s10* sret // AAPCS: define arm_aapcscc i32 @f11() struct s11 { int : 0; int f0; }; struct s11 f11(void) {} @@ -72,7 +72,7 @@ union u12 { char f0; short f1; int f2; }; union u12 f12(void) {} // APCS-GNU: define arm_apcscc void @f13( -// APCS-GNU: struct.s13* noalias sret +// APCS-GNU: struct.s13* sret // FIXME: This should return a float. // AAPCS-FIXME: define arm_aapcscc float @f13() @@ -80,7 +80,7 @@ struct s13 { float f0; }; struct s13 f13(void) {} // APCS-GNU: define arm_apcscc void @f14( -// APCS-GNU: struct.s13* noalias sret +// APCS-GNU: struct.s13* sret // AAPCS: define arm_aapcscc i32 @f14() union u14 { float f0; }; union u14 f14(void) {} @@ -104,13 +104,13 @@ struct s18 { short f0; char f1 : 4; }; struct s18 f18(void) {} // APCS-GNU: define arm_apcscc void @f19( -// APCS-GNU: struct.s19* noalias sret +// APCS-GNU: struct.s19* sret // AAPCS: define arm_aapcscc i32 @f19() struct s19 { int f0; struct s8 f1; }; struct s19 f19(void) {} // APCS-GNU: define arm_apcscc void @f20( -// APCS-GNU: struct.s20* noalias sret +// APCS-GNU: struct.s20* sret // AAPCS: define arm_aapcscc i32 @f20() struct s20 { struct s8 f1; int f0; }; struct s20 f20(void) {} @@ -128,10 +128,10 @@ struct s21 f21(void) {} // APCS-GNU: define arm_apcscc i128 @f27() // AAPCS: define arm_aapcscc i16 @f22() // AAPCS: define arm_aapcscc i32 @f23() -// AAPCS: define arm_aapcscc void @f24({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f25({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f26({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f27({{.*}} noalias sret +// AAPCS: define arm_aapcscc void @f24({{.*}} sret +// AAPCS: define arm_aapcscc void @f25({{.*}} sret +// AAPCS: define arm_aapcscc void @f26({{.*}} sret +// AAPCS: define arm_aapcscc void @f27({{.*}} sret _Complex char f22(void) {} _Complex short f23(void) {} _Complex int f24(void) {} @@ -149,7 +149,7 @@ struct s28 f28() {} struct s29 { _Complex short f0; }; struct s29 f29() {} -// APCS-GNU: define arm_apcscc void @f30({{.*}} noalias sret -// AAPCS: define arm_aapcscc void @f30({{.*}} noalias sret +// APCS-GNU: define arm_apcscc void @f30({{.*}} sret +// AAPCS: define arm_aapcscc void @f30({{.*}} sret struct s30 { _Complex int f0; }; struct s30 f30() {} diff --git a/test/CodeGen/blocks.c b/test/CodeGen/blocks.c index 0ef10c14e0..e7625b1954 100644 --- a/test/CodeGen/blocks.c +++ b/test/CodeGen/blocks.c @@ -12,7 +12,7 @@ struct s0 { int a[64]; }; -// RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* noalias sret .*, .*, .* byval .*)' %t +// RUN: grep 'internal void @__f2_block_invoke_(.struct.s0\* sret .*, .*, .* byval .*)' %t struct s0 f2(struct s0 a0) { return ^(struct s0 a1){ return a1; }(a0); } diff --git a/test/CodeGen/struct-passing.c b/test/CodeGen/struct-passing.c index b351d8148e..409d14e22d 100644 --- a/test/CodeGen/struct-passing.c +++ b/test/CodeGen/struct-passing.c @@ -1,8 +1,8 @@ // RUN: %clang_cc1 -triple i386-pc-linux-gnu -emit-llvm -o %t %s // RUN: grep 'declare i32 @f0() readnone$' %t // RUN: grep 'declare i32 @f1() readonly$' %t -// RUN: grep 'declare void @f2(.* noalias sret)$' %t -// RUN: grep 'declare void @f3(.* noalias sret)$' %t +// RUN: grep 'declare void @f2(.* sret)$' %t +// RUN: grep 'declare void @f3(.* sret)$' %t // RUN: grep 'declare void @f4(.* byval)$' %t // RUN: grep 'declare void @f5(.* byval)$' %t // PR3835 diff --git a/test/CodeGen/x86_32-arguments.c b/test/CodeGen/x86_32-arguments.c index eb98e1a228..b24d833fc2 100644 --- a/test/CodeGen/x86_32-arguments.c +++ b/test/CodeGen/x86_32-arguments.c @@ -72,7 +72,7 @@ struct s10 { // Small vectors and 1 x {i64,double} are returned in registers // RUN: grep 'i32 @f11()' %t -// RUN: grep -F 'void @f12(<2 x i32>* noalias sret %agg.result)' %t +// RUN: grep -F 'void @f12(<2 x i32>* sret %agg.result)' %t // RUN: grep 'i64 @f13()' %t // RUN: grep 'i64 @f14()' %t // RUN: grep '<2 x i64> @f15()' %t @@ -94,11 +94,11 @@ T16 f16(void) { while (1) {} } // 128-bits). // RUN: grep 'i32 @f17()' %t -// RUN: grep -F 'void @f18(%2* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f19(%3* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f20(%4* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f21(%5* noalias sret %agg.result)' %t -// RUN: grep -F 'void @f22(%6* noalias sret %agg.result)' %t +// RUN: grep -F 'void @f18(%2* sret %agg.result)' %t +// RUN: grep -F 'void @f19(%3* sret %agg.result)' %t +// RUN: grep -F 'void @f20(%4* sret %agg.result)' %t +// RUN: grep -F 'void @f21(%5* sret %agg.result)' %t +// RUN: grep -F 'void @f22(%6* sret %agg.result)' %t struct { T11 a; } f17(void) { while (1) {} } struct { T12 a; } f18(void) { while (1) {} } struct { T13 a; } f19(void) { while (1) {} } @@ -117,11 +117,11 @@ struct { struct {} a; struct { float a[1]; } b; } f25(void) { while (1) {} } // Small structures are handled recursively // RUN: grep -F 'i32 @f26()' %t -// RUN: grep 'void @f27(%.truct.s27\* noalias sret %agg.result)' %t +// RUN: grep 'void @f27(%.truct.s27\* sret %agg.result)' %t struct s26 { struct { char a, b; } a; struct { char a, b; } b; } f26(void) { while (1) {} } struct s27 { struct { char a, b, c; } a; struct { char a; } b; } f27(void) { while (1) {} } -// RUN: grep 'void @f28(%.truct.s28\* noalias sret %agg.result)' %t +// RUN: grep 'void @f28(%.truct.s28\* sret %agg.result)' %t struct s28 { int a; int b[]; } f28(void) { while (1) {} } // RUN: grep 'define i16 @f29()' %t @@ -151,7 +151,7 @@ struct s36 { struct { int : 0; } a[2][10]; char b; char c; } f36(void) { while ( // RUN: grep 'define float @f37()' %t struct s37 { float c[1][1]; } f37(void) { while (1) {} } -// RUN: grep 'define void @f38(.struct.s38. noalias sret .agg.result)' %t +// RUN: grep 'define void @f38(.struct.s38. sret .agg.result)' %t struct s38 { char a[3]; short b; } f38(void) { while (1) {} } // RUN: grep 'define void @f39(.struct.s39. byval align 16 .x)' %t diff --git a/test/CodeGen/x86_64-arguments.c b/test/CodeGen/x86_64-arguments.c index d6b9b29360..f34f212a2b 100644 --- a/test/CodeGen/x86_64-arguments.c +++ b/test/CodeGen/x86_64-arguments.c @@ -58,7 +58,7 @@ struct s9 { int a; int b; int : 0; } f9(void) { while (1) {} } struct s10 { int a; int b; int : 0; }; void f10(struct s10 a0) {} -// RUN: grep 'define void @f11(.union.anon. noalias sret .agg.result)' %t +// RUN: grep 'define void @f11(.union.anon. sret .agg.result)' %t union { long double a; float b; } f11() { while (1) {} } // RUN: grep 'define i64 @f12_0()' %t @@ -69,7 +69,7 @@ void f12_1(struct s12 a0) {} // Check that sret parameter is accounted for when checking available integer // registers. -// RUN: grep 'define void @f13(.struct.s13_0. noalias sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t +// RUN: grep 'define void @f13(.struct.s13_0. sret .agg.result, i32 .a, i32 .b, i32 .c, i32 .d, .struct.s13_1. byval .e, i32 .f)' %t struct s13_0 { long long f0[3]; }; struct s13_1 { long long f0[2]; }; diff --git a/test/CodeGenCXX/x86_32-arguments.cpp b/test/CodeGenCXX/x86_32-arguments.cpp index d13c0e4888..f8d655145b 100644 --- a/test/CodeGenCXX/x86_32-arguments.cpp +++ b/test/CodeGenCXX/x86_32-arguments.cpp @@ -6,7 +6,7 @@ struct S { int s; }; -// CHECK: define void @_Z1fv(%struct.S* noalias sret % +// CHECK: define void @_Z1fv(%struct.S* sret % S f() { return S(); } // CHECK: define void @_Z1f1S(%struct.S*) void f(S) { } @@ -17,7 +17,7 @@ class C { double c; }; -// CHECK: define void @_Z1gv(%class.C* noalias sret % +// CHECK: define void @_Z1gv(%class.C* sret % C g() { return C(); } // CHECK: define void @_Z1f1C(%class.C*) diff --git a/test/CodeGenObjC/x86_64-struct-return-gc.m b/test/CodeGenObjC/x86_64-struct-return-gc.m index 32a321c0b7..c62a33f2d1 100644 --- a/test/CodeGenObjC/x86_64-struct-return-gc.m +++ b/test/CodeGenObjC/x86_64-struct-return-gc.m @@ -25,7 +25,7 @@ struct Indirect indirect_func(void); void Indirect_test(void) { struct Indirect i; - // CHECK: call void @indirect_func(%struct.Indirect* noalias sret + // CHECK: call void @indirect_func(%struct.Indirect* sret // CHECK: call i8* @objc_memmove_collectable( i = indirect_func(); }