Skip to content

Commit 6c8122b

Browse files
author
Artem Gindinson
committed
Simplify call replacing (since we're always dealing with constants)
Signed-off-by: Artem Gindinson <artem.gindinson@intel.com>
1 parent 87d4137 commit 6c8122b

File tree

1 file changed

+10
-12
lines changed

1 file changed

+10
-12
lines changed

llvm/lib/SYCLLowerIR/MutatePrintfAddrspace.cpp

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -106,24 +106,22 @@ namespace {
106106

107107
/// Encapsulates the update of CallInst's literal argument.
108108
struct 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

124122
private:
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

Comments
 (0)