HomePhabricator

[Codegen] If reasonable, materialize clang's `AssumeAlignedAttr` as llvm's…

Authored by lebedev.ri on Jan 23 2020, 11:50 AM.

Description

[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