[lldb] Avoid pointer element type accesses

This commit is contained in:
Nikita Popov 2022-03-24 13:07:24 +01:00
parent 406bde9a15
commit 840bb72543
2 changed files with 4 additions and 7 deletions

View File

@ -1757,20 +1757,19 @@ bool IRForTarget::ReplaceVariables(Function &llvm_function) {
llvm::Instruction *entry_instruction = llvm::cast<Instruction>( llvm::Instruction *entry_instruction = llvm::cast<Instruction>(
m_entry_instruction_finder.GetValue(function)); m_entry_instruction_finder.GetValue(function));
Type *int8Ty = Type::getInt8Ty(function->getContext());
ConstantInt *offset_int( ConstantInt *offset_int(
ConstantInt::get(offset_type, offset, true)); ConstantInt::get(offset_type, offset, true));
GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create( GetElementPtrInst *get_element_ptr = GetElementPtrInst::Create(
argument->getType()->getPointerElementType(), argument, int8Ty, argument, offset_int, "", entry_instruction);
offset_int, "", entry_instruction);
if (name == m_result_name && !m_result_is_pointer) { if (name == m_result_name && !m_result_is_pointer) {
BitCastInst *bit_cast = new BitCastInst( BitCastInst *bit_cast = new BitCastInst(
get_element_ptr, value->getType()->getPointerTo(), "", get_element_ptr, value->getType()->getPointerTo(), "",
entry_instruction); entry_instruction);
LoadInst *load = LoadInst *load = new LoadInst(value->getType(), bit_cast, "",
new LoadInst(bit_cast->getType()->getPointerElementType(), entry_instruction);
bit_cast, "", entry_instruction);
return load; return load;
} else { } else {

View File

@ -204,8 +204,6 @@ open problems:
* Some pointer element type uses remain in LLVM. * Some pointer element type uses remain in LLVM.
* Some pointer element type uses remain in LLDB.
* Some pointer element type uses remain in MLIR. * Some pointer element type uses remain in MLIR.
* Some pointer element type uses remain in Polly. * Some pointer element type uses remain in Polly.