forked from OSchip/llvm-project
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. llvm-svn: 101877
This commit is contained in:
parent
23030c9004
commit
9cffdf1331
|
@ -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 |
|
||||
|
|
|
@ -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() {}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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]; };
|
||||
|
|
|
@ -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*)
|
||||
|
|
|
@ -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();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue