[llvm-commits] [llvm] r77818 - in /llvm/trunk: lib/CodeGen/AsmPrinter/AsmPrinter.cpp test/CodeGen/X86/ptrtoint-constexpr.ll
Chris Lattner
sabre at nondot.org
Sat Aug 1 15:25:13 PDT 2009
Author: lattner
Date: Sat Aug 1 17:25:12 2009
New Revision: 77818
URL: http://llvm.org/viewvc/llvm-project?rev=77818&view=rev
Log:
fix a problem Eli noticed where we would compile the attached ptrtoint
to:
.quad X
even on a 32-bit system, where X is not 64-bits. There isn't much that
we can do here, so we just print:
.quad ((X) & 4294967295)
instead.
Added:
llvm/trunk/test/CodeGen/X86/ptrtoint-constexpr.ll
Modified:
llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
Modified: llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp?rev=77818&r1=77817&r2=77818&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp (original)
+++ llvm/trunk/lib/CodeGen/AsmPrinter/AsmPrinter.cpp Sat Aug 1 17:25:12 2009
@@ -910,6 +910,16 @@
const TargetData *TD = TM.getTargetData();
unsigned Opcode = CE->getOpcode();
switch (Opcode) {
+ case Instruction::Trunc:
+ case Instruction::ZExt:
+ case Instruction::SExt:
+ case Instruction::FPTrunc:
+ case Instruction::FPExt:
+ case Instruction::UIToFP:
+ case Instruction::SIToFP:
+ case Instruction::FPToUI:
+ case Instruction::FPToSI:
+ llvm_unreachable("FIXME: Don't support this constant cast expr");
case Instruction::GetElementPtr: {
// generate a symbolic expression for the byte address
const Constant *ptrVal = CE->getOperand(0);
@@ -934,17 +944,6 @@
}
break;
}
- case Instruction::Trunc:
- case Instruction::ZExt:
- case Instruction::SExt:
- case Instruction::FPTrunc:
- case Instruction::FPExt:
- case Instruction::UIToFP:
- case Instruction::SIToFP:
- case Instruction::FPToUI:
- case Instruction::FPToSI:
- llvm_unreachable("FIXME: Don't yet support this kind of constant cast expr");
- break;
case Instruction::BitCast:
return EmitConstantValueOnly(CE->getOperand(0));
@@ -965,12 +964,13 @@
// We can emit the pointer value into this slot if the slot is an
// integer slot greater or equal to the size of the pointer.
- if (TD->getTypeAllocSize(Ty) >= TD->getTypeAllocSize(Op->getType()))
+ if (TD->getTypeAllocSize(Ty) == TD->getTypeAllocSize(Op->getType()))
return EmitConstantValueOnly(Op);
O << "((";
EmitConstantValueOnly(Op);
- APInt ptrMask = APInt::getAllOnesValue(TD->getTypeAllocSizeInBits(Ty));
+ APInt ptrMask =
+ APInt::getAllOnesValue(TD->getTypeAllocSizeInBits(Op->getType()));
SmallString<40> S;
ptrMask.toStringUnsigned(S);
Added: llvm/trunk/test/CodeGen/X86/ptrtoint-constexpr.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/ptrtoint-constexpr.ll?rev=77818&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/ptrtoint-constexpr.ll (added)
+++ llvm/trunk/test/CodeGen/X86/ptrtoint-constexpr.ll Sat Aug 1 17:25:12 2009
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | llc -mtriple=i386-linux | FileCheck %s
+ %union.x = type { i64 }
+
+; CHECK: .globl r
+; CHECK: r:
+; CHECK: .quad ((r) & 4294967295)
+
+ at r = global %union.x { i64 ptrtoint (%union.x* @r to i64) }, align 4
More information about the llvm-commits
mailing list