[llvm] 6e2329e - [SystemZ][z/OS] Force alignment to fix build failure on z/OS

Abhina Sreeskantharajan via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 11 05:29:35 PDT 2022


Author: Abhina Sreeskantharajan
Date: 2022-07-11T08:29:29-04:00
New Revision: 6e2329e33ae3f0239785af0fb69bf73ebe3b8899

URL: https://github.com/llvm/llvm-project/commit/6e2329e33ae3f0239785af0fb69bf73ebe3b8899
DIFF: https://github.com/llvm/llvm-project/commit/6e2329e33ae3f0239785af0fb69bf73ebe3b8899.diff

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

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

Added: 
    

Modified: 
    llvm/include/llvm/IR/Metadata.h

Removed: 
    


################################################################################
diff  --git a/llvm/include/llvm/IR/Metadata.h b/llvm/include/llvm/IR/Metadata.h
index be359d94f812b..293eba9e9f0a9 100644
--- a/llvm/include/llvm/IR/Metadata.h
+++ b/llvm/include/llvm/IR/Metadata.h
@@ -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;


        


More information about the llvm-commits mailing list