[llvm-branch-commits] [llvm-branch] r261126 - Merging r259702:

David Majnemer via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Wed Feb 17 10:42:18 PST 2016


Author: majnemer
Date: Wed Feb 17 12:42:17 2016
New Revision: 261126

URL: http://llvm.org/viewvc/llvm-project?rev=261126&view=rev
Log:
Merging r259702:
------------------------------------------------------------------------
r259702 | majnemer | 2016-02-03 13:30:34 -0800 (Wed, 03 Feb 2016) | 7 lines

[LoopStrengthReduce] Don't rewrite PHIs with incoming values from CatchSwitches

Bail out if we have a PHI on an EHPad that gets a value from a
CatchSwitchInst.  Because the CatchSwitchInst cannot be split, there is
no good place to stick any instructions.

This fixes PR26373.
------------------------------------------------------------------------

Modified:
    llvm/branches/release_38/   (props changed)
    llvm/branches/release_38/include/llvm/IR/Instructions.h
    llvm/branches/release_38/lib/Transforms/Scalar/LoopStrengthReduce.cpp
    llvm/branches/release_38/test/Transforms/LoopStrengthReduce/funclet.ll

Propchange: llvm/branches/release_38/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Wed Feb 17 12:42:17 2016
@@ -1,3 +1,3 @@
 /llvm/branches/Apple/Pertwee:110850,110961
 /llvm/branches/type-system-rewrite:133420-134817
-/llvm/trunk:155241,257645,257648,257730,257775,257791,257864,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258103,258112,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259177-259178,259228,259236,259342,259346,259375,259381,259645,259649,259695-259696,259740,259798,259835,259840,259886,259888,259958,260164,260390,260427,260587,260641,260703,260733,261033
+/llvm/trunk:155241,257645,257648,257730,257775,257791,257864,257875,257886,257902,257905,257925,257929-257930,257940,257942,257977,257979,257997,258103,258112,258168,258184,258207,258221,258273,258325,258406,258416,258428,258436,258471,258690,258729,258891,258971,259177-259178,259228,259236,259342,259346,259375,259381,259645,259649,259695-259696,259702,259740,259798,259835,259840,259886,259888,259958,260164,260390,260427,260587,260641,260703,260733,261033

Modified: llvm/branches/release_38/include/llvm/IR/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/include/llvm/IR/Instructions.h?rev=261126&r1=261125&r2=261126&view=diff
==============================================================================
--- llvm/branches/release_38/include/llvm/IR/Instructions.h (original)
+++ llvm/branches/release_38/include/llvm/IR/Instructions.h Wed Feb 17 12:42:17 2016
@@ -2512,6 +2512,14 @@ public:
     return block_begin() + getNumOperands();
   }
 
+  iterator_range<block_iterator> blocks() {
+    return make_range(block_begin(), block_end());
+  }
+
+  iterator_range<const_block_iterator> blocks() const {
+    return make_range(block_begin(), block_end());
+  }
+
   op_range incoming_values() { return operands(); }
 
   const_op_range incoming_values() const { return operands(); }

Modified: llvm/branches/release_38/lib/Transforms/Scalar/LoopStrengthReduce.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/lib/Transforms/Scalar/LoopStrengthReduce.cpp?rev=261126&r1=261125&r2=261126&view=diff
==============================================================================
--- llvm/branches/release_38/lib/Transforms/Scalar/LoopStrengthReduce.cpp (original)
+++ llvm/branches/release_38/lib/Transforms/Scalar/LoopStrengthReduce.cpp Wed Feb 17 12:42:17 2016
@@ -4799,6 +4799,17 @@ LSRInstance::LSRInstance(Loop *L, IVUser
       DEBUG(dbgs() << "LSR skipping loop, too many IV Users in " << U << "\n");
       return;
     }
+    // Bail out if we have a PHI on an EHPad that gets a value from a
+    // CatchSwitchInst.  Because the CatchSwitchInst cannot be split, there is
+    // no good place to stick any instructions.
+    if (auto *PN = dyn_cast<PHINode>(U.getUser())) {
+       auto *FirstNonPHI = PN->getParent()->getFirstNonPHI();
+       if (isa<FuncletPadInst>(FirstNonPHI) ||
+           isa<CatchSwitchInst>(FirstNonPHI))
+         for (BasicBlock *PredBB : PN->blocks())
+           if (isa<CatchSwitchInst>(PredBB->getFirstNonPHI()))
+             return;
+    }
   }
 
 #ifndef NDEBUG

Modified: llvm/branches/release_38/test/Transforms/LoopStrengthReduce/funclet.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/release_38/test/Transforms/LoopStrengthReduce/funclet.ll?rev=261126&r1=261125&r2=261126&view=diff
==============================================================================
--- llvm/branches/release_38/test/Transforms/LoopStrengthReduce/funclet.ll (original)
+++ llvm/branches/release_38/test/Transforms/LoopStrengthReduce/funclet.ll Wed Feb 17 12:42:17 2016
@@ -214,3 +214,32 @@ try.cont.7:
 
 ; CHECK: catch.dispatch.2:
 ; CHECK: %e.0 = phi i32* [ %c, %try.cont ], [ %b, %catch.dispatch ]
+
+define i32 @test2() personality i32 (...)* @_except_handler3 {
+entry:
+  br label %for.body
+
+for.body:                                         ; preds = %for.inc, %entry
+  %phi = phi i32 [ %inc, %for.inc ], [ 0, %entry ]
+  invoke void @reserve()
+          to label %for.inc unwind label %catch.dispatch
+
+catch.dispatch:                                   ; preds = %for.body
+  %tmp18 = catchswitch within none [label %catch.handler] unwind to caller
+
+catch.handler:                                    ; preds = %catch.dispatch
+  %phi.lcssa = phi i32 [ %phi, %catch.dispatch ]
+  %tmp19 = catchpad within %tmp18 [i8* null]
+  catchret from %tmp19 to label %done
+
+done:
+  ret i32 %phi.lcssa
+
+for.inc:                                          ; preds = %for.body
+  %inc = add i32 %phi, 1
+  br label %for.body
+}
+
+; CHECK-LABEL: define i32 @test2(
+; CHECK:      %phi.lcssa = phi i32 [ %phi, %catch.dispatch ]
+; CHECK-NEXT: catchpad within




More information about the llvm-branch-commits mailing list