summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-09-21 19:47:04 +0000
committerDan Gohman <gohman@apple.com>2009-09-21 19:47:04 +0000
commit28f02fdd76f4efc05d14649e0eec90ce8e71e17e (patch)
tree4871a48055d37956277077fbc4bea72781807c57
parent78a130a31cb8eca6f4c46f80a8cc4e0aff472be0 (diff)
Change MachineMemOperand's alignment value to be the alignment of
the base pointer, without the offset. This matches MemSDNode's new alignment behavior, and holds more interesting information. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@82473 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--include/llvm/CodeGen/MachineMemOperand.h16
-rw-r--r--lib/CodeGen/MachineInstr.cpp2
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAG.cpp4
-rw-r--r--lib/CodeGen/StackSlotColoring.cpp2
-rw-r--r--lib/CodeGen/TargetInstrInfoImpl.cpp2
5 files changed, 17 insertions, 9 deletions
diff --git a/include/llvm/CodeGen/MachineMemOperand.h b/include/llvm/CodeGen/MachineMemOperand.h
index de238e48d1..1b01c4893e 100644
--- a/include/llvm/CodeGen/MachineMemOperand.h
+++ b/include/llvm/CodeGen/MachineMemOperand.h
@@ -16,6 +16,8 @@
#ifndef LLVM_CODEGEN_MACHINEMEMOPERAND_H
#define LLVM_CODEGEN_MACHINEMEMOPERAND_H
+#include "llvm/Support/MathExtras.h"
+
namespace llvm {
class Value;
@@ -47,9 +49,9 @@ public:
};
/// MachineMemOperand - Construct an MachineMemOperand object with the
- /// specified address Value, flags, offset, size, and alignment.
+ /// specified address Value, flags, offset, size, and base alignment.
MachineMemOperand(const Value *v, unsigned int f, int64_t o, uint64_t s,
- unsigned int a);
+ unsigned int base_alignment);
/// getValue - Return the base address of the memory access. This may either
/// be a normal LLVM IR Value, or one of the special values used in CodeGen.
@@ -72,8 +74,14 @@ public:
uint64_t getSize() const { return Size; }
/// getAlignment - Return the minimum known alignment in bytes of the
- /// memory reference.
- unsigned int getAlignment() const { return (1u << (Flags >> 3)) >> 1; }
+ /// actual memory reference.
+ uint64_t getAlignment() const {
+ return MinAlign(getBaseAlignment(), getOffset());
+ }
+
+ /// getBaseAlignment - Return the minimum known alignment in bytes of the
+ /// base address, without the offset.
+ uint64_t getBaseAlignment() const { return (1u << (Flags >> 3)) >> 1; }
bool isLoad() const { return Flags & MOLoad; }
bool isStore() const { return Flags & MOStore; }
diff --git a/lib/CodeGen/MachineInstr.cpp b/lib/CodeGen/MachineInstr.cpp
index cf6597d809..2f5964f140 100644
--- a/lib/CodeGen/MachineInstr.cpp
+++ b/lib/CodeGen/MachineInstr.cpp
@@ -284,7 +284,7 @@ MachineMemOperand::MachineMemOperand(const Value *v, unsigned int f,
int64_t o, uint64_t s, unsigned int a)
: Offset(o), Size(s), V(v),
Flags((f & 7) | ((Log2_32(a) + 1) << 3)) {
- assert(isPowerOf2_32(a) && "Alignment is not a power of 2!");
+ assert(getBaseAlignment() == a && "Alignment is not a power of 2!");
assert((isLoad() || isStore()) && "Not a load/store!");
}
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 669526780b..87ea19be86 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -5015,10 +5015,10 @@ MachineMemOperand MemSDNode::getMemOperand() const {
dyn_cast<const FrameIndexSDNode>(getBasePtr().getNode());
if (!getSrcValue() && FI)
return MachineMemOperand(PseudoSourceValue::getFixedStack(FI->getIndex()),
- Flags, 0, Size, getAlignment());
+ Flags, 0, Size, getOriginalAlignment());
else
return MachineMemOperand(getSrcValue(), Flags, getSrcValueOffset(),
- Size, getAlignment());
+ Size, getOriginalAlignment());
}
/// Profile - Gather unique data for the node.
diff --git a/lib/CodeGen/StackSlotColoring.cpp b/lib/CodeGen/StackSlotColoring.cpp
index e62c0506b3..7d88dad6c8 100644
--- a/lib/CodeGen/StackSlotColoring.cpp
+++ b/lib/CodeGen/StackSlotColoring.cpp
@@ -473,7 +473,7 @@ void StackSlotColoring::RewriteInstruction(MachineInstr *MI, int OldFI,
else {
MachineMemOperand MMO(PseudoSourceValue::getFixedStack(NewFI),
MMOs[i].getFlags(), MMOs[i].getOffset(),
- MMOs[i].getSize(), MMOs[i].getAlignment());
+ MMOs[i].getSize(), MMOs[i].getBaseAlignment());
MI->addMemOperand(MF, MMO);
}
}
diff --git a/lib/CodeGen/TargetInstrInfoImpl.cpp b/lib/CodeGen/TargetInstrInfoImpl.cpp
index 8aca0ccd42..f184cb74f0 100644
--- a/lib/CodeGen/TargetInstrInfoImpl.cpp
+++ b/lib/CodeGen/TargetInstrInfoImpl.cpp
@@ -205,7 +205,7 @@ TargetInstrInfo::foldMemoryOperand(MachineFunction &MF,
assert(MFI.getObjectOffset(FrameIndex) != -1);
MachineMemOperand MMO(PseudoSourceValue::getFixedStack(FrameIndex),
Flags,
- MFI.getObjectOffset(FrameIndex),
+ /*Offset=*/0,
MFI.getObjectSize(FrameIndex),
MFI.getObjectAlignment(FrameIndex));
NewMI->addMemOperand(MF, MMO);