This is an archive of the discontinued LLVM Phabricator instance.

Honor __unaligned in codegen for declarations and expressions
ClosedPublic

Authored by rogfer01 on Feb 20 2017, 7:10 AM.

Details

Summary

See related proposal in http://lists.llvm.org/pipermail/cfe-dev/2017-February/052739.html

This patch honors the unaligned type qualifier (currently available through he keyword __unaligned and -fms-extensions) in CodeGen. In the current form the patch affects declarations and expressions. It does not affect fields of classes.

Diff Detail

Event Timeline

rogfer01 created this revision.Feb 20 2017, 7:10 AM
ahatanak added inline comments.
include/clang/AST/ASTContext.h
1910

Is it better to call TargetInfo::getCharWidth() instead of assigning a hardcoded number here?

lib/AST/ExprConstant.cpp
5678

You can remove an else after return.

rogfer01 updated this revision to Diff 89172.Feb 21 2017, 1:46 AM
rogfer01 marked 2 inline comments as done.

Updated patch. Use TargetInfo::getCharWidth and remove unnecessary else.

Ping? :-)

Kind regards

aaron.ballman added inline comments.
include/clang/AST/ASTContext.h
1909

This makes me a bit uncomfortable -- wouldn't we rather have the distinction between unqualified and qualified types instead of a mixture of both when calling getTypeInfo()?

rogfer01 updated this revision to Diff 89989.EditedFeb 28 2017, 2:02 AM

Avoid altering results of TypeInfo due to the __unaligned qualifier. Instead override the natural alignment to 1 if the type is __unaligned-qualified.

aaron.ballman accepted this revision.Feb 28 2017, 12:52 PM

I think this LGTM, but you should wait for confirmation from one of the other reviewers before committing.

This revision is now accepted and ready to land.Feb 28 2017, 12:52 PM

Ping? :-)

Kind regards

rnk accepted this revision.Mar 7 2017, 3:46 PM

Looks good! Sorry for the delay, I was out last week.

This revision was automatically updated to reflect the committed changes.