aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Frontend
diff options
context:
space:
mode:
authorJeremy Morse <jeremy.morse@sony.com>2024-03-19 14:30:41 +0000
committerGitHub <noreply@github.com>2024-03-19 14:30:41 +0000
commit7ef433f62c199c414bffdcac1c8ee3159b29c5f5 (patch)
treef18999a86ccfadfe634cdeaa3fff8644a0162675 /llvm/lib/Frontend
parent4aec1438cdb2326c3709d57a5ec22fe436d4d8f1 (diff)
downloadllvm-7ef433f62c199c414bffdcac1c8ee3159b29c5f5.zip
llvm-7ef433f62c199c414bffdcac1c8ee3159b29c5f5.tar.gz
llvm-7ef433f62c199c414bffdcac1c8ee3159b29c5f5.tar.bz2
[NFC][RemoveDIs] Switch ConstantExpr::getAsInstruction to not insert (#84737)
Because the RemoveDIs work is putting a debug-info bit into BasicBlock::iterator and iterators are needed for insertion, the getAsInstruction method declaration would need to use a fully defined instruction-iterator, which leads to a complicated header-inclusion-order problem. Much simpler to instead just not insert, and make it the callers problem to insert. This is proportionate because there are only four call-sites to getAsInstruction -- it would suck if we did this everywhere. --------- Merged by: Stephen Tozer <stephen.tozer@sony.com>
Diffstat (limited to 'llvm/lib/Frontend')
-rw-r--r--llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp13
1 files changed, 9 insertions, 4 deletions
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index c07ee34..16507a6 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -5073,10 +5073,15 @@ FunctionCallee OpenMPIRBuilder::createDispatchFiniFunction(unsigned IVSize,
static void replaceConstatExprUsesInFuncWithInstr(ConstantExpr *ConstExpr,
Function *Func) {
- for (User *User : make_early_inc_range(ConstExpr->users()))
- if (auto *Instr = dyn_cast<Instruction>(User))
- if (Instr->getFunction() == Func)
- Instr->replaceUsesOfWith(ConstExpr, ConstExpr->getAsInstruction(Instr));
+ for (User *User : make_early_inc_range(ConstExpr->users())) {
+ if (auto *Instr = dyn_cast<Instruction>(User)) {
+ if (Instr->getFunction() == Func) {
+ Instruction *ConstInst = ConstExpr->getAsInstruction();
+ ConstInst->insertBefore(*Instr->getParent(), Instr->getIterator());
+ Instr->replaceUsesOfWith(ConstExpr, ConstInst);
+ }
+ }
+ }
}
static void replaceConstantValueUsesInFuncWithInstr(llvm::Value *Input,