Commit 181ab91e authored by Guillaume Chatelet's avatar Guillaume Chatelet
Browse files

[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove

Summary:
This patch introduces a set of functions to enable deprecation of IRBuilder functions without breaking out of tree clients.
Functions will be deprecated one by one and as in tree code is cleaned up.

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

Reviewers: courbet

Subscribers: arsenm, jvesely, nhaehnle, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71473
parent c41d2b5a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -76,8 +76,13 @@ public:
  bool hasByValOrInAllocaAttr() const;

  /// If this is a byval or inalloca argument, return its alignment.
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getParamAlign() instead.
  unsigned getParamAlignment() const;

  /// If this is a byval or inalloca argument, return its alignment.
  MaybeAlign getParamAlign() const;

  /// If this is a byval argument, return its type.
  Type *getParamByValType() const;

+7 −1
Original line number Diff line number Diff line
@@ -435,12 +435,18 @@ public:
  void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);

  /// Extract the alignment for a call or parameter (0=unknown).
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getParamAlign() instead.
  unsigned getParamAlignment(unsigned ArgNo) const {
    if (const auto MA = AttributeSets.getParamAlignment(ArgNo))
    if (const auto MA = getParamAlign(ArgNo))
      return MA->value();
    return 0;
  }

  MaybeAlign getParamAlign(unsigned ArgNo) const {
    return AttributeSets.getParamAlignment(ArgNo);
  }

  /// Extract the byval type for a parameter.
  Type *getParamByValType(unsigned ArgNo) const {
    Type *Ty = AttributeSets.getParamByValType(ArgNo);
+28 −21
Original line number Diff line number Diff line
@@ -493,12 +493,14 @@ public:
  /// and noalias tags.
  /// FIXME: Remove this function once transition to Align is over.
  /// Use the version that takes MaybeAlign instead of this one.
  LLVM_ATTRIBUTE_DEPRECATED(
      CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
                             unsigned SrcAlign, uint64_t Size,
                             bool isVolatile = false, MDNode *TBAATag = nullptr,
                             MDNode *TBAAStructTag = nullptr,
                             MDNode *ScopeTag = nullptr,
                         MDNode *NoAliasTag = nullptr) {
                             MDNode *NoAliasTag = nullptr),
      "Use the version that takes MaybeAlign instead") {
    return CreateMemCpy(Dst, MaybeAlign(DstAlign), Src, MaybeAlign(SrcAlign),
                        getInt64(Size), isVolatile, TBAATag, TBAAStructTag,
                        ScopeTag, NoAliasTag);
@@ -517,12 +519,14 @@ public:

  /// FIXME: Remove this function once transition to Align is over.
  /// Use the version that takes MaybeAlign instead of this one.
  LLVM_ATTRIBUTE_DEPRECATED(
      CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
                             unsigned SrcAlign, Value *Size,
                             bool isVolatile = false, MDNode *TBAATag = nullptr,
                             MDNode *TBAAStructTag = nullptr,
                             MDNode *ScopeTag = nullptr,
                         MDNode *NoAliasTag = nullptr);
                             MDNode *NoAliasTag = nullptr),
      "Use the version that takes MaybeAlign instead");
  CallInst *CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src,
                         MaybeAlign SrcAlign, Value *Size,
                         bool isVolatile = false, MDNode *TBAATag = nullptr,
@@ -562,10 +566,12 @@ public:
  /// and noalias tags.
  /// FIXME: Remove this function once transition to Align is over.
  /// Use the version that takes MaybeAlign instead of this one.
  CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
                          uint64_t Size, bool isVolatile = false,
                          MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr,
                          MDNode *NoAliasTag = nullptr) {
  LLVM_ATTRIBUTE_DEPRECATED(
      CallInst *CreateMemMove(
          Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
          uint64_t Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
          MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr),
      "Use the version that takes MaybeAlign") {
    return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size), isVolatile,
                         TBAATag, ScopeTag, NoAliasTag);
  }
@@ -579,11 +585,12 @@ public:
  }
  /// FIXME: Remove this function once transition to Align is over.
  /// Use the version that takes MaybeAlign instead of this one.
  CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src,
                          unsigned SrcAlign, Value *Size,
                          bool isVolatile = false, MDNode *TBAATag = nullptr,
                          MDNode *ScopeTag = nullptr,
                          MDNode *NoAliasTag = nullptr) {
  LLVM_ATTRIBUTE_DEPRECATED(
      CallInst *CreateMemMove(
          Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
          Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
          MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr),
      "Use the version that takes MaybeAlign") {
    return CreateMemMove(Dst, MaybeAlign(DstAlign), Src, MaybeAlign(SrcAlign),
                         Size, isVolatile, TBAATag, ScopeTag, NoAliasTag);
  }
+12 −0
Original line number Diff line number Diff line
@@ -1585,19 +1585,31 @@ public:
  }

  /// Extract the alignment of the return value.
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getRetAlign() instead.
  unsigned getRetAlignment() const {
    if (const auto MA = Attrs.getRetAlignment())
      return MA->value();
    return 0;
  }

  /// Extract the alignment of the return value.
  MaybeAlign getRetAlign() const { return Attrs.getRetAlignment(); }

  /// Extract the alignment for a call or parameter (0=unknown).
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getParamAlign() instead.
  unsigned getParamAlignment(unsigned ArgNo) const {
    if (const auto MA = Attrs.getParamAlignment(ArgNo))
      return MA->value();
    return 0;
  }

  /// Extract the alignment for a call or parameter (0=unknown).
  MaybeAlign getParamAlign(unsigned ArgNo) const {
    return Attrs.getParamAlignment(ArgNo);
  }

  /// Extract the byval type for a call or parameter.
  Type *getParamByValType(unsigned ArgNo) const {
    Type *Ty = Attrs.getParamByValType(ArgNo);
+17 −6
Original line number Diff line number Diff line
@@ -239,14 +239,20 @@ public:
  }

  /// Return the alignment of the access that is being performed.
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getAlign() instead.
  unsigned getAlignment() const {
    if (const auto MA =
            decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31))
    if (const auto MA = getAlign())
      return MA->value();
    return 0;
  }

  void setAlignment(MaybeAlign Align);
  /// Return the alignment of the access that is being performed.
  MaybeAlign getAlign() const {
    return decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
  }

  void setAlignment(MaybeAlign Alignment);

  /// Returns the ordering constraint of this load instruction.
  AtomicOrdering getOrdering() const {
@@ -365,14 +371,19 @@ public:
  DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);

  /// Return the alignment of the access that is being performed
  /// FIXME: Remove this function once transition to Align is over.
  /// Use getAlign() instead.
  unsigned getAlignment() const {
    if (const auto MA =
            decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31))
    if (const auto MA = getAlign())
      return MA->value();
    return 0;
  }

  void setAlignment(MaybeAlign Align);
  MaybeAlign getAlign() const {
    return decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
  }

  void setAlignment(MaybeAlign Alignment);

  /// Returns the ordering constraint of this store instruction.
  AtomicOrdering getOrdering() const {
Loading