Chromium Code Reviews| Index: src/IceCfg.cpp |
| diff --git a/src/IceCfg.cpp b/src/IceCfg.cpp |
| index 50aa5ee1dbbd25974869e0b766092876a0830a08..73d59ac39bfeedb6e3e8ee75742dd82e78560f9b 100644 |
| --- a/src/IceCfg.cpp |
| +++ b/src/IceCfg.cpp |
| @@ -18,6 +18,7 @@ |
| #include "IceClFlags.h" |
| #include "IceDefs.h" |
| #include "IceELFObjectWriter.h" |
| +#include "IceGlobalInits.h" |
| #include "IceInst.h" |
| #include "IceLiveness.h" |
| #include "IceOperand.h" |
| @@ -75,6 +76,53 @@ void Cfg::addImplicitArg(Variable *Arg) { |
| // is used for dumping the stack frame location of Variables. |
| bool Cfg::hasComputedFrame() const { return getTarget()->hasComputedFrame(); } |
| +namespace { |
| +constexpr char BlockNameGlobalPrefix[] = ".Lblock_name_"; |
| +constexpr char BlockStatsGlobalPrefix[] = ".Lprofile_"; |
|
Jim Stichnoth
2015/06/08 23:45:31
Document somewhere that this is a "reserved" prefi
John
2015/06/09 15:36:18
What do you mean, "reserved"?
Jim Stichnoth
2015/06/09 16:39:45
For a function named "foo", Subzero generates inte
John
2015/06/09 22:01:16
To avoid name clashes (as long as $ is not a valid
|
| + |
| +VariableDeclaration *nodeNameDeclaration(const IceString &NodeAsmName) { |
| + VariableDeclaration *Var = VariableDeclaration::create(); |
| + Var->setName(BlockNameGlobalPrefix + NodeAsmName); |
| + Var->setIsConstant(true); |
| + Var->addInitializer(new VariableDeclaration::DataInitializer( |
| + NodeAsmName.data(), NodeAsmName.size() + 1)); |
| + Var->setAlignment(8); // Wasteful, 32-bit could use 4 bytes. |
| + return Var; |
| +} |
| + |
| +VariableDeclaration * |
| +blockProfilingInfoDeclaration(const IceString &NodeAsmName, |
| + VariableDeclaration *NodeNameDeclaration) { |
| + VariableDeclaration *Var = VariableDeclaration::create(); |
| + Var->setName(BlockStatsGlobalPrefix + NodeAsmName); |
| + Var->addInitializer(new VariableDeclaration::ZeroInitializer(8)); |
| + Var->addInitializer( |
| + new VariableDeclaration::RelocInitializer(NodeNameDeclaration, 0)); |
| + Var->setAlignment(8); |
| + return Var; |
| +} |
| + |
| +} // end of namespace |
|
Jim Stichnoth
2015/06/08 23:45:31
end of anonymous namespace
John
2015/06/09 15:36:18
Done.
|
| + |
| +std::unique_ptr<VariableDeclarationList> Cfg::profileBlocks() { |
|
Jim Stichnoth
2015/06/08 23:45:31
Add light documentation of these two functions, ei
John
2015/06/09 15:36:18
Done.
|
| + std::unique_ptr<VariableDeclarationList> ProfilerInits( |
| + new VariableDeclarationList()); |
| + |
| + for (CfgNode *Node : Nodes) { |
| + IceString NodeAsmName = Node->getAsmName(); |
| + ProfilerInits->push_back(nodeNameDeclaration(NodeAsmName)); |
| + ProfilerInits->push_back( |
| + blockProfilingInfoDeclaration(NodeAsmName, ProfilerInits->back())); |
| + Node->profileExecutionCount(ProfilerInits->back()); |
| + } |
| + |
| + return ProfilerInits; |
| +} |
| + |
| +bool Cfg::isProfileGlobal(const VariableDeclaration &Var) { |
| + return Var.getName().find(BlockStatsGlobalPrefix) == 0; |
| +} |
| + |
| void Cfg::translate() { |
| if (hasError()) |
| return; |