PATCH + test for PR17099.
Duncan Sands
duncan.sands at gmail.com
Thu Sep 5 13:01:27 PDT 2013
Hi Stepan,
> Please find patch + regression test for MergeFunctions pass that fixes PR17099
> issue.
> --- lib/Transforms/IPO/MergeFunctions.cpp (revision 189742)
> +++ lib/Transforms/IPO/MergeFunctions.cpp (working copy)
> @@ -738,7 +738,15 @@
> FunctionType *FFTy = F->getFunctionType();
> for (Function::arg_iterator AI = NewG->arg_begin(), AE = NewG->arg_end();
> AI != AE; ++AI) {
> - Args.push_back(Builder.CreateBitCast(AI, FFTy->getParamType(i)));
> + Type* Ty1 = AI->getType();
> + Type* Ty2 = FFTy->getParamType(i);
> + LLVMContext &Ctx = Ty1->getContext();
> + if (isa<PointerType>(Ty1) && Ty2 == TD->getIntPtrType(Ctx))
> + Args.push_back(Builder.CreatePtrToInt(AI, Ty2));
> + else if (isa<PointerType>(Ty2) && Ty1 == TD->getIntPtrType(Ctx))
> + Args.push_back(Builder.CreateIntToPtr(AI, Ty2));
> + else
> + Args.push_back(Builder.CreateBitCast(AI, Ty2));
you can use CastInst::getCastOpcode, which will produce BitCast, IntToPtr or
PtrToInt as appropriate.
Ciao, Duncan.
> ++i;
> }
>
More information about the llvm-commits
mailing list