forked from OSchip/llvm-project
[OpaquePtr] Use byval type more
This commit is contained in:
parent
113a807977
commit
ab5693aa4a
|
@ -1157,7 +1157,7 @@ static StructType *buildFrameType(Function &F, coro::Shape &Shape,
|
||||||
// instead of the pointer itself.
|
// instead of the pointer itself.
|
||||||
if (const Argument *A = dyn_cast<Argument>(S.first))
|
if (const Argument *A = dyn_cast<Argument>(S.first))
|
||||||
if (A->hasByValAttr())
|
if (A->hasByValAttr())
|
||||||
FieldType = FieldType->getPointerElementType();
|
FieldType = A->getParamByValType();
|
||||||
FieldIDType Id =
|
FieldIDType Id =
|
||||||
B.addField(FieldType, None, false /*header*/, true /*IsSpillOfValue*/);
|
B.addField(FieldType, None, false /*header*/, true /*IsSpillOfValue*/);
|
||||||
FrameData.setFieldIndex(S.first, Id);
|
FrameData.setFieldIndex(S.first, Id);
|
||||||
|
|
|
@ -139,7 +139,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
|
||||||
++I, ++ArgNo) {
|
++I, ++ArgNo) {
|
||||||
if (ByValArgsToTransform.count(&*I)) {
|
if (ByValArgsToTransform.count(&*I)) {
|
||||||
// Simple byval argument? Just add all the struct element types.
|
// Simple byval argument? Just add all the struct element types.
|
||||||
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
|
Type *AgTy = I->getParamByValType();
|
||||||
StructType *STy = cast<StructType>(AgTy);
|
StructType *STy = cast<StructType>(AgTy);
|
||||||
llvm::append_range(Params, STy->elements());
|
llvm::append_range(Params, STy->elements());
|
||||||
ArgAttrVec.insert(ArgAttrVec.end(), STy->getNumElements(),
|
ArgAttrVec.insert(ArgAttrVec.end(), STy->getNumElements(),
|
||||||
|
@ -260,7 +260,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
|
||||||
ArgAttrVec.push_back(CallPAL.getParamAttributes(ArgNo));
|
ArgAttrVec.push_back(CallPAL.getParamAttributes(ArgNo));
|
||||||
} else if (ByValArgsToTransform.count(&*I)) {
|
} else if (ByValArgsToTransform.count(&*I)) {
|
||||||
// Emit a GEP and load for each element of the struct.
|
// Emit a GEP and load for each element of the struct.
|
||||||
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
|
Type *AgTy = I->getParamByValType();
|
||||||
StructType *STy = cast<StructType>(AgTy);
|
StructType *STy = cast<StructType>(AgTy);
|
||||||
Value *Idxs[2] = {
|
Value *Idxs[2] = {
|
||||||
ConstantInt::get(Type::getInt32Ty(F->getContext()), 0), nullptr};
|
ConstantInt::get(Type::getInt32Ty(F->getContext()), 0), nullptr};
|
||||||
|
@ -387,7 +387,7 @@ doPromotion(Function *F, SmallPtrSetImpl<Argument *> &ArgsToPromote,
|
||||||
Instruction *InsertPt = &NF->begin()->front();
|
Instruction *InsertPt = &NF->begin()->front();
|
||||||
|
|
||||||
// Just add all the struct element types.
|
// Just add all the struct element types.
|
||||||
Type *AgTy = cast<PointerType>(I->getType())->getElementType();
|
Type *AgTy = I->getParamByValType();
|
||||||
Align StructAlign = *I->getParamAlign();
|
Align StructAlign = *I->getParamAlign();
|
||||||
Value *TheAlloca = new AllocaInst(AgTy, DL.getAllocaAddrSpace(), nullptr,
|
Value *TheAlloca = new AllocaInst(AgTy, DL.getAllocaAddrSpace(), nullptr,
|
||||||
StructAlign, "", InsertPt);
|
StructAlign, "", InsertPt);
|
||||||
|
|
|
@ -1583,7 +1583,7 @@ bool MemCpyOptPass::processByValArgument(CallBase &CB, unsigned ArgNo) {
|
||||||
const DataLayout &DL = CB.getCaller()->getParent()->getDataLayout();
|
const DataLayout &DL = CB.getCaller()->getParent()->getDataLayout();
|
||||||
// Find out what feeds this byval argument.
|
// Find out what feeds this byval argument.
|
||||||
Value *ByValArg = CB.getArgOperand(ArgNo);
|
Value *ByValArg = CB.getArgOperand(ArgNo);
|
||||||
Type *ByValTy = cast<PointerType>(ByValArg->getType())->getElementType();
|
Type *ByValTy = CB.getParamByValType(ArgNo);
|
||||||
uint64_t ByValSize = DL.getTypeAllocSize(ByValTy);
|
uint64_t ByValSize = DL.getTypeAllocSize(ByValTy);
|
||||||
MemoryLocation Loc(ByValArg, LocationSize::precise(ByValSize));
|
MemoryLocation Loc(ByValArg, LocationSize::precise(ByValSize));
|
||||||
MemCpyInst *MDep = nullptr;
|
MemCpyInst *MDep = nullptr;
|
||||||
|
|
Loading…
Reference in New Issue