@@ -36,6 +36,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
36
36
#include " common/LLVMWarningsPop.hpp"
37
37
#include " LLVM3DBuilder/BuiltinsFrontend.hpp"
38
38
39
+ #include " common/FunctionUpgrader.h"
40
+
39
41
using namespace IGC ;
40
42
using namespace IGC ::IGCMD;
41
43
using namespace llvm ;
@@ -215,10 +217,14 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
215
217
Module* M = samplePhase->getParent ();
216
218
CodeGenContext* ctx = getAnalysis<CodeGenContextWrapper>().getCodeGenContext ();
217
219
LLVM3DBuilder<> builder (samplePhase->getContext (), ctx->platform .getPlatformInfo ());
218
-
220
+
221
+ FunctionUpgrader FuncUpgrader;
222
+
223
+ FuncUpgrader.SetFunctionToUpgrade (samplePhase);
224
+
219
225
// find all the phase inputs
220
226
Function* phaseInput = GenISAIntrinsic::getDeclaration (M, GenISAIntrinsic::GenISA_PHASE_INPUT);
221
- Value* sampleIndex = new llvm::Argument (builder. getInt32Ty (), " " , samplePhase );
227
+ Value* sampleIndex = FuncUpgrader. AddArgument ( " " , builder. getInt32Ty () );
222
228
223
229
SmallVector<Type*, 10 > funcSignature;
224
230
funcSignature.push_back (builder.getInt32Ty ());
@@ -238,7 +244,7 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
238
244
}
239
245
else
240
246
{
241
- arg = new llvm::Argument ( inst->getType (), " " , samplePhase );
247
+ arg = FuncUpgrader. AddArgument ( " " , inst->getType ());
242
248
funcSignature.push_back (inst->getType ());
243
249
linkArguments[index] = arg;
244
250
linkSignature[index] = inputLocation++;
@@ -247,7 +253,16 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
247
253
}
248
254
}
249
255
}
250
-
256
+
257
+ Function* newSamplePhase = FuncUpgrader.RebuildFunction ();
258
+
259
+ samplePhase->eraseFromParent ();
260
+ samplePhase = newSamplePhase;
261
+ samplePhase->addFnAttr (llvm::Attribute::AlwaysInline);
262
+ sampleIndex = FuncUpgrader.GetArgumentFromRebuild (sampleIndex);
263
+
264
+ FuncUpgrader.Clean ();
265
+
251
266
// Replace sample index intrinsic
252
267
Function* SGV = GenISAIntrinsic::getDeclaration (
253
268
M,
@@ -325,7 +340,6 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
325
340
}
326
341
}
327
342
328
-
329
343
Function* rtWrite = GenISAIntrinsic::getDeclaration (
330
344
M,
331
345
GenISAIntrinsic::GenISA_RTWrite,
@@ -342,7 +356,6 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
342
356
}
343
357
}
344
358
345
-
346
359
Function* dualBlend = GenISAIntrinsic::getDeclaration (
347
360
M,
348
361
GenISAIntrinsic::GenISA_RTDualBlendSource,
@@ -359,22 +372,5 @@ Function* LinkMultiRateShader::PatchSamplePhaseSignature(
359
372
}
360
373
}
361
374
362
- // Create new function with the right signature
363
- FunctionType* signature = FunctionType::get (builder.getVoidTy (), funcSignature, false );
364
- Function* newSamplePhase = Function::Create (signature, GlobalValue::PrivateLinkage, " samplePhase" , M);
365
- newSamplePhase->addFnAttr (llvm::Attribute::AlwaysInline);
366
-
367
- newSamplePhase->getBasicBlockList ().splice (
368
- newSamplePhase->begin (),
369
- samplePhase->getBasicBlockList ());
370
- for (auto I = samplePhase->arg_begin (), E = samplePhase->arg_end (), I2 = newSamplePhase->arg_begin ();
371
- I != E;
372
- ++I, ++I2)
373
- {
374
- I->replaceAllUsesWith (&(*I2));
375
- }
376
-
377
- samplePhase->eraseFromParent ();
378
-
379
- return newSamplePhase;
375
+ return samplePhase;
380
376
}
0 commit comments