llvm.org GIT mirror llvm / 390f711
Approved by Chris: $ svn merge -c 113109 https://llvm.org/svn/llvm-project/llvm/trunk --- Merging r113109 into '.': U test/Transforms/GlobalOpt/crash.ll U lib/Analysis/ValueTracking.cpp Log: fix PR8063, a crash in globalopt in the malloc analysis code. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_28@113111 91177308-0d34-0410-b5e6-96231b3b80d8 Bill Wendling 9 years ago
2 changed file(s) with 44 addition(s) and 20 deletion(s). Raw diff Collapse all Expand all
879879 }
880880
881881 Value *Mul0 = NULL;
882 Value *Mul1 = NULL;
883 bool M0 = ComputeMultiple(Op0, Base, Mul0,
884 LookThroughSExt, Depth+1);
885 bool M1 = ComputeMultiple(Op1, Base, Mul1,
886 LookThroughSExt, Depth+1);
887
888 if (M0) {
889 if (isa(Op1) && isa(Mul0)) {
890 // V == Base * (Mul0 * Op1), so return (Mul0 * Op1)
891 Multiple = ConstantExpr::getMul(cast(Mul0),
892 cast(Op1));
893 return true;
894 }
882 if (ComputeMultiple(Op0, Base, Mul0, LookThroughSExt, Depth+1)) {
883 if (Constant *Op1C = dyn_cast(Op1))
884 if (Constant *MulC = dyn_cast(Mul0)) {
885 if (Op1C->getType()->getPrimitiveSizeInBits() <
886 MulC->getType()->getPrimitiveSizeInBits())
887 Op1C = ConstantExpr::getZExt(Op1C, MulC->getType());
888 if (Op1C->getType()->getPrimitiveSizeInBits() >
889 MulC->getType()->getPrimitiveSizeInBits())
890 MulC = ConstantExpr::getZExt(MulC, Op1C->getType());
891
892 // V == Base * (Mul0 * Op1), so return (Mul0 * Op1)
893 Multiple = ConstantExpr::getMul(MulC, Op1C);
894 return true;
895 }
895896
896897 if (ConstantInt *Mul0CI = dyn_cast(Mul0))
897898 if (Mul0CI->getValue() == 1) {
901902 }
902903 }
903904
904 if (M1) {
905 if (isa(Op0) && isa(Mul1)) {
906 // V == Base * (Mul1 * Op0), so return (Mul1 * Op0)
907 Multiple = ConstantExpr::getMul(cast(Mul1),
908 cast(Op0));
909 return true;
910 }
905 Value *Mul1 = NULL;
906 if (ComputeMultiple(Op1, Base, Mul1, LookThroughSExt, Depth+1)) {
907 if (Constant *Op0C = dyn_cast(Op0))
908 if (Constant *MulC = dyn_cast(Mul1)) {
909 if (Op0C->getType()->getPrimitiveSizeInBits() <
910 MulC->getType()->getPrimitiveSizeInBits())
911 Op0C = ConstantExpr::getZExt(Op0C, MulC->getType());
912 if (Op0C->getType()->getPrimitiveSizeInBits() >
913 MulC->getType()->getPrimitiveSizeInBits())
914 MulC = ConstantExpr::getZExt(MulC, Op0C->getType());
915
916 // V == Base * (Mul1 * Op0), so return (Mul1 * Op0)
917 Multiple = ConstantExpr::getMul(MulC, Op0C);
918 return true;
919 }
911920
912921 if (ConstantInt *Mul1CI = dyn_cast(Mul1))
913922 if (Mul1CI->getValue() == 1) {
3939 }
4040
4141 declare noalias i8* @malloc(i64) nounwind
42
43
44 ; PR8063
45 @permute_bitrev.bitrev = internal global i32* null, align 8
46 define void @permute_bitrev() nounwind {
47 entry:
48 %tmp = load i32** @permute_bitrev.bitrev, align 8
49 %conv = sext i32 0 to i64
50 %mul = mul i64 %conv, 4
51 %call = call i8* @malloc(i64 %mul)
52 %0 = bitcast i8* %call to i32*
53 store i32* %0, i32** @permute_bitrev.bitrev, align 8
54 ret void
55 }
56