From bcd82afad64a22b15000de350d075b10f2de273a Mon Sep 17 00:00:00 2001 From: Fariborz Jahanian Date: Tue, 5 Aug 2014 18:37:48 +0000 Subject: Introduce f[no-]max-unknown-pointer-align=[number] option to instruct the code generator to not enforce a higher alignment than the given number (of bytes) when accessing memory via an opaque pointer or reference. Patch reviewed by John McCall (with post-commit review pending). rdar://16254558 llvm-svn: 214911 --- clang/lib/CodeGen/CodeGenFunction.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'clang/lib/CodeGen/CodeGenFunction.h') diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h index 84962927990..a200548aa0e 100644 --- a/clang/lib/CodeGen/CodeGenFunction.h +++ b/clang/lib/CodeGen/CodeGenFunction.h @@ -1399,8 +1399,13 @@ public: LValue MakeNaturalAlignAddrLValue(llvm::Value *V, QualType T) { CharUnits Alignment; - if (!T->isIncompleteType()) + if (!T->isIncompleteType()) { Alignment = getContext().getTypeAlignInChars(T); + unsigned MaxAlign = getContext().getLangOpts().MaxTypeAlign; + if (MaxAlign && Alignment.getQuantity() > MaxAlign && + !getContext().isAlignmentRequired(T)) + Alignment = CharUnits::fromQuantity(MaxAlign); + } return LValue::MakeAddr(V, T, Alignment, getContext(), CGM.getTBAAInfo(T)); } -- cgit v1.2.3