aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.h
diff options
context:
space:
mode:
authorFariborz Jahanian <fjahanian@apple.com>2014-08-05 18:37:48 +0000
committerFariborz Jahanian <fjahanian@apple.com>2014-08-05 18:37:48 +0000
commitbcd82afad64a22b15000de350d075b10f2de273a (patch)
treed6f58ff362c773ca851bd78c9b5b8b0453444adb /clang/lib/CodeGen/CodeGenFunction.h
parent4e4cb6bc305ae8e71ce35e4bfa4dfac721ce7e71 (diff)
downloadllvm-bcd82afad64a22b15000de350d075b10f2de273a.zip
llvm-bcd82afad64a22b15000de350d075b10f2de273a.tar.gz
llvm-bcd82afad64a22b15000de350d075b10f2de273a.tar.bz2
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
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.h')
-rw-r--r--clang/lib/CodeGen/CodeGenFunction.h7
1 files changed, 6 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CodeGenFunction.h b/clang/lib/CodeGen/CodeGenFunction.h
index 8496292..a200548 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));
}