summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen
diff options
context:
space:
mode:
authorDavid Majnemer <david.majnemer@gmail.com>2016-10-31 16:48:30 +0000
committerDavid Majnemer <david.majnemer@gmail.com>2016-10-31 16:48:30 +0000
commitbb103d928ec241d884ed38747e12ac17f05600c4 (patch)
tree075b316b578992d61cc4e76b692a1c4e8c304b6e /clang/lib/CodeGen
parentcddab279f6978fca9ae5a5676c7346f384579d2c (diff)
downloadbcm5719-llvm-bb103d928ec241d884ed38747e12ac17f05600c4.tar.gz
bcm5719-llvm-bb103d928ec241d884ed38747e12ac17f05600c4.zip
Use toCharUnitsFromBits instead of TargetInfo::getCharWidth
llvm-svn: 285595
Diffstat (limited to 'clang/lib/CodeGen')
-rw-r--r--clang/lib/CodeGen/CGBuiltin.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGBuiltin.cpp b/clang/lib/CodeGen/CGBuiltin.cpp
index 54566aa7e51..4728aadf733 100644
--- a/clang/lib/CodeGen/CGBuiltin.cpp
+++ b/clang/lib/CodeGen/CGBuiltin.cpp
@@ -1142,7 +1142,9 @@ RValue CodeGenFunction::EmitBuiltinExpr(const FunctionDecl *FD,
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(const FunctionDecl *FD,
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);
OpenPOWER on IntegriCloud