[llvm-branch-commits] [llvm-branch] r109542 - in /llvm/branches/Apple/Hartnell: ./ lib/Transforms/Scalar/ScalarReplAggregates.cpp test/Transforms/ScalarRepl/address-space.ll
Bill Wendling
isanbard at gmail.com
Tue Jul 27 14:09:11 PDT 2010
Author: void
Date: Tue Jul 27 16:09:11 2010
New Revision: 109542
URL: http://llvm.org/viewvc/llvm-project?rev=109542&view=rev
Log:
$ svn merge -c 107846 https://llvm.org/svn/llvm-project/llvm/trunk
--- Merging r107846 into '.':
A test/Transforms/ScalarRepl/address-space.ll
U lib/Transforms/Scalar/ScalarReplAggregates.cpp
Added:
llvm/branches/Apple/Hartnell/test/Transforms/ScalarRepl/address-space.ll
- copied unchanged from r107846, llvm/trunk/test/Transforms/ScalarRepl/address-space.ll
Modified:
llvm/branches/Apple/Hartnell/ (props changed)
llvm/branches/Apple/Hartnell/lib/Transforms/Scalar/ScalarReplAggregates.cpp
Propchange: llvm/branches/Apple/Hartnell/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Tue Jul 27 16:09:11 2010
@@ -1,2 +1,2 @@
/llvm/branches/Apple/Morbo:102475
-/llvm/trunk:104174-104175,105453,108367
+/llvm/trunk:104174-104175,105453,107846,108367
Modified: llvm/branches/Apple/Hartnell/lib/Transforms/Scalar/ScalarReplAggregates.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/Apple/Hartnell/lib/Transforms/Scalar/ScalarReplAggregates.cpp?rev=109542&r1=109541&r2=109542&view=diff
==============================================================================
--- llvm/branches/Apple/Hartnell/lib/Transforms/Scalar/ScalarReplAggregates.cpp (original)
+++ llvm/branches/Apple/Hartnell/lib/Transforms/Scalar/ScalarReplAggregates.cpp Tue Jul 27 16:09:11 2010
@@ -1272,6 +1272,8 @@
// If there is an other pointer, we want to convert it to the same pointer
// type as AI has, so we can GEP through it safely.
if (OtherPtr) {
+ unsigned AddrSpace =
+ cast<PointerType>(OtherPtr->getType())->getAddressSpace();
// Remove bitcasts and all-zero GEPs from OtherPtr. This is an
// optimization, but it's also required to detect the corner case where
@@ -1279,20 +1281,8 @@
// OtherPtr may be a bitcast or GEP that currently being rewritten. (This
// function is only called for mem intrinsics that access the whole
// aggregate, so non-zero GEPs are not an issue here.)
- while (1) {
- if (BitCastInst *BC = dyn_cast<BitCastInst>(OtherPtr)) {
- OtherPtr = BC->getOperand(0);
- continue;
- }
- if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(OtherPtr)) {
- // All zero GEPs are effectively bitcasts.
- if (GEP->hasAllZeroIndices()) {
- OtherPtr = GEP->getOperand(0);
- continue;
- }
- }
- break;
- }
+ OtherPtr = OtherPtr->stripPointerCasts();
+
// Copying the alloca to itself is a no-op: just delete it.
if (OtherPtr == AI || OtherPtr == NewElts[0]) {
// This code will run twice for a no-op memcpy -- once for each operand.
@@ -1304,15 +1294,13 @@
return;
}
- if (ConstantExpr *BCE = dyn_cast<ConstantExpr>(OtherPtr))
- if (BCE->getOpcode() == Instruction::BitCast)
- OtherPtr = BCE->getOperand(0);
-
// If the pointer is not the right type, insert a bitcast to the right
// type.
- if (OtherPtr->getType() != AI->getType())
- OtherPtr = new BitCastInst(OtherPtr, AI->getType(), OtherPtr->getName(),
- MI);
+ const Type *NewTy =
+ PointerType::get(AI->getType()->getElementType(), AddrSpace);
+
+ if (OtherPtr->getType() != NewTy)
+ OtherPtr = new BitCastInst(OtherPtr, NewTy, OtherPtr->getName(), MI);
}
// Process each element of the aggregate.
More information about the llvm-branch-commits
mailing list