This is an archive of the discontinued LLVM Phabricator instance.

[SystemZ][z/OS] Force alignment to fix build failure on z/OS
ClosedPublic

Authored by abhina.sreeskantharajan on Jul 8 2022, 6:41 AM.

Details

Summary

The following commit https://reviews.llvm.org/D125998 added a static_assert which was triggered on z/OS because bitfields are always aligned to 1 regardless of type.

error: static_assert failed due to requirement 'alignof(llvm::SmallVector<llvm::MDOperand, 0>) <= alignof(llvm::MDNode::Header)' "LargeStorageVector too strongly aligned"

The solution was to force the alignment to be size_t.

Diff Detail

Event Timeline

Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 6:41 AM
abhina.sreeskantharajan requested review of this revision.Jul 8 2022, 6:41 AM
Herald added a project: Restricted Project. · View Herald TranscriptJul 8 2022, 6:41 AM
abhina.sreeskantharajan retitled this revision from Force alignment to fix build failure on z/OS. to [SystemZ][z/OS] Force alignment to fix build failure on z/OS.Jul 8 2022, 6:45 AM
abhina.sreeskantharajan edited the summary of this revision. (Show Details)
abhina.sreeskantharajan edited the summary of this revision. (Show Details)Jul 8 2022, 6:53 AM
abhina.sreeskantharajan edited the summary of this revision. (Show Details)
abhina.sreeskantharajan edited the summary of this revision. (Show Details)

empty commit

wolfgangp added inline comments.Jul 8 2022, 11:28 AM
llvm/include/llvm/IR/Metadata.h
959

This fails for me on Windows builds using Visual Studio (at least VS19), since it does not support this attribute. I would suggest using alignas() in the struct declaration instead, like

struct alignas(alignof(size_t)) Header {

and see if this works for you.

1037

This is not guaranteed on all platforms, because some compilers don't necessarily pack the bitfields tightly. In fact, I'll need to reexamine this for Visual Studio builds and perhaps adjust the bitfield types. I would ask you to not put this assert in for now.

Use alignas and remove assert.

abhina.sreeskantharajan marked 2 inline comments as done.Jul 8 2022, 12:35 PM

Thanks, I have changed it to alignas and removed the static_assert.

wolfgangp accepted this revision.Jul 8 2022, 1:27 PM

LGTM.

This revision is now accepted and ready to land.Jul 8 2022, 1:27 PM
This revision was landed with ongoing or failed builds.Jul 11 2022, 5:29 AM
This revision was automatically updated to reflect the committed changes.