From ee2f1f7f40632e786c6e67c1fc82185d2fcafac2 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Sun, 22 Dec 2013 21:03:07 -0800 Subject: use function alignment to pack function tables more efficiently --- lib/Target/CppBackend/CPPBackend.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'lib/Target/CppBackend/CPPBackend.cpp') diff --git a/lib/Target/CppBackend/CPPBackend.cpp b/lib/Target/CppBackend/CPPBackend.cpp index cd316762a4..a5a648105d 100644 --- a/lib/Target/CppBackend/CPPBackend.cpp +++ b/lib/Target/CppBackend/CPPBackend.cpp @@ -195,7 +195,10 @@ namespace { if (IndexedFunctions.find(Name) != IndexedFunctions.end()) return IndexedFunctions[Name]; std::string Sig = getFunctionSignature(F->getFunctionType()); FunctionTable &Table = FunctionTables[Sig]; - while (Table.size() == 0 || Table.size() % 2 == 1) Table.push_back("0"); // TODO: optimize this, fill in holes, see test_polymorph + // use alignment info to avoid unnecessary holes. This is not optimal though, + // (1) depends on order of appearance, and (2) really just need align for &class::method, see test_polymorph + unsigned Alignment = F->getAlignment() || 1; + while (Table.size() == 0 || Table.size() % Alignment) Table.push_back("0"); unsigned Index = Table.size(); Table.push_back(Name); IndexedFunctions[Name] = Index; -- cgit v1.2.3-70-g09d2