summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
diff options
context:
space:
mode:
authorSaleem Abdulrasool <compnerd@compnerd.org>2017-09-07 04:00:13 +0000
committerSaleem Abdulrasool <compnerd@compnerd.org>2017-09-07 04:00:13 +0000
commit5fba8ba9cc1e6de4884bd5844b435dcdaaeae3bb (patch)
treee7e44ee2c036628491df612c6803379da3c2535a /llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
parente2addb79b8d018cb0847ffb67e09ab97a39fbef6 (diff)
downloadbcm5719-llvm-5fba8ba9cc1e6de4884bd5844b435dcdaaeae3bb.tar.gz
bcm5719-llvm-5fba8ba9cc1e6de4884bd5844b435dcdaaeae3bb.zip
ARM: track globals promoted to coalesced const pool entries
Globals that are promoted to an ARM constant pool may alias with another existing constant pool entry. We need to keep a reference to all globals that were promoted to each constant pool value so that we can emit a distinct label for each promoted global. These labels are necessary so that debug info can refer to the promoted global without an undefined reference during linking. Patch by Stephen Crane! llvm-svn: 312692
Diffstat (limited to 'llvm/lib/Target/ARM/ARMConstantPoolValue.cpp')
-rw-r--r--llvm/lib/Target/ARM/ARMConstantPoolValue.cpp17
1 files changed, 14 insertions, 3 deletions
diff --git a/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
index 9705c8b718b..88b3683bd75 100644
--- a/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
+++ b/llvm/lib/Target/ARM/ARMConstantPoolValue.cpp
@@ -140,8 +140,9 @@ ARMConstantPoolConstant::ARMConstantPoolConstant(const Constant *C,
ARMConstantPoolConstant::ARMConstantPoolConstant(const GlobalVariable *GV,
const Constant *C)
: ARMConstantPoolValue((Type *)C->getType(), 0, ARMCP::CPPromotedGlobal, 0,
- ARMCP::no_modifier, false),
- CVal(C), GVar(GV) {}
+ ARMCP::no_modifier, false), CVal(C) {
+ GVars.insert(GV);
+}
ARMConstantPoolConstant *
ARMConstantPoolConstant::Create(const Constant *C, unsigned ID) {
@@ -189,7 +190,15 @@ const BlockAddress *ARMConstantPoolConstant::getBlockAddress() const {
int ARMConstantPoolConstant::getExistingMachineCPValue(MachineConstantPool *CP,
unsigned Alignment) {
- return getExistingMachineCPValueImpl<ARMConstantPoolConstant>(CP, Alignment);
+ int index =
+ getExistingMachineCPValueImpl<ARMConstantPoolConstant>(CP, Alignment);
+ if (index != -1) {
+ auto *CPV = static_cast<ARMConstantPoolValue*>(
+ CP->getConstants()[index].Val.MachineCPVal);
+ auto *Constant = cast<ARMConstantPoolConstant>(CPV);
+ Constant->GVars.insert(GVars.begin(), GVars.end());
+ }
+ return index;
}
bool ARMConstantPoolConstant::hasSameValue(ARMConstantPoolValue *ACPV) {
@@ -199,6 +208,8 @@ bool ARMConstantPoolConstant::hasSameValue(ARMConstantPoolValue *ACPV) {
void ARMConstantPoolConstant::addSelectionDAGCSEId(FoldingSetNodeID &ID) {
ID.AddPointer(CVal);
+ for (const auto *GV : GVars)
+ ID.AddPointer(GV);
ARMConstantPoolValue::addSelectionDAGCSEId(ID);
}
OpenPOWER on IntegriCloud