[SystemZ][z/OS] Force alignment to fix build failure on z/OS
authorAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 11 Jul 2022 12:28:47 +0000 (08:28 -0400)
committerAbhina Sreeskantharajan <Abhina.Sreeskantharajan@ibm.com>
Mon, 11 Jul 2022 12:29:29 +0000 (08:29 -0400)
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.

Reviewed By: wolfgangp

Differential Revision: https://reviews.llvm.org/D129369

llvm/include/llvm/IR/Metadata.h

index be359d9..293eba9 100644 (file)
@@ -951,7 +951,9 @@ class MDNode : public Metadata {
   /// The operands are in turn located immediately before the header.
   /// For resizable MDNodes, the space for the storage vector is also allocated
   /// immediately before the header, overlapping with the operands.
-  struct Header {
+  /// Explicity set alignment because bitfields by default have an
+  /// alignment of 1 on z/OS.
+  struct alignas(alignof(size_t)) Header {
     bool IsResizable : 1;
     bool IsLarge : 1;
     size_t SmallSize : 4;