Skip to content

Commit 29997e2

Browse files
committed
Use IRBuilder in lowerBuiltinCallsToVariables; NFC (#3022)
Simplify code by not having to manually track insertion positions and debug locations.
1 parent 0cf86c9 commit 29997e2

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
@@ -2177,16 +2177,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21772177
for (auto *U : F.users()) {
21782178
auto *CI = dyn_cast<CallInst>(U);
21792179
assert(CI && "invalid instruction");
2180-
const DebugLoc &DLoc = CI->getDebugLoc();
2181-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI->getIterator());
2182-
if (DLoc)
2183-
NewValue->setDebugLoc(DLoc);
2180+
IRBuilder<> Builder(CI);
2181+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21842182
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21852183
if (IsVec) {
2186-
NewValue = ExtractElementInst::Create(NewValue, CI->getArgOperand(0),
2187-
"", CI->getIterator());
2188-
if (DLoc)
2189-
NewValue->setDebugLoc(DLoc);
2184+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21902185
LLVM_DEBUG(dbgs() << *NewValue << '\n');
21912186
}
21922187
NewValue->takeName(CI);

0 commit comments

Comments
 (0)