diff options
author | James Molloy <james.molloy@arm.com> | 2016-09-15 12:30:27 +0000 |
---|---|---|
committer | James Molloy <james.molloy@arm.com> | 2016-09-15 12:30:27 +0000 |
commit | fe7fd879d78c97a94a57d9beb7b5896f75491ae7 (patch) | |
tree | cea20653361a6b41b4a32549574a52d289eecd6d /llvm/lib/Target/ARM/ARMAsmPrinter.h | |
parent | 50bc34ca31d1499472a1117ded41be34e4c44067 (diff) | |
download | bcm5719-llvm-fe7fd879d78c97a94a57d9beb7b5896f75491ae7.tar.gz bcm5719-llvm-fe7fd879d78c97a94a57d9beb7b5896f75491ae7.zip |
[ARM] Promote small global constants to constant pools
If a constant is unamed_addr and is only used within one function, we can save
on the code size and runtime cost of an indirection by changing the global's storage
to inside the constant pool. For example, instead of:
ldr r0, .CPI0
bl printf
bx lr
.CPI0: &format_string
format_string: .asciz "hello, world!\n"
We can emit:
adr r0, .CPI0
bl printf
bx lr
.CPI0: .asciz "hello, world!\n"
This can cause significant code size savings when many small strings are used in one
function (4 bytes per string).
This recommit contains fixes for a nasty bug related to fast-isel fallback - because
fast-isel doesn't know about this optimization, if it runs and emits references to
a string that we inline (because fast-isel fell back to SDAG) we will end up
with an inlined string and also an out-of-line string, and we won't emit the
out-of-line string, causing backend failures.
llvm-svn: 281604
Diffstat (limited to 'llvm/lib/Target/ARM/ARMAsmPrinter.h')
-rw-r--r-- | llvm/lib/Target/ARM/ARMAsmPrinter.h | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Target/ARM/ARMAsmPrinter.h b/llvm/lib/Target/ARM/ARMAsmPrinter.h index 97f5ca0ecbc..30abdbc322a 100644 --- a/llvm/lib/Target/ARM/ARMAsmPrinter.h +++ b/llvm/lib/Target/ARM/ARMAsmPrinter.h @@ -56,6 +56,12 @@ class LLVM_LIBRARY_VISIBILITY ARMAsmPrinter : public AsmPrinter { /// -1 if uninitialized, 0 if conflicting goals int OptimizationGoals; + /// List of globals that have had their storage promoted to a constant + /// pool. This lives between calls to runOnMachineFunction and collects + /// data from every MachineFunction. It is used during doFinalization + /// when all non-function globals are emitted. + SmallPtrSet<const GlobalVariable*,2> PromotedGlobals; + public: explicit ARMAsmPrinter(TargetMachine &TM, std::unique_ptr<MCStreamer> Streamer); @@ -90,7 +96,8 @@ public: void EmitStartOfAsmFile(Module &M) override; void EmitEndOfAsmFile(Module &M) override; void EmitXXStructor(const DataLayout &DL, const Constant *CV) override; - + void EmitGlobalVariable(const GlobalVariable *GV) override; + // lowerOperand - Convert a MachineOperand into the equivalent MCOperand. bool lowerOperand(const MachineOperand &MO, MCOperand &MCOp); |