diff options
| author | Nick Lewycky <nicholas@mxc.ca> | 2012-09-27 06:33:40 +0000 |
|---|---|---|
| committer | Nick Lewycky <nicholas@mxc.ca> | 2012-09-27 06:33:40 +0000 |
| commit | 04f832bf2c576c65fed751a613437da74f5c5f43 (patch) | |
| tree | df90a3d1dcec6eb41e2f085745e843330be80946 | |
| parent | 47172a064f9b362ae2ef5895c494fb61f174907f (diff) | |
| download | bcm5719-llvm-04f832bf2c576c65fed751a613437da74f5c5f43.tar.gz bcm5719-llvm-04f832bf2c576c65fed751a613437da74f5c5f43.zip | |
Add missing function CreateFPCast to the TargetFolder. It's there in the other
folders and not having it here fails to compile if you actually try to use it.
Also, CreatePointerCast was failing to do the part where it does TD-aware
constant folding. Granted there is exactly one case where that it will ever
do anything, but there's no reason to skip it. For reference, that case is a
subtraction between two constant offsets on the same global variable, eg.,
"&A[123] - &A[4].f".
llvm-svn: 164760
| -rw-r--r-- | llvm/include/llvm/Support/TargetFolder.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/include/llvm/Support/TargetFolder.h b/llvm/include/llvm/Support/TargetFolder.h index c65faa66219..a02db2fe666 100644 --- a/llvm/include/llvm/Support/TargetFolder.h +++ b/llvm/include/llvm/Support/TargetFolder.h @@ -177,7 +177,14 @@ public: return Fold(ConstantExpr::getIntegerCast(C, DestTy, isSigned)); } Constant *CreatePointerCast(Constant *C, Type *DestTy) const { - return ConstantExpr::getPointerCast(C, DestTy); + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getPointerCast(C, DestTy)); + } + Constant *CreateFPCast(Constant *C, Type *DestTy) const { + if (C->getType() == DestTy) + return C; // avoid calling Fold + return Fold(ConstantExpr::getFPCast(C, DestTy)); } Constant *CreateBitCast(Constant *C, Type *DestTy) const { return CreateCast(Instruction::BitCast, C, DestTy); |

