[llvm] r225068 - [SROA] Fix two total think-os in r225061 that should have been caught on

Chandler Carruth chandlerc at gmail.com
Thu Jan 1 15:26:16 PST 2015


Author: chandlerc
Date: Thu Jan  1 17:26:16 2015
New Revision: 225068

URL: http://llvm.org/viewvc/llvm-project?rev=225068&view=rev
Log:
[SROA] Fix two total think-os in r225061 that should have been caught on
a +asserts bootstrap, but my bootstrap had asserts off. Oops.

Anyways, in some places it is reasonable to cast (as a sanity check) the
pointer operand to a load or store to an instruction within SROA --
namely when the pointer operand is expected to be derived from an
alloca, and thus always an instruction. However, the pre-splitting code
also deals with loads and stores to non-alloca pointers and there we
need to just use the Value*. Nothing about the code relied on the
instruction cast, it was only there essentially as an invariant
assertion. Remove the two that don't actually hold.

This should fix the proximate issue in PR22080, but I'm also doing an
asserts bootstrap myself to see if there are other issues lurking.

I'll craft a reduced test case in a moment, but I wanted to get the tree
healthy as quickly as possible.

Modified:
    llvm/trunk/lib/Transforms/Scalar/SROA.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=225068&r1=225067&r2=225068&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Thu Jan  1 17:26:16 2015
@@ -3726,7 +3726,7 @@ bool SROA::presplitLoadsAndStores(Alloca
         continue;
       }
 
-      Instruction *StoreBasePtr = cast<Instruction>(SI->getPointerOperand());
+      Value *StoreBasePtr = SI->getPointerOperand();
       IRB.SetInsertPoint(BasicBlock::iterator(SI));
 
       DEBUG(dbgs() << "    Splitting store of load: " << *SI << "\n");
@@ -3789,7 +3789,7 @@ bool SROA::presplitLoadsAndStores(Alloca
     assert(BaseOffset + StoreSize > BaseOffset &&
            "Cannot represent alloca access size using 64-bit integers!");
 
-    Instruction *LoadBasePtr = cast<Instruction>(LI->getPointerOperand());
+    Value *LoadBasePtr = LI->getPointerOperand();
     Instruction *StoreBasePtr = cast<Instruction>(SI->getPointerOperand());
 
     DEBUG(dbgs() << "  Splitting store: " << *SI << "\n");





More information about the llvm-commits mailing list