r284150 - Swift Calling Convention: Fix out of bounds access
Arnold Schwaighofer via cfe-commits
cfe-commits at lists.llvm.org
Thu Oct 13 12:19:38 PDT 2016
Author: arnolds
Date: Thu Oct 13 14:19:37 2016
New Revision: 284150
URL: http://llvm.org/viewvc/llvm-project?rev=284150&view=rev
Log:
Swift Calling Convention: Fix out of bounds access
Use iterator instead of address of element in vector
It is not valid to access one after the last element.
rdar://28759508
Modified:
cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
cfe/trunk/test/CodeGen/64bit-swiftcall.c
Modified: cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp?rev=284150&r1=284149&r2=284150&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp (original)
+++ cfe/trunk/lib/CodeGen/SwiftCallingConv.cpp Thu Oct 13 14:19:37 2016
@@ -384,7 +384,7 @@ void SwiftAggLowering::splitVectorEntry(
auto eltTy = split.first;
CharUnits eltSize = getTypeStoreSize(CGM, eltTy);
auto numElts = split.second;
- Entries.insert(&Entries[index + 1], numElts - 1, StorageEntry());
+ Entries.insert(Entries.begin() + index + 1, numElts - 1, StorageEntry());
CharUnits begin = Entries[index].Begin;
for (unsigned i = 0; i != numElts; ++i) {
Modified: cfe/trunk/test/CodeGen/64bit-swiftcall.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/64bit-swiftcall.c?rev=284150&r1=284149&r2=284150&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/64bit-swiftcall.c (original)
+++ cfe/trunk/test/CodeGen/64bit-swiftcall.c Thu Oct 13 14:19:37 2016
@@ -694,3 +694,22 @@ typedef struct {
TEST(struct_l5)
// CHECK: define swiftcc void @return_struct_l5([[STRUCT5:%.*]]* noalias sret
// CHECK: define swiftcc void @take_struct_l5([[STRUCT5]]*
+
+
+// Don't crash.
+typedef union {
+int4 v[2];
+struct {
+ int LSW;
+ int d7;
+ int d6;
+ int d5;
+ int d4;
+ int d3;
+ int d2;
+ int MSW;
+} s;
+} union_het_vecint;
+TEST(union_het_vecint)
+// CHECK: define swiftcc void @return_union_het_vecint([[UNION:%.*]]* noalias sret
+// CHECK: define swiftcc void @take_union_het_vecint([[UNION]]*
More information about the cfe-commits
mailing list