OSDN Git Service

Make ARM RegNames[] static like X86 (no ARM syms in X86-only build).
authorJan Voung <jvoung@chromium.org>
Tue, 21 Jul 2015 21:29:34 +0000 (14:29 -0700)
committerJan Voung <jvoung@chromium.org>
Tue, 21 Jul 2015 21:29:34 +0000 (14:29 -0700)
The X86 code was switch out here:
https://codereview.chromium.org/1216933015/diff/150001/src/IceTargetLoweringX86Base.h

The important bit might be that it's static const char * instead of
static IceString. This removes static ctor/dtor for that array,
which LTO doesn't seem to be able to optimize out, leaving ARM
and MIPS symbols in the X86-only build. After changing it to static
const char *, LTO is able to optimize out the ARM and MIPS
symbols in the x86-only build, saving about 3KB of .text and
few bytes of .rodata.

BUG=none
R=jpp@chromium.org

Review URL: https://codereview.chromium.org/1246013004 .

src/IceTargetLoweringARM32.cpp
src/IceTargetLoweringARM32.h
src/IceTargetLoweringMIPS32.cpp
src/IceTargetLoweringMIPS32.h

index 9f7a90d..faf1aa0 100644 (file)
@@ -348,17 +348,17 @@ bool TargetARM32::doBranchOpt(Inst *I, const CfgNode *NextNode) {
   return false;
 }
 
-IceString TargetARM32::RegNames[] = {
+IceString TargetARM32::getRegName(SizeT RegNum, Type Ty) const {
+  assert(RegNum < RegARM32::Reg_NUM);
+  (void)Ty;
+  static const char *RegNames[] = {
 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt,    \
           isFP)                                                                \
   name,
-    REGARM32_TABLE
+      REGARM32_TABLE
 #undef X
-};
+  };
 
-IceString TargetARM32::getRegName(SizeT RegNum, Type Ty) const {
-  assert(RegNum < RegARM32::Reg_NUM);
-  (void)Ty;
   return RegNames[RegNum];
 }
 
index 1e0f284..198563c 100644 (file)
@@ -389,7 +389,6 @@ protected:
   llvm::SmallBitVector ScratchRegs;
   llvm::SmallBitVector RegsUsed;
   VarList PhysicalRegisters[IceType_NUM];
-  static IceString RegNames[];
 
   /// Helper class that understands the Calling Convention and register
   /// assignments. The first few integer type parameters can use r0-r3,
index a7e85a8..add97b3 100644 (file)
@@ -220,17 +220,16 @@ bool TargetMIPS32::doBranchOpt(Inst *I, const CfgNode *NextNode) {
   return false;
 }
 
-IceString TargetMIPS32::RegNames[] = {
+IceString TargetMIPS32::getRegName(SizeT RegNum, Type Ty) const {
+  assert(RegNum < RegMIPS32::Reg_NUM);
+  (void)Ty;
+  static const char *RegNames[] = {
 #define X(val, encode, name, scratch, preserved, stackptr, frameptr, isInt,    \
           isFP)                                                                \
   name,
-    REGMIPS32_TABLE
+      REGMIPS32_TABLE
 #undef X
-};
-
-IceString TargetMIPS32::getRegName(SizeT RegNum, Type Ty) const {
-  assert(RegNum < RegMIPS32::Reg_NUM);
-  (void)Ty;
+  };
   return RegNames[RegNum];
 }
 
index e581ffa..e63d738 100644 (file)
@@ -129,7 +129,6 @@ protected:
   llvm::SmallBitVector ScratchRegs;
   llvm::SmallBitVector RegsUsed;
   VarList PhysicalRegisters[IceType_NUM];
-  static IceString RegNames[];
 
 private:
   ~TargetMIPS32() override = default;