Skip to content

Commit 8d177a6

Browse files
svenvhhaonanya1
authored andcommitted
Use IRBuilder in lowerBuiltinCallsToVariables; NFC (KhronosGroup#3022)
Simplify code by not having to manually track insertion positions and debug locations.
1 parent 5be53f2 commit 8d177a6

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

lib/SPIRV/SPIRVUtil.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2159,16 +2159,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21592159
for (auto *U : F.users()) {
21602160
auto *CI = dyn_cast<CallInst>(U);
21612161
assert(CI && "invalid instruction");
2162-
const DebugLoc &DLoc = CI->getDebugLoc();
2163-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI);
2164-
if (DLoc)
2165-
NewValue->setDebugLoc(DLoc);
2162+
IRBuilder<> Builder(CI);
2163+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21662164
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21672165
if (IsVec) {
2168-
NewValue =
2169-
ExtractElementInst::Create(NewValue, CI->getArgOperand(0), "", CI);
2170-
if (DLoc)
2171-
NewValue->setDebugLoc(DLoc);
2166+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21722167
LLVM_DEBUG(dbgs() << *NewValue << '\n');
21732168
}
21742169
NewValue->takeName(CI);

0 commit comments

Comments
 (0)