[llvm-commits] [dragonegg] r138629 - /dragonegg/trunk/src/Constants.cpp
Duncan Sands
baldrick at free.fr
Fri Aug 26 01:29:02 PDT 2011
Author: baldrick
Date: Fri Aug 26 03:29:02 2011
New Revision: 138629
URL: http://llvm.org/viewvc/llvm-project?rev=138629&view=rev
Log:
The GCC optimizers can create constant vectors of pointers. Since LLVM
only supports vectors of integers, cast the pointers to integers of the
same size.
Modified:
dragonegg/trunk/src/Constants.cpp
Modified: dragonegg/trunk/src/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/dragonegg/trunk/src/Constants.cpp?rev=138629&r1=138628&r2=138629&view=diff
==============================================================================
--- dragonegg/trunk/src/Constants.cpp (original)
+++ dragonegg/trunk/src/Constants.cpp Fri Aug 26 03:29:02 2011
@@ -937,9 +937,16 @@
// Make the IR more pleasant by returning as a vector if the GCC type was a
// vector. However this is only correct if the initial values had the same
// type as the vector element type, rather than some random other type.
- return ActualEltTy == EltTy && TREE_CODE(init_type) == VECTOR_TYPE ?
- ConstantVector::get(Elts) :
- ConstantArray::get(ArrayType::get(ActualEltTy, Elts.size()), Elts);
+ if (TREE_CODE(init_type) == VECTOR_TYPE && ActualEltTy == EltTy) {
+ // If this is a vector of pointers, convert it to a vector of integers.
+ if (isa<PointerType>(EltTy)) {
+ IntegerType *IntPtrTy = getTargetData().getIntPtrType(Context);
+ for (unsigned i = 0, e = Elts.size(); i != e; ++i)
+ Elts[i] = Folder.CreatePtrToInt(Elts[i], IntPtrTy);
+ }
+ return ConstantVector::get(Elts);
+ }
+ return ConstantArray::get(ArrayType::get(ActualEltTy, Elts.size()), Elts);
}
/// FieldContents - A constant restricted to a range of bits. Any part of the
More information about the llvm-commits
mailing list