@@ -87,28 +87,14 @@ BasicBlock *llvm::CloneBasicBlock(const BasicBlock *BB, ValueToValueMapTy &VMap,
87
87
return NewBB;
88
88
}
89
89
90
- // Clone OldFunc into NewFunc, transforming the old arguments into references to
91
- // VMap values.
92
- //
93
- void llvm::CloneFunctionInto (Function *NewFunc, const Function *OldFunc,
94
- ValueToValueMapTy &VMap,
95
- CloneFunctionChangeType Changes,
96
- SmallVectorImpl<ReturnInst *> &Returns,
97
- const char *NameSuffix, ClonedCodeInfo *CodeInfo,
98
- ValueMapTypeRemapper *TypeMapper,
99
- ValueMaterializer *Materializer) {
100
- NewFunc->setIsNewDbgInfoFormat (OldFunc->IsNewDbgInfoFormat );
101
- assert (NameSuffix && " NameSuffix cannot be null!" );
102
-
103
- #ifndef NDEBUG
104
- for (const Argument &I : OldFunc->args ())
105
- assert (VMap.count (&I) && " No mapping from source argument specified!" );
106
- #endif
107
-
108
- bool ModuleLevelChanges = Changes > CloneFunctionChangeType::LocalChangesOnly;
109
-
110
- // Copy all attributes other than those stored in the AttributeList. We need
111
- // to remap the parameter indices of the AttributeList.
90
+ void llvm::CloneFunctionAttributesInto (Function *NewFunc,
91
+ const Function *OldFunc,
92
+ ValueToValueMapTy &VMap,
93
+ bool ModuleLevelChanges,
94
+ ValueMapTypeRemapper *TypeMapper,
95
+ ValueMaterializer *Materializer) {
96
+ // Copy all attributes other than those stored in Function's AttributeList
97
+ // which holds e.g. parameters and return value attributes.
112
98
AttributeList NewAttrs = NewFunc->getAttributes ();
113
99
NewFunc->copyAttributesFrom (OldFunc);
114
100
NewFunc->setAttributes (NewAttrs);
@@ -140,6 +126,7 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
140
126
// Clone any argument attributes that are present in the VMap.
141
127
for (const Argument &OldArg : OldFunc->args ()) {
142
128
if (Argument *NewArg = dyn_cast<Argument>(VMap[&OldArg])) {
129
+ // Remap the parameter indices.
143
130
NewArgAttrs[NewArg->getArgNo ()] =
144
131
OldAttrs.getParamAttrs (OldArg.getArgNo ());
145
132
}
@@ -148,6 +135,29 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
148
135
NewFunc->setAttributes (
149
136
AttributeList::get (NewFunc->getContext (), OldAttrs.getFnAttrs (),
150
137
OldAttrs.getRetAttrs (), NewArgAttrs));
138
+ }
139
+
140
+ // Clone OldFunc into NewFunc, transforming the old arguments into references to
141
+ // VMap values.
142
+ void llvm::CloneFunctionInto (Function *NewFunc, const Function *OldFunc,
143
+ ValueToValueMapTy &VMap,
144
+ CloneFunctionChangeType Changes,
145
+ SmallVectorImpl<ReturnInst *> &Returns,
146
+ const char *NameSuffix, ClonedCodeInfo *CodeInfo,
147
+ ValueMapTypeRemapper *TypeMapper,
148
+ ValueMaterializer *Materializer) {
149
+ NewFunc->setIsNewDbgInfoFormat (OldFunc->IsNewDbgInfoFormat );
150
+ assert (NameSuffix && " NameSuffix cannot be null!" );
151
+
152
+ #ifndef NDEBUG
153
+ for (const Argument &I : OldFunc->args ())
154
+ assert (VMap.count (&I) && " No mapping from source argument specified!" );
155
+ #endif
156
+
157
+ bool ModuleLevelChanges = Changes > CloneFunctionChangeType::LocalChangesOnly;
158
+
159
+ CloneFunctionAttributesInto (NewFunc, OldFunc, VMap, ModuleLevelChanges,
160
+ TypeMapper, Materializer);
151
161
152
162
// Everything else beyond this point deals with function instructions,
153
163
// so if we are dealing with a function declaration, we're done.
0 commit comments