[llvm-commits] [llvm-gcc-4.2] r54240 - /llvm-gcc-4.2/trunk/gcc/llvm-convert.cpp

Duncan Sands baldrick at free.fr
Thu Jul 31 00:16:26 PDT 2008


Hi,

> @@ -4520,18 +4520,19 @@
>        Emit(TREE_VALUE(TREE_CHAIN(TREE_CHAIN(arglist))), 0)
>      };
>      const Type *OrigTy = cast<PointerType>(C[0]->getType())->getElementType();
> -    const Type* Ty = OrigTy;
> -    if (isa<PointerType>(Ty)) 
> -      Ty = TD.getIntPtrType();
> -
> -    C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty));
> -    C[1] = Builder.CreateIntCast(C[1], Ty, "cast");
> -    C[2] = Builder.CreateIntCast(C[2], Ty, "cast");
> +    const Type* Ty[2];
> +    if (isa<PointerType>(Ty[0])) 

You just used Ty[0] uninitialized.

> @@ -4555,15 +4556,17 @@
>        Emit(TREE_VALUE(TREE_CHAIN(arglist)), 0)
>      };
>      const Type *OrigTy = cast<PointerType>(C[0]->getType())->getElementType();
> -    const Type* Ty = OrigTy;
> -    if (isa<PointerType>(Ty)) 
> -      Ty = TD.getIntPtrType();     
> -    C[0] = Builder.CreateBitCast(C[0], PointerType::getUnqual(Ty));
> -    C[1] = Builder.CreateIntCast(C[1], Ty, "cast");
> +    const Type* Ty[2];
> +    Ty[0] = OrigTy;
> +    if (isa<PointerType>(Ty[0])) 
> +      Ty[0] = TD.getIntPtrType();
> +    Ty[1] = C[0]->getType();

Here you may well have used C[0] uninitialized.  More cases
of this occur in the rest of the patch.

Also, how about factorizing this code while you are there?
It seems to be many copies of the same thing.

Best wishes,

Duncan.



More information about the llvm-commits mailing list