Skip to content

Commit 63ecf82

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 2a26d6a commit 63ecf82

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
@@ -2117,16 +2117,11 @@ bool lowerBuiltinCallsToVariables(Module *M) {
21172117
for (auto *U : F.users()) {
21182118
auto *CI = dyn_cast<CallInst>(U);
21192119
assert(CI && "invalid instruction");
2120-
const DebugLoc &DLoc = CI->getDebugLoc();
2121-
Instruction *NewValue = new LoadInst(GVType, BV, "", CI);
2122-
if (DLoc)
2123-
NewValue->setDebugLoc(DLoc);
2120+
IRBuilder<> Builder(CI);
2121+
Value *NewValue = Builder.CreateLoad(GVType, BV);
21242122
LLVM_DEBUG(dbgs() << "Transform: " << *CI << " => " << *NewValue << '\n');
21252123
if (IsVec) {
2126-
NewValue =
2127-
ExtractElementInst::Create(NewValue, CI->getArgOperand(0), "", CI);
2128-
if (DLoc)
2129-
NewValue->setDebugLoc(DLoc);
2124+
NewValue = Builder.CreateExtractElement(NewValue, CI->getArgOperand(0));
21302125
LLVM_DEBUG(dbgs() << *NewValue << '\n');
21312126
}
21322127
NewValue->takeName(CI);

0 commit comments

Comments
 (0)