summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/AsmPrinter
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2009-02-05 06:55:21 +0000
committerChris Lattner <sabre@nondot.org>2009-02-05 06:55:21 +0000
commit7e1d2862ca99296f6bc0e09fc5e1e814ddc648a2 (patch)
tree76adf2e48da50d9ae9395f37b5a4de2a892a5eed /llvm/lib/CodeGen/AsmPrinter
parent400aae7fa4fe4ab49c1dd6497d8d7227820faea2 (diff)
downloadbcm5719-llvm-7e1d2862ca99296f6bc0e09fc5e1e814ddc648a2.tar.gz
bcm5719-llvm-7e1d2862ca99296f6bc0e09fc5e1e814ddc648a2.zip
if we have a large GEP offset on a 32-bit or other target, make
sure to print the value properly sext'd to the right pointer size. This fixes PR3481. llvm-svn: 63843
Diffstat (limited to 'llvm/lib/CodeGen/AsmPrinter')
-rw-r--r--llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
index c6b0313c39f..678488e1b41 100644
--- a/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
+++ b/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
@@ -815,6 +815,12 @@ void AsmPrinter::EmitConstantValueOnly(const Constant *CV) {
SmallVector<Value*, 8> idxVec(CE->op_begin()+1, CE->op_end());
if (int64_t Offset = TD->getIndexedOffset(ptrVal->getType(), &idxVec[0],
idxVec.size())) {
+ // Truncate/sext the offset to the pointer size.
+ if (TD->getPointerSizeInBits() != 64) {
+ int SExtAmount = 64-TD->getPointerSizeInBits();
+ Offset = (Offset << SExtAmount) >> SExtAmount;
+ }
+
if (Offset)
O << '(';
EmitConstantValueOnly(ptrVal);
OpenPOWER on IntegriCloud