]> granicus.if.org Git - clang/commitdiff
don't slap noalias attribute on stret result arguments.
authorChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 05:44:43 +0000 (05:44 +0000)
committerChris Lattner <sabre@nondot.org>
Tue, 20 Apr 2010 05:44:43 +0000 (05:44 +0000)
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

lib/CodeGen/CGCall.cpp
test/CodeGen/arm-arguments.c
test/CodeGen/blocks.c
test/CodeGen/struct-passing.c
test/CodeGen/x86_32-arguments.c
test/CodeGen/x86_64-arguments.c
test/CodeGenCXX/x86_32-arguments.cpp
test/CodeGenObjC/x86_64-struct-return-gc.m

index 145d693649b5f41eca23869c9cfcbde501c584d2..8b5c3a0f6c46de0d6d20d8b62b8aceabff6b8c2d 100644 (file)
@@ -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 |
index d313a9b3310f68e9b6876dabd7eac33fd6c0959e..cc5af89a6aa4f1d52b96760bf9f8c053220c4007 100644 (file)
@@ -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() {}
index 0ef10c14e009207f194bd28a7087d0217678fce8..e7625b19542cda3e30cb4a1b521dfa69d0e54942 100644 (file)
@@ -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);
 }
index b351d8148e9104cb8226b3439d3427e69ada91d9..409d14e22d39a7a7c0cd287c007a4d39349c1c14 100644 (file)
@@ -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
index eb98e1a2282a85e4fbae8329359ef44a9b2c910f..b24d833fc2346a8b3a0b0dfd41a1935721d484c8 100644 (file)
@@ -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
index d6b9b2936045f8b7ccb2f97a3e1783bb3b69160e..f34f212a2badcb1360347533558ecd53b6603d02 100644 (file)
@@ -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]; };
index d13c0e4888fd24080878d275932d274dd4c25274..f8d655145b8f008032967feb78aac78b8b4e8e3c 100644 (file)
@@ -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*) 
index 32a321c0b7d013d8a8a1d707bf863f31e94924b1..c62a33f2d1622d6768dd8e8508299c1905f3a0fb 100644 (file)
@@ -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();
 }