summaryrefslogtreecommitdiff
path: root/include/llvm/Support/TargetFolder.h
diff options
context:
space:
mode:
authorNick Lewycky <nicholas@mxc.ca>2012-09-27 06:33:40 +0000
committerNick Lewycky <nicholas@mxc.ca>2012-09-27 06:33:40 +0000
commite2d02349c3a864a825f3152ac5b7999594a0952f (patch)
tree3f72edc0b7724bc17ff0e3457c03f7b7eab2b779 /include/llvm/Support/TargetFolder.h
parent8f50647662560167b88851f92c3c891d2e7c1696 (diff)
downloadllvm-e2d02349c3a864a825f3152ac5b7999594a0952f.tar.gz
llvm-e2d02349c3a864a825f3152ac5b7999594a0952f.tar.bz2
llvm-e2d02349c3a864a825f3152ac5b7999594a0952f.tar.xz
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". git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@164760 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'include/llvm/Support/TargetFolder.h')
-rw-r--r--include/llvm/Support/TargetFolder.h9
1 files changed, 8 insertions, 1 deletions
diff --git a/include/llvm/Support/TargetFolder.h b/include/llvm/Support/TargetFolder.h
index c65faa6621..a02db2fe66 100644
--- a/include/llvm/Support/TargetFolder.h
+++ b/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);