Skip to content

Commit c7ea49b

Browse files
svenvhjsji
authored andcommitted
Use IRBuilder in lowerBuiltinCallsToVariables; NFC (#3022)
Simplify code by not having to manually track insertion positions and debug locations. Original commit: KhronosGroup/SPIRV-LLVM-Translator@51f2c21128f5fb0
1 parent f53f9fd commit c7ea49b

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

llvm-spirv/lib/SPIRV/SPIRVUtil.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2186,16 +2186,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21862186
for (auto *U : F.users()) {
21872187
auto *CI = dyn_cast<CallInst>(U);
21882188
assert(CI && "invalid instruction");
2189-
const DebugLoc &DLoc = CI->getDebugLoc();
2190-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI->getIterator());
2191-
if (DLoc)
2192-
NewValue->setDebugLoc(DLoc);
2189+
IRBuilder<> Builder(CI);
2190+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21932191
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21942192
if (IsVec) {
2195-
NewValue = ExtractElementInst::Create(NewValue, CI->getArgOperand(0),
2196-
"", CI->getIterator());
2197-
if (DLoc)
2198-
NewValue->setDebugLoc(DLoc);
2193+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21992194
LLVM_DEBUG(dbgs() << *NewValue << '\n');
22002195
}
22012196
NewValue->takeName(CI);

0 commit comments

Comments
 (0)