Skip to content

Commit

Permalink
[lldb] Use BasicBlock::iterator instead of InsertPosition (NFC) (llvm…
Browse files Browse the repository at this point in the history
…#112307)

InsertPosition has been deprecated in favor of using
BasicBlock::iterator. (See llvm#102608)
  • Loading branch information
JDevlieghere authored Oct 15, 2024
1 parent 2a0073f commit 74eb079
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ class ValidPointerChecker : public Instrumenter {
return false;

// Insert an instruction to call the helper with the result
CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "", inst);
CallInst::Create(m_valid_pointer_check_func, dereferenced_ptr, "",
inst->getIterator());

return true;
}
Expand Down Expand Up @@ -417,7 +418,7 @@ class ObjcObjectChecker : public Instrumenter {

ArrayRef<llvm::Value *> args(arg_array, 2);

CallInst::Create(m_objc_object_check_func, args, "", inst);
CallInst::Create(m_objc_object_check_func, args, "", inst->getIterator());

return true;
}
Expand Down
38 changes: 22 additions & 16 deletions lldb/source/Plugins/ExpressionParser/Clang/IRForTarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,8 +378,8 @@ bool IRForTarget::CreateResultVariable(llvm::Function &llvm_function) {

Constant *initializer = result_global->getInitializer();

StoreInst *synthesized_store =
new StoreInst(initializer, new_result_global, first_entry_instruction);
StoreInst *synthesized_store = new StoreInst(
initializer, new_result_global, first_entry_instruction->getIterator());

LLDB_LOG(log, "Synthesized result store \"{0}\"\n",
PrintValue(synthesized_store));
Expand Down Expand Up @@ -413,9 +413,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
"CFStringCreateWithBytes");

bool missing_weak = false;
CFStringCreateWithBytes_addr =
m_execution_unit.FindSymbol(g_CFStringCreateWithBytes_str,
missing_weak);
CFStringCreateWithBytes_addr = m_execution_unit.FindSymbol(
g_CFStringCreateWithBytes_str, missing_weak);
if (CFStringCreateWithBytes_addr == LLDB_INVALID_ADDRESS || missing_weak) {
LLDB_LOG(log, "Couldn't find CFStringCreateWithBytes in the target");

Expand Down Expand Up @@ -514,7 +513,8 @@ bool IRForTarget::RewriteObjCConstString(llvm::GlobalVariable *ns_str,
m_CFStringCreateWithBytes, CFSCWB_arguments,
"CFStringCreateWithBytes",
llvm::cast<Instruction>(
m_entry_instruction_finder.GetValue(function)));
m_entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(ns_str, nullptr, CFSCWB_Caller, m_entry_instruction_finder,
Expand Down Expand Up @@ -821,7 +821,7 @@ bool IRForTarget::RewriteObjCSelector(Instruction *selector_load) {

CallInst *srN_call =
CallInst::Create(m_sel_registerName, _objc_meth_var_name_,
"sel_registerName", selector_load);
"sel_registerName", selector_load->getIterator());

// Replace the load with the call in all users

Expand Down Expand Up @@ -914,8 +914,9 @@ bool IRForTarget::RewritePersistentAlloc(llvm::Instruction *persistent_alloc) {
// Now, since the variable is a pointer variable, we will drop in a load of
// that pointer variable.

LoadInst *persistent_load = new LoadInst(persistent_global->getValueType(),
persistent_global, "", alloc);
LoadInst *persistent_load =
new LoadInst(persistent_global->getValueType(), persistent_global, "",
alloc->getIterator());

LLDB_LOG(log, "Replacing \"{0}\" with \"{1}\"", PrintValue(alloc),
PrintValue(persistent_load));
Expand Down Expand Up @@ -1341,8 +1342,10 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,

return new BitCastInst(
value_maker.GetValue(function), constant_expr->getType(),
"", llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function)));
"",
llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(constant_expr, llvm_function, bit_cast_maker,
Expand Down Expand Up @@ -1376,7 +1379,8 @@ bool IRForTarget::UnfoldConstant(Constant *old_constant,
return GetElementPtrInst::Create(
gep->getSourceElementType(), ptr, indices, "",
llvm::cast<Instruction>(
entry_instruction_finder.GetValue(function)));
entry_instruction_finder.GetValue(function))
->getIterator());
});

if (!UnfoldConstant(constant_expr, llvm_function,
Expand Down Expand Up @@ -1556,12 +1560,14 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
Type *int8Ty = Type::getInt8Ty(function->getContext());
ConstantInt *offset_int(
ConstantInt::get(offset_type, offset, true));
GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(
int8Ty, argument, offset_int, "", entry_instruction);
GetElementPtrInst *get_element_ptr =
GetElementPtrInst::Create(int8Ty, argument, offset_int, "",
entry_instruction->getIterator());

if (name == m_result_name && !m_result_is_pointer) {
LoadInst *load = new LoadInst(value->getType(), get_element_ptr,
"", entry_instruction);
LoadInst *load =
new LoadInst(value->getType(), get_element_ptr, "",
entry_instruction->getIterator());

return load;
} else {
Expand Down

0 comments on commit 74eb079

Please sign in to comment.