Skip to content

Commit 4658da1

Browse files
committed
Revert "[Alignment][NFC] Deprecate CreateMemCpy/CreateMemMove"
This reverts commit 181ab91.
1 parent f4dfae9 commit 4658da1

19 files changed

+144
-197
lines changed

llvm/include/llvm/IR/Argument.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,8 @@ class Argument final : public Value {
7676
bool hasByValOrInAllocaAttr() const;
7777

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

83-
/// If this is a byval or inalloca argument, return its alignment.
84-
MaybeAlign getParamAlign() const;
85-
8681
/// If this is a byval argument, return its type.
8782
Type *getParamByValType() const;
8883

llvm/include/llvm/IR/Function.h

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -435,18 +435,12 @@ class Function : public GlobalObject, public ilist_node<Function> {
435435
void addDereferenceableOrNullParamAttr(unsigned ArgNo, uint64_t Bytes);
436436

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

446-
MaybeAlign getParamAlign(unsigned ArgNo) const {
447-
return AttributeSets.getParamAlignment(ArgNo);
448-
}
449-
450444
/// Extract the byval type for a parameter.
451445
Type *getParamByValType(unsigned ArgNo) const {
452446
Type *Ty = AttributeSets.getParamByValType(ArgNo);

llvm/include/llvm/IR/IRBuilder.h

Lines changed: 21 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -493,14 +493,12 @@ class IRBuilderBase {
493493
/// and noalias tags.
494494
/// FIXME: Remove this function once transition to Align is over.
495495
/// Use the version that takes MaybeAlign instead of this one.
496-
LLVM_ATTRIBUTE_DEPRECATED(
497-
CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
498-
unsigned SrcAlign, uint64_t Size,
499-
bool isVolatile = false, MDNode *TBAATag = nullptr,
500-
MDNode *TBAAStructTag = nullptr,
501-
MDNode *ScopeTag = nullptr,
502-
MDNode *NoAliasTag = nullptr),
503-
"Use the version that takes MaybeAlign instead") {
496+
CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
497+
unsigned SrcAlign, uint64_t Size,
498+
bool isVolatile = false, MDNode *TBAATag = nullptr,
499+
MDNode *TBAAStructTag = nullptr,
500+
MDNode *ScopeTag = nullptr,
501+
MDNode *NoAliasTag = nullptr) {
504502
return CreateMemCpy(Dst, MaybeAlign(DstAlign), Src, MaybeAlign(SrcAlign),
505503
getInt64(Size), isVolatile, TBAATag, TBAAStructTag,
506504
ScopeTag, NoAliasTag);
@@ -519,14 +517,12 @@ class IRBuilderBase {
519517

520518
/// FIXME: Remove this function once transition to Align is over.
521519
/// Use the version that takes MaybeAlign instead of this one.
522-
LLVM_ATTRIBUTE_DEPRECATED(
523-
CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
524-
unsigned SrcAlign, Value *Size,
525-
bool isVolatile = false, MDNode *TBAATag = nullptr,
526-
MDNode *TBAAStructTag = nullptr,
527-
MDNode *ScopeTag = nullptr,
528-
MDNode *NoAliasTag = nullptr),
529-
"Use the version that takes MaybeAlign instead");
520+
CallInst *CreateMemCpy(Value *Dst, unsigned DstAlign, Value *Src,
521+
unsigned SrcAlign, Value *Size,
522+
bool isVolatile = false, MDNode *TBAATag = nullptr,
523+
MDNode *TBAAStructTag = nullptr,
524+
MDNode *ScopeTag = nullptr,
525+
MDNode *NoAliasTag = nullptr);
530526
CallInst *CreateMemCpy(Value *Dst, MaybeAlign DstAlign, Value *Src,
531527
MaybeAlign SrcAlign, Value *Size,
532528
bool isVolatile = false, MDNode *TBAATag = nullptr,
@@ -566,12 +562,10 @@ class IRBuilderBase {
566562
/// and noalias tags.
567563
/// FIXME: Remove this function once transition to Align is over.
568564
/// Use the version that takes MaybeAlign instead of this one.
569-
LLVM_ATTRIBUTE_DEPRECATED(
570-
CallInst *CreateMemMove(
571-
Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
572-
uint64_t Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
573-
MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr),
574-
"Use the version that takes MaybeAlign") {
565+
CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
566+
uint64_t Size, bool isVolatile = false,
567+
MDNode *TBAATag = nullptr, MDNode *ScopeTag = nullptr,
568+
MDNode *NoAliasTag = nullptr) {
575569
return CreateMemMove(Dst, DstAlign, Src, SrcAlign, getInt64(Size), isVolatile,
576570
TBAATag, ScopeTag, NoAliasTag);
577571
}
@@ -585,12 +579,11 @@ class IRBuilderBase {
585579
}
586580
/// FIXME: Remove this function once transition to Align is over.
587581
/// Use the version that takes MaybeAlign instead of this one.
588-
LLVM_ATTRIBUTE_DEPRECATED(
589-
CallInst *CreateMemMove(
590-
Value *Dst, unsigned DstAlign, Value *Src, unsigned SrcAlign,
591-
Value *Size, bool isVolatile = false, MDNode *TBAATag = nullptr,
592-
MDNode *ScopeTag = nullptr, MDNode *NoAliasTag = nullptr),
593-
"Use the version that takes MaybeAlign") {
582+
CallInst *CreateMemMove(Value *Dst, unsigned DstAlign, Value *Src,
583+
unsigned SrcAlign, Value *Size,
584+
bool isVolatile = false, MDNode *TBAATag = nullptr,
585+
MDNode *ScopeTag = nullptr,
586+
MDNode *NoAliasTag = nullptr) {
594587
return CreateMemMove(Dst, MaybeAlign(DstAlign), Src, MaybeAlign(SrcAlign),
595588
Size, isVolatile, TBAATag, ScopeTag, NoAliasTag);
596589
}

llvm/include/llvm/IR/InstrTypes.h

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1585,31 +1585,19 @@ class CallBase : public Instruction {
15851585
}
15861586

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

1596-
/// Extract the alignment of the return value.
1597-
MaybeAlign getRetAlign() const { return Attrs.getRetAlignment(); }
1598-
15991594
/// Extract the alignment for a call or parameter (0=unknown).
1600-
/// FIXME: Remove this function once transition to Align is over.
1601-
/// Use getParamAlign() instead.
16021595
unsigned getParamAlignment(unsigned ArgNo) const {
16031596
if (const auto MA = Attrs.getParamAlignment(ArgNo))
16041597
return MA->value();
16051598
return 0;
16061599
}
16071600

1608-
/// Extract the alignment for a call or parameter (0=unknown).
1609-
MaybeAlign getParamAlign(unsigned ArgNo) const {
1610-
return Attrs.getParamAlignment(ArgNo);
1611-
}
1612-
16131601
/// Extract the byval type for a call or parameter.
16141602
Type *getParamByValType(unsigned ArgNo) const {
16151603
Type *Ty = Attrs.getParamByValType(ArgNo);

llvm/include/llvm/IR/Instructions.h

Lines changed: 6 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -239,20 +239,14 @@ class LoadInst : public UnaryInstruction {
239239
}
240240

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

250-
/// Return the alignment of the access that is being performed.
251-
MaybeAlign getAlign() const {
252-
return decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
253-
}
254-
255-
void setAlignment(MaybeAlign Alignment);
249+
void setAlignment(MaybeAlign Align);
256250

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

373367
/// Return the alignment of the access that is being performed
374-
/// FIXME: Remove this function once transition to Align is over.
375-
/// Use getAlign() instead.
376368
unsigned getAlignment() const {
377-
if (const auto MA = getAlign())
369+
if (const auto MA =
370+
decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31))
378371
return MA->value();
379372
return 0;
380373
}
381374

382-
MaybeAlign getAlign() const {
383-
return decodeMaybeAlign((getSubclassDataFromInstruction() >> 1) & 31);
384-
}
385-
386-
void setAlignment(MaybeAlign Alignment);
375+
void setAlignment(MaybeAlign Align);
387376

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

llvm/include/llvm/IR/IntrinsicInst.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -348,10 +348,7 @@ namespace llvm {
348348
return cast<PointerType>(getRawDest()->getType())->getAddressSpace();
349349
}
350350

351-
/// FIXME: Remove this function once transition to Align is over.
352-
/// Use getDestAlign() instead.
353351
unsigned getDestAlignment() const { return getParamAlignment(ARG_DEST); }
354-
MaybeAlign getDestAlign() const { return getParamAlign(ARG_DEST); }
355352

356353
/// Set the specified arguments of the instruction.
357354
void setDest(Value *Ptr) {
@@ -409,16 +406,10 @@ namespace llvm {
409406
return cast<PointerType>(getRawSource()->getType())->getAddressSpace();
410407
}
411408

412-
/// FIXME: Remove this function once transition to Align is over.
413-
/// Use getSourceAlign() instead.
414409
unsigned getSourceAlignment() const {
415410
return BaseCL::getParamAlignment(ARG_SOURCE);
416411
}
417412

418-
MaybeAlign getSourceAlign() const {
419-
return BaseCL::getParamAlign(ARG_SOURCE);
420-
}
421-
422413
void setSource(Value *Ptr) {
423414
assert(getRawSource()->getType() == Ptr->getType() &&
424415
"setSource called with pointer of wrong type!");

llvm/lib/CodeGen/SafeStack.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -563,7 +563,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
563563

564564
for (Argument *Arg : ByValArguments) {
565565
unsigned Offset = SSL.getObjectOffset(Arg);
566-
MaybeAlign Align(SSL.getObjectAlignment(Arg));
566+
unsigned Align = SSL.getObjectAlignment(Arg);
567567
Type *Ty = Arg->getType()->getPointerElementType();
568568

569569
uint64_t Size = DL.getTypeStoreSize(Ty);
@@ -580,7 +580,7 @@ Value *SafeStack::moveStaticAllocasToUnsafeStack(
580580
DIExpression::ApplyOffset, -Offset);
581581
Arg->replaceAllUsesWith(NewArg);
582582
IRB.SetInsertPoint(cast<Instruction>(NewArg)->getNextNode());
583-
IRB.CreateMemCpy(Off, Align, Arg, Arg->getParamAlign(), Size);
583+
IRB.CreateMemCpy(Off, Align, Arg, Arg->getParamAlignment(), Size);
584584
}
585585

586586
// Allocate space for every unsafe static AllocaInst on the unsafe stack.

llvm/lib/IR/Core.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3450,17 +3450,17 @@ LLVMValueRef LLVMBuildMemCpy(LLVMBuilderRef B,
34503450
LLVMValueRef Dst, unsigned DstAlign,
34513451
LLVMValueRef Src, unsigned SrcAlign,
34523452
LLVMValueRef Size) {
3453-
return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), MaybeAlign(DstAlign),
3454-
unwrap(Src), MaybeAlign(SrcAlign),
3453+
return wrap(unwrap(B)->CreateMemCpy(unwrap(Dst), DstAlign,
3454+
unwrap(Src), SrcAlign,
34553455
unwrap(Size)));
34563456
}
34573457

34583458
LLVMValueRef LLVMBuildMemMove(LLVMBuilderRef B,
34593459
LLVMValueRef Dst, unsigned DstAlign,
34603460
LLVMValueRef Src, unsigned SrcAlign,
34613461
LLVMValueRef Size) {
3462-
return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), MaybeAlign(DstAlign),
3463-
unwrap(Src), MaybeAlign(SrcAlign),
3462+
return wrap(unwrap(B)->CreateMemMove(unwrap(Dst), DstAlign,
3463+
unwrap(Src), SrcAlign,
34643464
unwrap(Size)));
34653465
}
34663466

llvm/lib/IR/Function.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,11 +126,6 @@ unsigned Argument::getParamAlignment() const {
126126
return getParent()->getParamAlignment(getArgNo());
127127
}
128128

129-
MaybeAlign Argument::getParamAlign() const {
130-
assert(getType()->isPointerTy() && "Only pointers have alignments");
131-
return getParent()->getParamAlign(getArgNo());
132-
}
133-
134129
Type *Argument::getParamByValType() const {
135130
assert(getType()->isPointerTy() && "Only pointers have byval types");
136131
return getParent()->getParamByValType(getArgNo());

llvm/lib/IR/Instructions.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1342,7 +1342,11 @@ void LoadInst::setAlignment(MaybeAlign Align) {
13421342
"Alignment is greater than MaximumAlignment!");
13431343
setInstructionSubclassData((getSubclassDataFromInstruction() & ~(31 << 1)) |
13441344
(encode(Align) << 1));
1345-
assert(getAlign() == Align && "Alignment representation error!");
1345+
if (Align)
1346+
assert(getAlignment() == Align->value() &&
1347+
"Alignment representation error!");
1348+
else
1349+
assert(getAlignment() == 0 && "Alignment representation error!");
13461350
}
13471351

13481352
//===----------------------------------------------------------------------===//
@@ -1412,12 +1416,16 @@ StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
14121416
AssertOK();
14131417
}
14141418

1415-
void StoreInst::setAlignment(MaybeAlign Alignment) {
1416-
assert((!Alignment || *Alignment <= MaximumAlignment) &&
1419+
void StoreInst::setAlignment(MaybeAlign Align) {
1420+
assert((!Align || *Align <= MaximumAlignment) &&
14171421
"Alignment is greater than MaximumAlignment!");
14181422
setInstructionSubclassData((getSubclassDataFromInstruction() & ~(31 << 1)) |
1419-
(encode(Alignment) << 1));
1420-
assert(getAlign() == Alignment && "Alignment representation error!");
1423+
(encode(Align) << 1));
1424+
if (Align)
1425+
assert(getAlignment() == Align->value() &&
1426+
"Alignment representation error!");
1427+
else
1428+
assert(getAlignment() == 0 && "Alignment representation error!");
14211429
}
14221430

14231431
//===----------------------------------------------------------------------===//

0 commit comments

Comments
 (0)