[PATCH] SelectionDAG: Use the correct pointer width in SelectionDAG::InferPtrAlignment()

Tom Stellard tom at stellard.net
Tue Oct 15 21:17:42 PDT 2013


From: Tom Stellard <thomas.stellard at amd.com>

---
 lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 +-
 test/CodeGen/R600/address-space.ll        | 9 +++++++++
 2 files changed, 10 insertions(+), 1 deletion(-)

diff --git a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
index 1756f94..daeb97b 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
@@ -6276,7 +6276,7 @@ unsigned SelectionDAG::InferPtrAlignment(SDValue Ptr) const {
   int64_t GVOffset = 0;
   const TargetLowering *TLI = TM.getTargetLowering();
   if (TLI->isGAPlusOffset(Ptr.getNode(), GV, GVOffset)) {
-    unsigned PtrWidth = TLI->getPointerTy().getSizeInBits();
+    unsigned PtrWidth = TLI->getPointerTypeSizeInBits(GV->getType());
     APInt KnownZero(PtrWidth, 0), KnownOne(PtrWidth, 0);
     llvm::ComputeMaskedBits(const_cast<GlobalValue*>(GV), KnownZero, KnownOne,
                             TLI->getDataLayout());
diff --git a/test/CodeGen/R600/address-space.ll b/test/CodeGen/R600/address-space.ll
index d8e6c63..ff8be50 100644
--- a/test/CodeGen/R600/address-space.ll
+++ b/test/CodeGen/R600/address-space.ll
@@ -39,3 +39,12 @@ entry:
   ret void
 }
 
+; Test for a crash in SelectionDAG::InferPtrAlignment()
+; CHECK-LABEL: @integral_cols
+; CHECK: DS_READ_B32
+define void @integral_cols(i32 addrspace(1)* %out) {
+entry:
+  %0 = load i32 addrspace(3)* getelementptr inbounds ([2 x [264 x i32]] addrspace(3)* @local.mem, i32 0, i32 1, i32 262), align 16
+  store i32 %0, i32 addrspace(1)* %out
+  ret void
+}
-- 
1.8.1.5




More information about the llvm-commits mailing list