Skip to content

Commit ec5027a

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 8b1fb86 commit ec5027a

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
@@ -2163,16 +2163,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21632163
for (auto *U : F.users()) {
21642164
auto *CI = dyn_cast<CallInst>(U);
21652165
assert(CI && "invalid instruction");
2166-
const DebugLoc &DLoc = CI->getDebugLoc();
2167-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI);
2168-
if (DLoc)
2169-
NewValue->setDebugLoc(DLoc);
2166+
IRBuilder<> Builder(CI);
2167+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21702168
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21712169
if (IsVec) {
2172-
NewValue =
2173-
ExtractElementInst::Create(NewValue, CI->getArgOperand(0), "", CI);
2174-
if (DLoc)
2175-
NewValue->setDebugLoc(DLoc);
2170+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21762171
LLVM_DEBUG(dbgs() << *NewValue << '\n');
21772172
}
21782173
NewValue->takeName(CI);

0 commit comments

Comments
 (0)