llvm.org GIT mirror llvm / 31ec98d
[Alignment][NFC] Convert StoreInst to MaybeAlign Summary: 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: hiraditya, jfb, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D69303 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375499 91177308-0d34-0410-b5e6-96231b3b80d8 Guillaume Chatelet 1 year, 1 day ago
8 changed file(s) with 40 addition(s) and 47 deletion(s). Raw diff Collapse all Expand all
336336 StoreInst(Value *Val, Value *Ptr, bool isVolatile = false,
337337 Instruction *InsertBefore = nullptr);
338338 StoreInst(Value *Val, Value *Ptr, bool isVolatile, BasicBlock *InsertAtEnd);
339 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
340 unsigned Align, Instruction *InsertBefore = nullptr);
341 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
342 unsigned Align, BasicBlock *InsertAtEnd);
343 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
344 unsigned Align, AtomicOrdering Order,
345 SyncScope::ID SSID = SyncScope::System,
339 StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
346340 Instruction *InsertBefore = nullptr);
347 StoreInst(Value *Val, Value *Ptr, bool isVolatile,
348 unsigned Align, AtomicOrdering Order, SyncScope::ID SSID,
341 StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
349342 BasicBlock *InsertAtEnd);
343 StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
344 AtomicOrdering Order, SyncScope::ID SSID = SyncScope::System,
345 Instruction *InsertBefore = nullptr);
346 StoreInst(Value *Val, Value *Ptr, bool isVolatile, MaybeAlign Align,
347 AtomicOrdering Order, SyncScope::ID SSID, BasicBlock *InsertAtEnd);
350348
351349 // allocate space for exactly two operands
352350 void *operator new(size_t s) {
70157015 Ordering == AtomicOrdering::AcquireRelease)
70167016 return Error(Loc, "atomic store cannot use Acquire ordering");
70177017
7018 Inst = new StoreInst(Val, Ptr, isVolatile, Alignment ? Alignment->value() : 0,
7019 Ordering, SSID);
7018 Inst = new StoreInst(Val, Ptr, isVolatile, Alignment, Ordering, SSID);
70207019 return AteExtraComma ? InstExtraComma : InstNormal;
70217020 }
70227021
48504850 MaybeAlign Align;
48514851 if (Error Err = parseAlignmentValue(Record[OpNum], Align))
48524852 return Err;
4853 I = new StoreInst(Val, Ptr, Record[OpNum + 1],
4854 Align ? Align->value() : 0);
4853 I = new StoreInst(Val, Ptr, Record[OpNum + 1], Align);
48554854 InstructionList.push_back(I);
48564855 break;
48574856 }
48844883 MaybeAlign Align;
48854884 if (Error Err = parseAlignmentValue(Record[OpNum], Align))
48864885 return Err;
4887 I = new StoreInst(Val, Ptr, Record[OpNum + 1], Align ? Align->value() : 0,
4888 Ordering, SSID);
4886 I = new StoreInst(Val, Ptr, Record[OpNum + 1], Align, Ordering, SSID);
48894887 InstructionList.push_back(I);
48904888 break;
48914889 }
13701370
13711371 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
13721372 Instruction *InsertBefore)
1373 : StoreInst(val, addr, isVolatile, /*Align=*/0, InsertBefore) {}
1373 : StoreInst(val, addr, isVolatile, /*Align=*/None, InsertBefore) {}
13741374
13751375 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
13761376 BasicBlock *InsertAtEnd)
1377 : StoreInst(val, addr, isVolatile, /*Align=*/0, InsertAtEnd) {}
1378
1379 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align,
1377 : StoreInst(val, addr, isVolatile, /*Align=*/None, InsertAtEnd) {}
1378
1379 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
13801380 Instruction *InsertBefore)
13811381 : StoreInst(val, addr, isVolatile, Align, AtomicOrdering::NotAtomic,
13821382 SyncScope::System, InsertBefore) {}
13831383
1384 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, unsigned Align,
1384 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
13851385 BasicBlock *InsertAtEnd)
13861386 : StoreInst(val, addr, isVolatile, Align, AtomicOrdering::NotAtomic,
13871387 SyncScope::System, InsertAtEnd) {}
13881388
1389 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
1390 unsigned Align, AtomicOrdering Order,
1391 SyncScope::ID SSID,
1389 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1390 AtomicOrdering Order, SyncScope::ID SSID,
13921391 Instruction *InsertBefore)
1393 : Instruction(Type::getVoidTy(val->getContext()), Store,
1394 OperandTraits::op_begin(this),
1395 OperandTraits::operands(this),
1396 InsertBefore) {
1392 : Instruction(Type::getVoidTy(val->getContext()), Store,
1393 OperandTraits::op_begin(this),
1394 OperandTraits::operands(this), InsertBefore) {
13971395 Op<0>() = val;
13981396 Op<1>() = addr;
13991397 setVolatile(isVolatile);
1400 setAlignment(MaybeAlign(Align));
1398 setAlignment(Align);
14011399 setAtomic(Order, SSID);
14021400 AssertOK();
14031401 }
14041402
1405 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
1406 unsigned Align, AtomicOrdering Order,
1407 SyncScope::ID SSID,
1403 StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile, MaybeAlign Align,
1404 AtomicOrdering Order, SyncScope::ID SSID,
14081405 BasicBlock *InsertAtEnd)
1409 : Instruction(Type::getVoidTy(val->getContext()), Store,
1410 OperandTraits::op_begin(this),
1411 OperandTraits::operands(this),
1412 InsertAtEnd) {
1406 : Instruction(Type::getVoidTy(val->getContext()), Store,
1407 OperandTraits::op_begin(this),
1408 OperandTraits::operands(this), InsertAtEnd) {
14131409 Op<0>() = val;
14141410 Op<1>() = addr;
14151411 setVolatile(isVolatile);
1416 setAlignment(MaybeAlign(Align));
1412 setAlignment(Align);
14171413 setAtomic(Order, SSID);
14181414 AssertOK();
14191415 }
41454141
41464142 StoreInst *StoreInst::cloneImpl() const {
41474143 return new StoreInst(getOperand(0), getOperand(1), isVolatile(),
4148 getAlignment(), getOrdering(), getSyncScopeID());
4149
4144 MaybeAlign(getAlignment()), getOrdering(),
4145 getSyncScopeID());
41504146 }
41514147
41524148 AtomicCmpXchgInst *AtomicCmpXchgInst::cloneImpl() const {
890890 while (!GV->use_empty()) {
891891 if (StoreInst *SI = dyn_cast(GV->user_back())) {
892892 // The global is initialized when the store to it occurs.
893 new StoreInst(ConstantInt::getTrue(GV->getContext()), InitBool, false, 0,
894 SI->getOrdering(), SI->getSyncScopeID(), SI);
893 new StoreInst(ConstantInt::getTrue(GV->getContext()), InitBool, false,
894 None, SI->getOrdering(), SI->getSyncScopeID(), SI);
895895 SI->eraseFromParent();
896896 continue;
897897 }
17251725 }
17261726 }
17271727 StoreInst *NSI =
1728 new StoreInst(StoreVal, NewGV, false, 0, SI->getOrdering(),
1728 new StoreInst(StoreVal, NewGV, false, None, SI->getOrdering(),
17291729 SI->getSyncScopeID(), SI);
17301730 NSI->setDebugLoc(SI->getDebugLoc());
17311731 } else {
10841084 // If the mask is all ones, this is a plain vector store of the 1st argument.
10851085 if (ConstMask->isAllOnesValue()) {
10861086 Value *StorePtr = II.getArgOperand(1);
1087 unsigned Alignment = cast(II.getArgOperand(2))->getZExtValue();
1087 MaybeAlign Alignment(
1088 cast(II.getArgOperand(2))->getZExtValue());
10881089 return new StoreInst(II.getArgOperand(0), StorePtr, false, Alignment);
10891090 }
10901091
23592360 // Turn PPC VSX stores into normal stores.
23602361 Type *OpPtrTy = PointerType::getUnqual(II->getArgOperand(0)->getType());
23612362 Value *Ptr = Builder.CreateBitCast(II->getArgOperand(1), OpPtrTy);
2362 return new StoreInst(II->getArgOperand(0), Ptr, false, 1);
2363 return new StoreInst(II->getArgOperand(0), Ptr, false, Align::None());
23632364 }
23642365 case Intrinsic::ppc_qpx_qvlfs:
23652366 // Turn PPC QPX qvlfs -> load if the pointer is known aligned.
15781578
15791579 // Advance to a place where it is safe to insert the new store and insert it.
15801580 BBI = DestBB->getFirstInsertionPt();
1581 StoreInst *NewSI = new StoreInst(MergedVal, SI.getOperand(1),
1582 SI.isVolatile(), SI.getAlignment(),
1581 StoreInst *NewSI = new StoreInst(MergedVal, SI.getOperand(1), SI.isVolatile(),
1582 MaybeAlign(SI.getAlignment()),
15831583 SI.getOrdering(), SI.getSyncScopeID());
15841584 InsertNewInstBefore(NewSI, *BBI);
15851585 NewSI->setDebugLoc(MergedLoc);
12531253
12541254 auto *SI = new StoreInst(
12551255 ConstantInt::get(Earlier->getValueOperand()->getType(), Merged),
1256 Earlier->getPointerOperand(), false, Earlier->getAlignment(),
1257 Earlier->getOrdering(), Earlier->getSyncScopeID(), DepWrite);
1256 Earlier->getPointerOperand(), false,
1257 MaybeAlign(Earlier->getAlignment()), Earlier->getOrdering(),
1258 Earlier->getSyncScopeID(), DepWrite);
12581259
12591260 unsigned MDToKeep[] = {LLVMContext::MD_dbg, LLVMContext::MD_tbaa,
12601261 LLVMContext::MD_alias_scope,