@@ -106,24 +106,22 @@ namespace {
106106
107107// / Encapsulates the update of CallInst's literal argument.
108108struct CallReplacer {
109- CallReplacer (CallInst *CI, Value *CASArg) : CI(CI), CASArg(CASArg) {}
109+ CallReplacer (CallInst *CI, Constant *CASArg) : CI(CI), CASArg(CASArg) {}
110110 void replaceWithFunction (Function *CASPrintf) {
111111 CI->setCalledFunction (CASPrintf);
112- Value *ArgToSet = CASArg;
113- if (auto *Const = dyn_cast<Constant>(CASArg)) {
114- // In case there's a misalignment between the updated function type and
115- // the constant literal type, create a constant pointer cast so as to
116- // duck module verifier complaints.
117- Type *ParamType = CASPrintf->getFunctionType ()->getParamType (0 );
118- if (Const->getType () != ParamType)
119- ArgToSet = ConstantExpr::getPointerCast (Const, ParamType);
120- }
121- CI->setArgOperand (0 , ArgToSet);
112+ auto *Const = CASArg;
113+ // In case there's a misalignment between the updated function type and
114+ // the constant literal type, create a constant pointer cast so as to
115+ // duck module verifier complaints.
116+ Type *ParamType = CASPrintf->getFunctionType ()->getParamType (0 );
117+ if (Const->getType () != ParamType)
118+ Const = ConstantExpr::getPointerCast (Const, ParamType);
119+ CI->setArgOperand (0 , Const);
122120 }
123121
124122private:
125123 CallInst *CI;
126- Value *CASArg;
124+ Constant *CASArg;
127125};
128126
129127// / The function's effect is similar to V->stripPointerCastsAndAliases(), but
0 commit comments