Skip to content

Commit d66d54e

Browse files
committed
Define and reuse I64Ty and PtrTy in legalizeLifetimeIntrinsics function for better readability
1 parent 18e57db commit d66d54e

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

llvm/lib/Target/DirectX/DXILWriter/DXILWriterPass.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ class WriteDXILPass : public llvm::ModulePass {
5959

6060
static void legalizeLifetimeIntrinsics(Module &M) {
6161
LLVMContext &Ctx = M.getContext();
62+
Type *I64Ty = IntegerType::get(Ctx, 64);
6263
Intrinsic::ID LifetimeIIDs[2] = {Intrinsic::lifetime_start,
6364
Intrinsic::lifetime_end};
6465
for (Intrinsic::ID &IID : LifetimeIIDs) {
@@ -73,8 +74,8 @@ static void legalizeLifetimeIntrinsics(Module &M) {
7374
AttributeList Attr;
7475
Attr = Attr.addFnAttribute(Ctx, Attribute::NoUnwind);
7576
FunctionCallee LifetimeCallee = M.getOrInsertFunction(
76-
Intrinsic::getBaseName(IID), Attr, Type::getVoidTy(Ctx),
77-
IntegerType::get(Ctx, 64), PointerType::get(Ctx, 0));
77+
Intrinsic::getBaseName(IID), Attr, Type::getVoidTy(Ctx), I64Ty,
78+
PointerType::get(Ctx, 0));
7879

7980
// Replace all calls to lifetime intrinsics with calls to the
8081
// LLVM 3.7-compliant version of the lifetime intrinsic
@@ -101,12 +102,11 @@ static void legalizeLifetimeIntrinsics(Module &M) {
101102
AI->getAllocationSize(CI->getDataLayout());
102103
assert(AllocSize.has_value() &&
103104
"Expected the allocation size of AllocaInst to be known");
104-
CallInst *NewCI =
105-
CallInst::Create(LifetimeCallee,
106-
{ConstantInt::get(IntegerType::get(Ctx, 64),
107-
AllocSize.value().getFixedValue()),
108-
NoOpBitCast},
109-
"", CI->getIterator());
105+
CallInst *NewCI = CallInst::Create(
106+
LifetimeCallee,
107+
{ConstantInt::get(I64Ty, AllocSize.value().getFixedValue()),
108+
NoOpBitCast},
109+
"", CI->getIterator());
110110
for (Attribute ParamAttr : CI->getParamAttributes(0))
111111
NewCI->addParamAttr(1, ParamAttr);
112112

0 commit comments

Comments
 (0)