@@ -35,6 +35,7 @@ IN THE SOFTWARE.
35
35
#include " llvm/Support/CommandLine.h"
36
36
#include " llvm/IR/Instructions.h"
37
37
#include " llvm/IR/InstIterator.h"
38
+ #include " llvm/Transforms/Utils/BasicBlockUtils.h"
38
39
#include " llvm/Transforms/Utils/Local.h"
39
40
#include " llvmWrapper/IR/InstrTypes.h"
40
41
#include " common/LLVMWarningsPop.hpp"
@@ -1969,9 +1970,7 @@ void Legalization::visitBasicBlock(llvm::BasicBlock& BB) {
1969
1970
1970
1971
void Legalization::PromoteFp16ToFp32OnGenSampleCall (llvm::CallInst& I)
1971
1972
{
1972
- Value* args[16 ];
1973
- const int args_size = I.getCalledFunction ()->getFunctionType ()->getNumParams ();
1974
- llvm::ArrayRef<Value*> arrayRef_params (args, args_size);
1973
+ llvm::SmallVector<llvm::Value*, 16 > args (I.arg_begin (), I.arg_end ());
1975
1974
GenIntrinsicInst* CI = llvm::dyn_cast<GenIntrinsicInst>(&I);
1976
1975
1977
1976
llvm::SmallVector<Type*, 5 > types;
@@ -2002,7 +2001,7 @@ void Legalization::PromoteFp16ToFp32OnGenSampleCall(llvm::CallInst& I)
2002
2001
types[0 ] = I.getType ();
2003
2002
types[1 ] = Type::getFloatTy (I.getContext ());
2004
2003
2005
- for (int index = 0 ; index < args_size ; index++)
2004
+ for (size_t index = 0 ; index < args. size () ; index++)
2006
2005
{
2007
2006
Value* input = I.getOperand (index);
2008
2007
if (input->getType ()->isHalfTy ())
@@ -2025,9 +2024,8 @@ void Legalization::PromoteFp16ToFp32OnGenSampleCall(llvm::CallInst& I)
2025
2024
}
2026
2025
2027
2026
llvm::Function* f0 = GenISAIntrinsic::getDeclaration (m_ctx->getModule (), CI->getIntrinsicID (), types);
2028
- llvm::CallInst* I0 = GenIntrinsicInst::Create (f0, arrayRef_params, " " , &I);
2029
- I.replaceAllUsesWith (I0);
2030
- I.eraseFromParent ();
2027
+ llvm::CallInst* I0 = GenIntrinsicInst::Create (f0, args);
2028
+ llvm::ReplaceInstWithInst (&I, I0);
2031
2029
}
2032
2030
2033
2031
void Legalization::visitTruncInst (llvm::TruncInst& I) {
0 commit comments