Skip to content

Commit c23bfa7

Browse files
committed
Reuse arg type when overwriting
Signed-off-by: Steffen Larsen <[email protected]>
1 parent a685c84 commit c23bfa7

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

llvm/tools/sycl-post-link/CompileTimePropertiesPass.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,8 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
187187

188188
// Get the global variable with the annotation string.
189189
const GlobalVariable *AnnotStrArgGV = nullptr;
190-
if (auto *GEP = dyn_cast<GEPOperator>(IntrInst->getArgOperand(1)))
190+
const Value *IntrAnnotStringArg = IntrInst->getArgOperand(1);
191+
if (auto *GEP = dyn_cast<GEPOperator>(IntrAnnotStringArg))
191192
if (auto *C = dyn_cast<Constant>(GEP->getOperand(0)))
192193
AnnotStrArgGV = dyn_cast<GlobalVariable>(C);
193194
if (!AnnotStrArgGV)
@@ -266,13 +267,14 @@ bool CompileTimePropertiesPass::transformSYCLPropertiesAnnotation(
266267
}
267268

268269
// Replace the annotation string with a bitcast of the new global variable.
269-
Type *Int8Ty = IntegerType::getInt8Ty(M.getContext());
270270
IntrInst->setArgOperand(
271-
1, ConstantExpr::getBitCast(NewAnnotStringGV, Int8Ty->getPointerTo(0)));
271+
1, ConstantExpr::getBitCast(NewAnnotStringGV,
272+
IntrAnnotStringArg->getType()));
272273

273274
// The values are not in the annotation string, so we can remove the original
274275
// annotation value.
275276
unsigned DefaultAS = M.getDataLayout().getDefaultGlobalsAddressSpace();
277+
Type *Int8Ty = IntegerType::getInt8Ty(M.getContext());
276278
PointerType *Int8DefaultASPtrTy = Int8Ty->getPointerTo(DefaultAS);
277279
IntrInst->setArgOperand(4, ConstantPointerNull::get(Int8DefaultASPtrTy));
278280
return true;

0 commit comments

Comments
 (0)