[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Guillaume Chatelet via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG0957233320eb: [Alignment][NFC] Use Align with 
CreateMaskedStore (authored by gchatelet).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2343,7 +2343,7 @@
   Value *ShuffledMask = Builder.CreateShuffleVector(
   BlockInMaskPart, Undefs, RepMask, "interleaved.mask");
   NewStoreInstr = Builder.CreateMaskedStore(
-  IVec, AddrParts[Part], Group->getAlignment(), ShuffledMask);
+  IVec, AddrParts[Part], Group->getAlign(), ShuffledMask);
 }
 else
   NewStoreInstr = Builder.CreateAlignedStore(IVec, AddrParts[Part],
@@ -2449,8 +2449,8 @@
 }
 auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
 if (isMaskRequired)
-  NewSI = Builder.CreateMaskedStore(
-  StoredVal, VecPtr, Alignment.value(), BlockInMaskParts[Part]);
+  NewSI = Builder.CreateMaskedStore(StoredVal, VecPtr, Alignment,
+BlockInMaskParts[Part]);
 else
   NewSI =
   Builder.CreateAlignedStore(StoredVal, VecPtr, Alignment.value());
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2904,7 +2904,7 @@
 IRBuilder<> IRB();
 Value *V = I.getArgOperand(0);
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());
 Value *Mask = I.getArgOperand(3);
 Value *Shadow = getShadow(V);
@@ -2921,21 +2921,20 @@
   insertShadowCheck(Mask, );
 }
 
-IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment ? Alignment->value() : 0,
-  Mask);
+IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment, Mask);
 
 if (MS.TrackOrigins) {
   auto  = F.getParent()->getDataLayout();
   paintOrigin(IRB, getOrigin(V), OriginPtr,
   DL.getTypeStoreSize(Shadow->getType()),
-  llvm::max(Alignment, kMinOriginAlignment));
+  std::max(Alignment, kMinOriginAlignment));
 }
   }
 
   bool handleMaskedLoad(IntrinsicInst ) {
 IRBuilder<> IRB();
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());
 Value *Mask = I.getArgOperand(2);
 Value *PassThru = I.getArgOperand(3);
@@ -2945,7 +2944,7 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
  getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(, getCleanShadow());
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1372,7 +1372,7 @@
   // on each element's most significant bit (the sign bit).
   Constant *BoolMask = getNegativeIsTrueBoolVec(ConstMask);
 
-  IC.Builder.CreateMaskedStore(Vec, PtrCast, 1, BoolMask);
+  IC.Builder.CreateMaskedStore(Vec, PtrCast, Align::None(), BoolMask);
 
   // 'Replace uses' doesn't work for stores. Erase the original masked store.
   IC.eraseInstFromFunction(II);
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -487,19 +487,19 @@
 }
 
 /// Create a call to a Masked Store intrinsic.
-/// \p Val   - data to be stored,
-/// \p Ptr   - base pointer for the store
-/// \p Align - alignment of the destination location
-/// \p Mask  - vector of booleans which indicates what vector lanes should
-///be accessed in memory
+/// \p Val   - data to be stored,
+/// \p Ptr   - base pointer for the store
+/// \p Alignment - alignment of the destination 

[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked an inline comment as done.
gchatelet added inline comments.



Comment at: llvm/docs/LangRef.rst:14945
 
-The first operand is the base pointer for the load. The second operand is the 
alignment of the source location. It must be a constant integer value. The 
third operand, mask, is a vector of boolean values with the same number of 
elements as the return type. The fourth is a pass-through value that is used to 
fill the masked-off lanes of the result. The return type, underlying type of 
the base pointer and the type of the '``passthru``' operand are the same vector 
types.
-
+The first operand is the base pointer for the load. The second operand is the 
alignment of the source location. It must be a power of two constant integer 
value. The third operand, mask, is a vector of boolean values with the same 
number of elements as the return type. The fourth is a pass-through value that 
is used to fill the masked-off lanes of the result. The return type, underlying 
type of the base pointer and the type of the '``passthru``' operand are the 
same vector types.
 

courbet wrote:
> Let's commit this as a base change, as this is just documenting what the 
> verifier is already checking.
Done as rG1d549e68d4ac58e5fcdc1c9c6d2d09334fab4fbf


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 239513.
gchatelet marked an inline comment as done.
gchatelet added a comment.

- Reverting LangRef


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2343,7 +2343,7 @@
   Value *ShuffledMask = Builder.CreateShuffleVector(
   BlockInMaskPart, Undefs, RepMask, "interleaved.mask");
   NewStoreInstr = Builder.CreateMaskedStore(
-  IVec, AddrParts[Part], Group->getAlignment(), ShuffledMask);
+  IVec, AddrParts[Part], Group->getAlign(), ShuffledMask);
 }
 else
   NewStoreInstr = Builder.CreateAlignedStore(IVec, AddrParts[Part],
@@ -2449,8 +2449,8 @@
 }
 auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
 if (isMaskRequired)
-  NewSI = Builder.CreateMaskedStore(
-  StoredVal, VecPtr, Alignment.value(), BlockInMaskParts[Part]);
+  NewSI = Builder.CreateMaskedStore(StoredVal, VecPtr, Alignment,
+BlockInMaskParts[Part]);
 else
   NewSI =
   Builder.CreateAlignedStore(StoredVal, VecPtr, Alignment.value());
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2904,7 +2904,7 @@
 IRBuilder<> IRB();
 Value *V = I.getArgOperand(0);
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());
 Value *Mask = I.getArgOperand(3);
 Value *Shadow = getShadow(V);
@@ -2921,21 +2921,20 @@
   insertShadowCheck(Mask, );
 }
 
-IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment ? Alignment->value() : 0,
-  Mask);
+IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment, Mask);
 
 if (MS.TrackOrigins) {
   auto  = F.getParent()->getDataLayout();
   paintOrigin(IRB, getOrigin(V), OriginPtr,
   DL.getTypeStoreSize(Shadow->getType()),
-  llvm::max(Alignment, kMinOriginAlignment));
+  std::max(Alignment, kMinOriginAlignment));
 }
   }
 
   bool handleMaskedLoad(IntrinsicInst ) {
 IRBuilder<> IRB();
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());
 Value *Mask = I.getArgOperand(2);
 Value *PassThru = I.getArgOperand(3);
@@ -2945,7 +2944,7 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
  getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(, getCleanShadow());
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1372,7 +1372,7 @@
   // on each element's most significant bit (the sign bit).
   Constant *BoolMask = getNegativeIsTrueBoolVec(ConstMask);
 
-  IC.Builder.CreateMaskedStore(Vec, PtrCast, 1, BoolMask);
+  IC.Builder.CreateMaskedStore(Vec, PtrCast, Align::None(), BoolMask);
 
   // 'Replace uses' doesn't work for stores. Erase the original masked store.
   IC.eraseInstFromFunction(II);
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -487,19 +487,19 @@
 }
 
 /// Create a call to a Masked Store intrinsic.
-/// \p Val   - data to be stored,
-/// \p Ptr   - base pointer for the store
-/// \p Align - alignment of the destination location
-/// \p Mask  - vector of booleans which indicates what vector lanes should
-///be accessed in memory
+/// \p Val   - data to be stored,
+/// \p Ptr   - base pointer for the store
+/// \p Alignment - alignment of the destination location
+/// \p Mask  - vector of booleans 

[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Clement Courbet via Phabricator via cfe-commits
courbet accepted this revision.
courbet added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/docs/LangRef.rst:14945
 
-The first operand is the base pointer for the load. The second operand is the 
alignment of the source location. It must be a constant integer value. The 
third operand, mask, is a vector of boolean values with the same number of 
elements as the return type. The fourth is a pass-through value that is used to 
fill the masked-off lanes of the result. The return type, underlying type of 
the base pointer and the type of the '``passthru``' operand are the same vector 
types.
-
+The first operand is the base pointer for the load. The second operand is the 
alignment of the source location. It must be a power of two constant integer 
value. The third operand, mask, is a vector of boolean values with the same 
number of elements as the return type. The fourth is a pass-through value that 
is used to fill the masked-off lanes of the result. The return type, underlying 
type of the base pointer and the type of the '``passthru``' operand are the 
same vector types.
 

Let's commit this as a base change, as this is just documenting what the 
verifier is already checking.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2907
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());

gchatelet wrote:
> courbet wrote:
> > I think it's actually OK for this one to be a `MaybeAlign`, e.g. in 
> > `ARMTTIImpl::isLegalMaskedLoad`.
> As discussed offline 
> [Verifier.cpp](https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/IR/Verifier.cpp#L4613)
>  requires the alignment to be set for both `masked_load` and `masked_store` 
> intrinsics. I've updated the documentation.
There is still the issue of already serialized bitcode files: as discussed, 
these are not an issue wrt this patch as they do not touch the API directly, 
will still generate a 0 align that will be caught by the verifier.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet marked 2 inline comments as done.
gchatelet added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2907
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());

courbet wrote:
> I think it's actually OK for this one to be a `MaybeAlign`, e.g. in 
> `ARMTTIImpl::isLegalMaskedLoad`.
As discussed offline 
[Verifier.cpp](https://github.com/llvm-mirror/llvm/blob/2c4ca6832fa6b306ee6a7010bfb80a3f2596f824/lib/IR/Verifier.cpp#L4613)
 requires the alignment to be set for both `masked_load` and `masked_store` 
intrinsics. I've updated the documentation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-22 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet updated this revision to Diff 239501.
gchatelet marked an inline comment as done.
gchatelet added a comment.

- Address comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/docs/LangRef.rst
  llvm/include/llvm/IR/Constants.h
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/CodeGen/ScalarizeMaskedMemIntrin.cpp
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2343,7 +2343,7 @@
   Value *ShuffledMask = Builder.CreateShuffleVector(
   BlockInMaskPart, Undefs, RepMask, "interleaved.mask");
   NewStoreInstr = Builder.CreateMaskedStore(
-  IVec, AddrParts[Part], Group->getAlignment(), ShuffledMask);
+  IVec, AddrParts[Part], Group->getAlign(), ShuffledMask);
 }
 else
   NewStoreInstr = Builder.CreateAlignedStore(IVec, AddrParts[Part],
@@ -2449,8 +2449,8 @@
 }
 auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
 if (isMaskRequired)
-  NewSI = Builder.CreateMaskedStore(
-  StoredVal, VecPtr, Alignment.value(), BlockInMaskParts[Part]);
+  NewSI = Builder.CreateMaskedStore(StoredVal, VecPtr, Alignment,
+BlockInMaskParts[Part]);
 else
   NewSI =
   Builder.CreateAlignedStore(StoredVal, VecPtr, Alignment.value());
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2904,7 +2904,7 @@
 IRBuilder<> IRB();
 Value *V = I.getArgOperand(0);
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());
 Value *Mask = I.getArgOperand(3);
 Value *Shadow = getShadow(V);
@@ -2921,21 +2921,20 @@
   insertShadowCheck(Mask, );
 }
 
-IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment ? Alignment->value() : 0,
-  Mask);
+IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment, Mask);
 
 if (MS.TrackOrigins) {
   auto  = F.getParent()->getDataLayout();
   paintOrigin(IRB, getOrigin(V), OriginPtr,
   DL.getTypeStoreSize(Shadow->getType()),
-  llvm::max(Alignment, kMinOriginAlignment));
+  std::max(Alignment, kMinOriginAlignment));
 }
   }
 
   bool handleMaskedLoad(IntrinsicInst ) {
 IRBuilder<> IRB();
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());
 Value *Mask = I.getArgOperand(2);
 Value *PassThru = I.getArgOperand(3);
@@ -2945,7 +2944,7 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
  getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(, getCleanShadow());
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1372,7 +1372,7 @@
   // on each element's most significant bit (the sign bit).
   Constant *BoolMask = getNegativeIsTrueBoolVec(ConstMask);
 
-  IC.Builder.CreateMaskedStore(Vec, PtrCast, 1, BoolMask);
+  IC.Builder.CreateMaskedStore(Vec, PtrCast, Align::None(), BoolMask);
 
   // 'Replace uses' doesn't work for stores. Erase the original masked store.
   IC.eraseInstFromFunction(II);
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -487,19 +487,19 @@
 }
 
 /// Create a call to a Masked Store intrinsic.
-/// \p Val   - data to be stored,
-/// \p Ptr   - base pointer for the store
-/// \p Align - alignment of the destination location
-/// \p Mask  - vector of booleans which indicates what vector lanes should
-///be accessed in memory
+/// \p Val   - data to be stored,
+/// \p Ptr   - base pointer for the store
+/// \p Alignment - alignment of the destination location
+/// \p Mask

[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-21 Thread Clement Courbet via Phabricator via cfe-commits
courbet added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2907
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());

I think it's actually OK for this one to be a `MaybeAlign`, e.g. in 
`ARMTTIImpl::isLegalMaskedLoad`.



Comment at: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp:2937
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());

ditto


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D73106/new/

https://reviews.llvm.org/D73106



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D73106: [Alignment][NFC] Use Align with CreateMaskedStore

2020-01-21 Thread Guillaume Chatelet via Phabricator via cfe-commits
gchatelet created this revision.
gchatelet added a reviewer: courbet.
Herald added subscribers: llvm-commits, cfe-commits, hiraditya.
Herald added projects: clang, LLVM.

This is patch is part of a series to introduce an Alignment type.
See this thread for context: 
http://lists.llvm.org/pipermail/llvm-dev/2019-July/133851.html
See this patch for the introduction of the type: https://reviews.llvm.org/D64790


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73106

Files:
  clang/lib/CodeGen/CGBuiltin.cpp
  llvm/include/llvm/IR/IRBuilder.h
  llvm/lib/IR/AutoUpgrade.cpp
  llvm/lib/IR/IRBuilder.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
  llvm/lib/Transforms/Vectorize/LoopVectorize.cpp

Index: llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
===
--- llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -2343,7 +2343,7 @@
   Value *ShuffledMask = Builder.CreateShuffleVector(
   BlockInMaskPart, Undefs, RepMask, "interleaved.mask");
   NewStoreInstr = Builder.CreateMaskedStore(
-  IVec, AddrParts[Part], Group->getAlignment(), ShuffledMask);
+  IVec, AddrParts[Part], Group->getAlign(), ShuffledMask);
 }
 else
   NewStoreInstr = Builder.CreateAlignedStore(IVec, AddrParts[Part],
@@ -2449,8 +2449,8 @@
 }
 auto *VecPtr = CreateVecPtr(Part, State.get(Addr, {0, 0}));
 if (isMaskRequired)
-  NewSI = Builder.CreateMaskedStore(
-  StoredVal, VecPtr, Alignment.value(), BlockInMaskParts[Part]);
+  NewSI = Builder.CreateMaskedStore(StoredVal, VecPtr, Alignment,
+BlockInMaskParts[Part]);
 else
   NewSI =
   Builder.CreateAlignedStore(StoredVal, VecPtr, Alignment.value());
Index: llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/MemorySanitizer.cpp
@@ -2904,7 +2904,7 @@
 IRBuilder<> IRB();
 Value *V = I.getArgOperand(0);
 Value *Addr = I.getArgOperand(1);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(2))->getZExtValue());
 Value *Mask = I.getArgOperand(3);
 Value *Shadow = getShadow(V);
@@ -2921,21 +2921,20 @@
   insertShadowCheck(Mask, );
 }
 
-IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment ? Alignment->value() : 0,
-  Mask);
+IRB.CreateMaskedStore(Shadow, ShadowPtr, Alignment, Mask);
 
 if (MS.TrackOrigins) {
   auto  = F.getParent()->getDataLayout();
   paintOrigin(IRB, getOrigin(V), OriginPtr,
   DL.getTypeStoreSize(Shadow->getType()),
-  llvm::max(Alignment, kMinOriginAlignment));
+  std::max(Alignment, kMinOriginAlignment));
 }
   }
 
   bool handleMaskedLoad(IntrinsicInst ) {
 IRBuilder<> IRB();
 Value *Addr = I.getArgOperand(0);
-const MaybeAlign Alignment(
+const Align Alignment(
 cast(I.getArgOperand(1))->getZExtValue());
 Value *Mask = I.getArgOperand(2);
 Value *PassThru = I.getArgOperand(3);
@@ -2945,7 +2944,7 @@
 if (PropagateShadow) {
   std::tie(ShadowPtr, OriginPtr) =
   getShadowOriginPtr(Addr, IRB, ShadowTy, Alignment, /*isStore*/ false);
-  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, *Alignment, Mask,
+  setShadow(, IRB.CreateMaskedLoad(ShadowPtr, Alignment, Mask,
  getShadow(PassThru), "_msmaskedld"));
 } else {
   setShadow(, getCleanShadow());
Index: llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
===
--- llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
+++ llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
@@ -1372,7 +1372,7 @@
   // on each element's most significant bit (the sign bit).
   Constant *BoolMask = getNegativeIsTrueBoolVec(ConstMask);
 
-  IC.Builder.CreateMaskedStore(Vec, PtrCast, 1, BoolMask);
+  IC.Builder.CreateMaskedStore(Vec, PtrCast, Align::None(), BoolMask);
 
   // 'Replace uses' doesn't work for stores. Erase the original masked store.
   IC.eraseInstFromFunction(II);
Index: llvm/lib/IR/IRBuilder.cpp
===
--- llvm/lib/IR/IRBuilder.cpp
+++ llvm/lib/IR/IRBuilder.cpp
@@ -487,19 +487,19 @@
 }
 
 /// Create a call to a Masked Store intrinsic.
-/// \p Val   - data to be stored,
-/// \p Ptr   - base pointer for the store
-/// \p Align - alignment of the destination location
-/// \p Mask  - vector of booleans which indicates what vector lanes should
-///be accessed in memory
+/// \p Val   - data to be stored,
+/// \p Ptr   -