[PATCH] Fix infinite recursion bug in SROA
Duncan P. N. Exon Smith
dexonsmith at apple.com
Tue Jan 21 11:43:39 PST 2014
On Jan 21, 2014, at 10:20 AM, James Molloy <James.Molloy at arm.com> wrote:
> Hi Chandler,
>
> OK – sure. Attached is a patch that removes the early exits. Is it OK?
>
> Cheers,
>
> James
>
> <sroa-findcommontype.diff>_______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
Hi James,
Just a nitpick here.
> Index: lib/Transforms/Scalar/SROA.cpp
> ===================================================================
> --- lib/Transforms/Scalar/SROA.cpp (revision 199673)
> +++ lib/Transforms/Scalar/SROA.cpp (working copy)
> @@ -956,8 +956,10 @@
> static Type *findCommonType(AllocaSlices::const_iterator B,
> AllocaSlices::const_iterator E,
> uint64_t EndOffset) {
> - Type *Ty = 0;
> - bool IgnoreNonIntegralTypes = false;
> + Type *Ty = NULL;
> + bool TyIsNotCommon = false;
I think TyIsCommon (= true) is a better name. The double-negative at the end of
the function (i.e., !TyIsNotCommon) is hard to read.
> + if (!UserTy || (Ty && UserTy != Ty))
> + TyIsNotCommon = true;
Obviously, this changes to:
if (!UserTy || (Ty && UserTy != Ty))
TyIsCommon = false;
> + // If there is a common type, return that. Else return the integral type,
> + // if there was one.
> + if (Ty && !TyIsNotCommon)
> + return Ty;
Now you can say:
if (Ty && TyIsCommon)
return Ty;
More information about the llvm-commits
mailing list