Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions llvm/include/llvm/Target/TargetMachine.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ namespace llvm {
class AAManager;
using ModulePassManager = PassManager<Module>;

struct EVT;
class Function;
class GlobalValue;
class MachineModuleInfoWrapperPass;
Expand Down Expand Up @@ -469,9 +470,13 @@ class TargetMachine {
}

/// True if target has some particular form of dealing with pointer arithmetic
/// semantics. False if pointer arithmetic should not be preserved for passes
/// such as instruction selection, and can fallback to regular arithmetic.
virtual bool shouldPreservePtrArith(const Function &F) const { return false; }
/// semantics for pointers with the given value type. False if pointer
/// arithmetic should not be preserved for passes such as instruction
/// selection, and can fallback to regular arithmetic.
virtual bool shouldPreservePtrArith(const Function &F,
const EVT &PtrVT) const {
return false;
}

/// Create a pass configuration object to be used by addPassToEmitX methods
/// for generating a pipeline of CodeGen passes.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8146,7 +8146,7 @@ SDValue SelectionDAG::getMemBasePlusOffset(SDValue Ptr, SDValue Offset,
assert(Offset.getValueType().isInteger());
EVT BasePtrVT = Ptr.getValueType();
if (!this->getTarget().shouldPreservePtrArith(
this->getMachineFunction().getFunction()))
this->getMachineFunction().getFunction(), BasePtrVT))
return getNode(ISD::ADD, DL, BasePtrVT, Ptr, Offset, Flags);
return getNode(ISD::PTRADD, DL, BasePtrVT, Ptr, Offset, Flags);
}
Expand Down