Author: majnemer Date: Mon Oct 31 11:48:30 2016 New Revision: 285595 URL: http://llvm.org/viewvc/llvm-project?rev=285595&view=rev Log: Use toCharUnitsFromBits instead of TargetInfo::getCharWidth
Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp Modified: cfe/trunk/lib/CodeGen/CGBuiltin.cpp URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGBuiltin.cpp?rev=285595&r1=285594&r2=285595&view=diff ============================================================================== --- cfe/trunk/lib/CodeGen/CGBuiltin.cpp (original) +++ cfe/trunk/lib/CodeGen/CGBuiltin.cpp Mon Oct 31 11:48:30 2016 @@ -1142,7 +1142,9 @@ RValue CodeGenFunction::EmitBuiltinExpr( const TargetInfo &TI = getContext().getTargetInfo(); // The alignment of the alloca should correspond to __BIGGEST_ALIGNMENT__. unsigned SuitableAlignmentInBytes = - TI.getSuitableAlign() / TI.getCharWidth(); + CGM.getContext() + .toCharUnitsFromBits(TI.getSuitableAlign()) + .getQuantity(); AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size); AI->setAlignment(SuitableAlignmentInBytes); return RValue::get(AI); @@ -1150,11 +1152,11 @@ RValue CodeGenFunction::EmitBuiltinExpr( case Builtin::BI__builtin_alloca_with_align: { Value *Size = EmitScalarExpr(E->getArg(0)); - Value *AlignmentValue = EmitScalarExpr(E->getArg(1)); - auto *AlignmentCI = cast<ConstantInt>(AlignmentValue); - unsigned Alignment = AlignmentCI->getZExtValue(); - const TargetInfo &TI = getContext().getTargetInfo(); - unsigned AlignmentInBytes = Alignment / TI.getCharWidth(); + Value *AlignmentInBitsValue = EmitScalarExpr(E->getArg(1)); + auto *AlignmentInBitsCI = cast<ConstantInt>(AlignmentInBitsValue); + unsigned AlignmentInBits = AlignmentInBitsCI->getZExtValue(); + unsigned AlignmentInBytes = + CGM.getContext().toCharUnitsFromBits(AlignmentInBits).getQuantity(); AllocaInst *AI = Builder.CreateAlloca(Builder.getInt8Ty(), Size); AI->setAlignment(AlignmentInBytes); return RValue::get(AI); _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits