[InstCombine] For cos/sin -> tan copy attributes from cos instead of the
parent function

Ideally we should merge the attributes from the functions somehow, but
this is obviously an improvement over taking random attributes from the
caller which will trip up the verifier if they're nonsensical for an
unary intrinsic call.

llvm-svn: 322284
diff --git a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
index 8abed5c..aa333fd 100644
--- a/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstCombineMulDivRem.cpp
@@ -1494,8 +1494,9 @@
         IRBuilder<> B(&I);
         IRBuilder<>::FastMathFlagGuard Guard(B);
         B.setFastMathFlags(I.getFastMathFlags());
-        Value *Tan = emitUnaryFloatFnCall(A, TLI.getName(LibFunc_tan),
-                                          B, I.getFunction()->getAttributes());
+        Value *Tan = emitUnaryFloatFnCall(
+            A, TLI.getName(LibFunc_tan), B,
+            CallSite(Op0).getCalledFunction()->getAttributes());
         Value *One = ConstantFP::get(Tan->getType(), 1.0);
         Value *Div = B.CreateFDiv(One, Tan);
         return replaceInstUsesWith(I, Div);