[llvm-branch-commits] [llvm-branch] r239611 - Merging r236457 and r236635:

Tim Northover tnorthover at apple.com
Fri Jun 12 08:57:36 PDT 2015


Author: tnorthover
Date: Fri Jun 12 10:57:35 2015
New Revision: 239611

URL: http://llvm.org/viewvc/llvm-project?rev=239611&view=rev
Log:
Merging r236457 and r236635:

------------------------------------------------------------------------
r236457 | tnorthover | 2015-05-04 13:41:51 -0700 (Mon, 04 May 2015) |
9 lines

CodeGen: match up correct insertvalue indices when assessing tail
calls.

When deciding whether a value comes from the aggregate or inserted
value of an insertvalue instruction, we compare the indices against
those of the location we're interested in. One of the lists needs
reversing because the input data is backwards (so that modifications
take place at the end of the SmallVector), but we were reversing both
before leading to incorrect results.

------------------------------------------------------------------------
r236635 | tnorthover | 2015-05-06 13:07:38 -0700 (Wed, 06 May 2015) |
12 lines

CodeGen: move over-zealous assert into actual if statement.

It's quite possible to encounter an insertvalue instruction that's
more deeply nested than the value we're looking for, but when that
happens we really mustn't compare beyond the end of the index array.

Since I couldn't see any guarantees about what comparisons std::equal
makes, we probably need to directly check the size beforehand. In
practice, I suspect most std::equal implementations would probably
bail early, which would be OK.  But just in case...

rdar://20834485



Modified:
    llvm/branches/release_36/   (props changed)
    llvm/branches/release_36/lib/CodeGen/Analysis.cpp
    llvm/branches/release_36/test/CodeGen/AArch64/tail-call.ll

Propchange: llvm/branches/release_36/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Fri Jun 12 10:57:35 2015
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,226023,226029,226044,226046,226048,226058,226075,226151,226164-226166,226170-226171,226182,226407-226409,226473,226588,226616,226652,226664,226708,226711,226755,226791,226808-226809,226905,227005,227084-227085,227087,227089,227250,227260-227261,227269,227290,227294,227299,227319,227339,227430,227491,227584,227603,227628,227670,227809,227815,227903,227934,227972,227983,228049,228129,228168,228331,228403,228411,228444,228490,228500,228507,228518,228525,228565,228656,228760-228761,228793,228842,228899,228957,228969,228979,229029,229343,229351-229352,229421,229495,229529,229731,229911,230058,230235,230500,230657,230742,230748,230956,231219,231227,231237,231563,231601,232046,232085,232189,232382,233904
+/llvm/trunk:155241,226023,226029,226044,226046,226048,226058,226075,226151,226164-226166,226170-226171,226182,226407-226409,226473,226588,226616,226652,226664,226708,226711,226755,226791,226808-226809,226905,227005,227084-227085,227087,227089,227250,227260-227261,227269,227290,227294,227299,227319,227339,227430,227491,227584,227603,227628,227670,227809,227815,227903,227934,227972,227983,228049,228129,228168,228331,228403,228411,228444,228490,228500,228507,228518,228525,228565,228656,228760-228761,228793,228842,228899,228957,228969,228979,229029,229343,229351-229352,229421,229495,229529,229731,229911,230058,230235,230500,230657,230742,230748,230956,231219,231227,231237,231563,231601,232046,232085,232189,232382,233904,236457,236635

Modified: llvm/branches/release_36/lib/CodeGen/Analysis.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/lib/CodeGen/Analysis.cpp?rev=239611&r1=239610&r2=239611&view=diff
==============================================================================
--- llvm/branches/release_36/lib/CodeGen/Analysis.cpp (original)
+++ llvm/branches/release_36/lib/CodeGen/Analysis.cpp Fri Jun 12 10:57:35 2015
@@ -295,8 +295,8 @@ static const Value *getNoopInput(const V
     } else if (const InsertValueInst *IVI = dyn_cast<InsertValueInst>(V)) {
       // Value may come from either the aggregate or the scalar
       ArrayRef<unsigned> InsertLoc = IVI->getIndices();
-      if (std::equal(InsertLoc.rbegin(), InsertLoc.rend(),
-                     ValLoc.rbegin())) {
+      if (ValLoc.size() >= InsertLoc.size() &&
+          std::equal(InsertLoc.begin(), InsertLoc.end(), ValLoc.rbegin())) {
         // The type being inserted is a nested sub-type of the aggregate; we
         // have to remove those initial indices to get the location we're
         // interested in for the operand.

Modified: llvm/branches/release_36/test/CodeGen/AArch64/tail-call.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_36/test/CodeGen/AArch64/tail-call.ll?rev=239611&r1=239610&r2=239611&view=diff
==============================================================================
--- llvm/branches/release_36/test/CodeGen/AArch64/tail-call.ll (original)
+++ llvm/branches/release_36/test/CodeGen/AArch64/tail-call.ll Fri Jun 12 10:57:35 2015
@@ -103,3 +103,41 @@ define fastcc void @caller_weak() {
   tail call void @callee_weak()
   ret void
 }
+
+declare { [2 x float] } @get_vec2()
+
+define { [3 x float] } @test_add_elem() {
+; CHECK-LABEL: test_add_elem:
+; CHECK: bl get_vec2
+; CHECK: fmov s2, #1.0
+; CHECK: ret
+
+  %call = tail call { [2 x float] } @get_vec2()
+  %arr = extractvalue { [2 x float] } %call, 0
+  %arr.0 = extractvalue [2 x float] %arr, 0
+  %arr.1 = extractvalue [2 x float] %arr, 1
+
+  %res.0 = insertvalue { [3 x float] } undef, float %arr.0, 0, 0
+  %res.01 = insertvalue { [3 x float] } %res.0, float %arr.1, 0, 1
+  %res.012 = insertvalue { [3 x float] } %res.01, float 1.000000e+00, 0, 2
+  ret { [3 x float] } %res.012
+}
+
+declare double @get_double()
+define { double, [2 x double] } @test_mismatched_insert() {
+; CHECK-LABEL: test_mismatched_insert:
+; CHECK: bl get_double
+; CHECK: bl get_double
+; CHECK: bl get_double
+; CHECK: ret
+
+  %val0 = call double @get_double()
+  %val1 = call double @get_double()
+  %val2 = tail call double @get_double()
+
+  %res.0 = insertvalue { double, [2 x double] } undef, double %val0, 0
+  %res.01 = insertvalue { double, [2 x double] } %res.0, double %val1, 1, 0
+  %res.012 = insertvalue { double, [2 x double] } %res.01, double %val2, 1, 1
+
+  ret { double, [2 x double] } %res.012
+}





More information about the llvm-branch-commits mailing list