From a2b18de4ba9ac3f5ac14ba9984d2250b0e512ea1 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 19 May 2007 06:51:32 +0000 Subject: [PATCH] Fix Transforms/InstCombine/2007-05-18-CastFoldBug.ll, a bug that devastates objc code due to the way the FE lowers objc message sends. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@37256 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/InstructionCombining.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp index 08905576d22..db105adf7ff 100644 --- a/lib/Transforms/Scalar/InstructionCombining.cpp +++ b/lib/Transforms/Scalar/InstructionCombining.cpp @@ -7773,6 +7773,14 @@ bool InstCombiner::transformConstExprCastCall(CallSite CS) { const FunctionType *FT = Callee->getFunctionType(); const Type *OldRetTy = Caller->getType(); + const FunctionType *ActualFT = + cast(cast(CE->getType())->getElementType()); + + // If the parameter attributes don't match up, don't do the xform. We don't + // want to lose an sret attribute or something. + if (FT->getParamAttrs() != ActualFT->getParamAttrs()) + return false; + // Check to see if we are changing the return type... if (OldRetTy != FT->getReturnType()) { if (Callee->isDeclaration() && !Caller->use_empty() &&