Skip to content

Commit 51f2c21

Browse files
authored
Use IRBuilder in lowerBuiltinCallsToVariables; NFC (#3022)
Simplify code by not having to manually track insertion positions and debug locations.
1 parent e17f4b4 commit 51f2c21

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
@@ -2184,16 +2184,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21842184
for (auto *U : F.users()) {
21852185
auto *CI = dyn_cast<CallInst>(U);
21862186
assert(CI && "invalid instruction");
2187-
const DebugLoc &DLoc = CI->getDebugLoc();
2188-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI->getIterator());
2189-
if (DLoc)
2190-
NewValue->setDebugLoc(DLoc);
2187+
IRBuilder<> Builder(CI);
2188+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21912189
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21922190
if (IsVec) {
2193-
NewValue = ExtractElementInst::Create(NewValue, CI->getArgOperand(0),
2194-
"", CI->getIterator());
2195-
if (DLoc)
2196-
NewValue->setDebugLoc(DLoc);
2191+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21972192
LLVM_DEBUG(dbgs() << *NewValue << '\n');
21982193
}
21992194
NewValue->takeName(CI);

0 commit comments

Comments
 (0)