[llvm] r223156 - [AArch64][Stackmaps] Optimize stackmap shadows on AArch64.
Lang Hames
lhames at gmail.com
Tue Dec 2 13:36:24 PST 2014
Author: lhames
Date: Tue Dec 2 15:36:24 2014
New Revision: 223156
URL: http://llvm.org/viewvc/llvm-project?rev=223156&view=rev
Log:
[AArch64][Stackmaps] Optimize stackmap shadows on AArch64.
Reduce the number of nops emitted for stackmap shadows on AArch64 by counting
non-stackmap instructions up to the next branch target towards the requested
shadow.
<rdar://problem/14959522>
Added:
llvm/trunk/test/CodeGen/AArch64/arm64-stackmap-nops.ll
Modified:
llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
Modified: llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp?rev=223156&r1=223155&r2=223156&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/AArch64/AArch64AsmPrinter.cpp Tue Dec 2 15:36:24 2014
@@ -381,8 +381,23 @@ void AArch64AsmPrinter::LowerSTACKMAP(MC
unsigned NumNOPBytes = MI.getOperand(1).getImm();
SM.recordStackMap(MI);
- // Emit padding.
assert(NumNOPBytes % 4 == 0 && "Invalid number of NOP bytes requested!");
+
+ // Scan ahead to trim the shadow.
+ const MachineBasicBlock &MBB = *MI.getParent();
+ MachineBasicBlock::const_iterator MII(MI);
+ ++MII;
+ while (NumNOPBytes > 0) {
+ if (MII == MBB.end() || MII->isCall() ||
+ MII->getOpcode() == AArch64::DBG_VALUE ||
+ MII->getOpcode() == TargetOpcode::PATCHPOINT ||
+ MII->getOpcode() == TargetOpcode::STACKMAP)
+ break;
+ ++MII;
+ NumNOPBytes -= 4;
+ }
+
+ // Emit nops.
for (unsigned i = 0; i < NumNOPBytes; i += 4)
EmitToStreamer(OutStreamer, MCInstBuilder(AArch64::HINT).addImm(0));
}
Added: llvm/trunk/test/CodeGen/AArch64/arm64-stackmap-nops.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/arm64-stackmap-nops.ll?rev=223156&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/arm64-stackmap-nops.ll (added)
+++ llvm/trunk/test/CodeGen/AArch64/arm64-stackmap-nops.ll Tue Dec 2 15:36:24 2014
@@ -0,0 +1,15 @@
+; RUN: llc < %s -mtriple=arm64-apple-darwin | FileCheck %s
+
+define void @test_shadow_optimization() {
+entry:
+; Expect 8 bytes worth of nops here rather than 16: With the shadow optimization
+; in place, 8 bytes will be consumed by the frame teardown and return instr.
+; CHECK-LABEL: test_shadow_optimization:
+; CHECK: nop
+; CHECK-NEXT: nop
+; CHECK-NOT: nop
+ tail call void (i64, i32, ...)* @llvm.experimental.stackmap(i64 0, i32 16)
+ ret void
+}
+
+declare void @llvm.experimental.stackmap(i64, i32, ...)
More information about the llvm-commits
mailing list