summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGExprCXX.cpp
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2013-02-03 17:44:25 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2013-02-03 17:44:25 +0000
commitb520633048637a96911c8aacdf422bbcf9380b2b (patch)
treeec83b5eacefb4cbc4d10f827a8fe33ad94180979 /clang/lib/CodeGen/CGExprCXX.cpp
parent981e99d5608d3dbf17fcb29fb9eafc8f3d9499b6 (diff)
downloadbcm5719-llvm-b520633048637a96911c8aacdf422bbcf9380b2b.tar.gz
bcm5719-llvm-b520633048637a96911c8aacdf422bbcf9380b2b.zip
CodeGen: Mark the runtime function __dynamic_cast as readonly & nounwind.
This allows the optimizer to CSE dynamic_casts. llvm-svn: 174289
Diffstat (limited to 'clang/lib/CodeGen/CGExprCXX.cpp')
-rw-r--r--clang/lib/CodeGen/CGExprCXX.cpp15
1 files changed, 10 insertions, 5 deletions
diff --git a/clang/lib/CodeGen/CGExprCXX.cpp b/clang/lib/CodeGen/CGExprCXX.cpp
index 8b7f2342c4e..853e25ec8c7 100644
--- a/clang/lib/CodeGen/CGExprCXX.cpp
+++ b/clang/lib/CodeGen/CGExprCXX.cpp
@@ -1689,11 +1689,16 @@ static llvm::Constant *getDynamicCastFn(CodeGenFunction &CGF) {
CGF.ConvertType(CGF.getContext().getPointerDiffType());
llvm::Type *Args[4] = { Int8PtrTy, Int8PtrTy, Int8PtrTy, PtrDiffTy };
-
- llvm::FunctionType *FTy =
- llvm::FunctionType::get(Int8PtrTy, Args, false);
-
- return CGF.CGM.CreateRuntimeFunction(FTy, "__dynamic_cast");
+
+ llvm::FunctionType *FTy = llvm::FunctionType::get(Int8PtrTy, Args, false);
+
+ // Mark the function as nounwind readonly.
+ llvm::Attribute::AttrKind FuncAttrs[] = { llvm::Attribute::NoUnwind,
+ llvm::Attribute::ReadOnly };
+ llvm::AttributeSet Attrs = llvm::AttributeSet::get(
+ CGF.getLLVMContext(), llvm::AttributeSet::FunctionIndex, FuncAttrs);
+
+ return CGF.CGM.CreateRuntimeFunction(FTy, "__dynamic_cast", Attrs);
}
static llvm::Constant *getBadCastFn(CodeGenFunction &CGF) {
OpenPOWER on IntegriCloud