OSDN Git Service

[Codegen] If reasonable, materialize clang's `AssumeAlignedAttr` as llvm's Alignment...
authorRoman Lebedev <lebedev.ri@gmail.com>
Thu, 23 Jan 2020 19:50:15 +0000 (22:50 +0300)
committerRoman Lebedev <lebedev.ri@gmail.com>
Thu, 23 Jan 2020 19:50:49 +0000 (22:50 +0300)
commite819f7c9feb4d4b611681e319fbb43fd28b3f5b7
tree0f8a318cfae1b1fb142a946863ce1e2bb904c572
parentd096f8d306b2b16a25f65ffb70849ca7963a0dac
[Codegen] If reasonable, materialize clang's `AssumeAlignedAttr` as llvm's Alignment Attribute on call-site function return value

Summary:
This should be mostly NFC - we still lower the same alignment
knowledge to the IR. The main reasoning here is that
this somewhat improves readability of IR like this,
and will improve test coverage in upcoming patch.

Even though the alignment is guaranteed to always be an I-C-E,
we don't always materialize it as llvm's Alignment Attribute because:
1. There may be a non-zero offset
2. We may be sanitizing for alignment

Note that if there already was an IR alignment attribute
on return value, we union them, and thus the alignment
only ever rises.

Also, there is a second relevant clang attribute `AllocAlignAttr`,
so that is why `AbstractAssumeAlignedAttrEmitter` is templated.

Reviewers: erichkeane, jdoerfert, hfinkel, aaron.ballman, rsmith

Reviewed By: erichkeane

Subscribers: cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73005
clang/lib/CodeGen/CGCall.cpp
clang/test/CodeGen/assume-aligned-and-alloc-align-attributes.c
clang/test/CodeGen/builtin-assume-aligned.c
clang/test/CodeGen/catch-alignment-assumption-attribute-assume_aligned-on-function.cpp