@@ -157,12 +157,6 @@ namespace {
157
157
if (V->getType () == DestTy)
158
158
return V;
159
159
160
- if (V->getType ()->isPointerTy () && DestTy->isIntegerTy ())
161
- return Builder.CreatePtrToInt (V, DestTy);
162
-
163
- if (V->getType ()->isIntegerTy () && DestTy->isPointerTy ())
164
- return Builder.CreateIntToPtr (V, DestTy);
165
-
166
160
if (V->getType ()->isPointerTy () && DestTy->isPointerTy ()) {
167
161
PointerType* SrcPtrTy = cast<PointerType>(V->getType ());
168
162
PointerType* DstPtrTy = cast<PointerType>(DestTy);
@@ -171,6 +165,30 @@ namespace {
171
165
return Builder.CreateAddrSpaceCast (V, DestTy);
172
166
}
173
167
168
+ if (V->getType ()->isPointerTy ()) {
169
+ if (DestTy->isIntegerTy ()) {
170
+ return Builder.CreatePtrToInt (V, DestTy);
171
+ }
172
+ else if (DestTy->isFloatingPointTy ()) {
173
+ uint32_t Size = DestTy->getPrimitiveSizeInBits ();
174
+ Value* Cast = Builder.CreatePtrToInt (
175
+ V, Builder.getIntNTy (Size));
176
+ return Builder.CreateBitCast (Cast, DestTy);
177
+ }
178
+ }
179
+
180
+ if (DestTy->isPointerTy ()) {
181
+ if (V->getType ()->isIntegerTy ()) {
182
+ return Builder.CreateIntToPtr (V, DestTy);
183
+ }
184
+ else if (V->getType ()->isFloatingPointTy ()) {
185
+ uint32_t Size = V->getType ()->getPrimitiveSizeInBits ();
186
+ Value* Cast = Builder.CreateBitCast (
187
+ V, Builder.getIntNTy (Size));
188
+ return Builder.CreateIntToPtr (Cast, DestTy);
189
+ }
190
+ }
191
+
174
192
return Builder.CreateBitCast (V, DestTy);
175
193
}
176
194
0 commit comments