[NFC][Codegen] Use MaybeAlign + APInt::getLimitedValue() when creating Alignment attr

Summary: Just an NFC code cleanup i stumbled upon when stumbling through clang alignment attribute handling.

Reviewers: erichkeane, gchatelet, courbet, jdoerfert

Reviewed By: gchatelet

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D72993
This commit is contained in:
Roman Lebedev 2020-01-21 21:18:29 +03:00
parent 372cb38f45
commit 6b2f820221
No known key found for this signature in database
GPG Key ID: 083C3EBB4A1689E0
1 changed files with 2 additions and 3 deletions

View File

@ -2440,9 +2440,8 @@ void CodeGenFunction::EmitFunctionProlog(const CGFunctionInfo &FI,
EmitScalarExpr(AVAttr->getAlignment());
llvm::ConstantInt *AlignmentCI =
cast<llvm::ConstantInt>(AlignmentValue);
unsigned Alignment = std::min((unsigned)AlignmentCI->getZExtValue(),
+llvm::Value::MaximumAlignment);
AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(Alignment));
AI->addAttrs(llvm::AttrBuilder().addAlignmentAttr(llvm::MaybeAlign(
AlignmentCI->getLimitedValue(llvm::Value::MaximumAlignment))));
}
}