From bf46f0754257ba134e50ea13a7515a8d08ceeaec Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 25 Nov 2013 18:29:21 -0800 Subject: handle ptrtoint of functions --- lib/Target/CppBackend/CPPBackend.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'lib/Target/CppBackend/CPPBackend.cpp') diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index 68c29ebf06..7954fc4dc3 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -202,7 +202,7 @@ namespace { Address a = GlobalAddresses[s]; return a.first; } - unsigned getConstAsOffset(Value *V) { + unsigned getConstAsOffset(const Value *V) { if (isa(V)) { dump("TODO: function indexing"); return 0; @@ -1667,7 +1667,7 @@ std::string CppWriter::generateInstruction(const Instruction *I) { case Instruction::PtrToInt: text = getAssign(iName, Type::getInt32Ty(I->getContext())); if (const Constant *CV = dyn_cast(I->getOperand(0))) { - text += utostr(getGlobalAddress(CV->getName().str())); + text += utostr(getConstAsOffset(CV)); } else { text += getCast(getValueAsStr(I->getOperand(0)), Type::getInt32Ty(I->getContext())); } -- cgit v1.2.3-18-g5258