[PATCH] Enable global merge pass
Jiangning Liu
liujiangning1 at gmail.com
Fri Apr 18 20:37:46 PDT 2014
Hi qcolombet, t.p.northover,
This is the patch to enable global merge pass for AArch64 and adrp instructions can be reduced accordingly. For ARM64, it also works, but it fails to reduce adrp instructions statically due to different ISEL strategy.
http://reviews.llvm.org/D3431
Files:
lib/Target/AArch64/AArch64ISelLowering.cpp
lib/Target/AArch64/AArch64ISelLowering.h
lib/Target/AArch64/AArch64TargetMachine.cpp
test/CodeGen/AArch64/global_merge_1.ll
Index: lib/Target/AArch64/AArch64ISelLowering.cpp
===================================================================
--- lib/Target/AArch64/AArch64ISelLowering.cpp
+++ lib/Target/AArch64/AArch64ISelLowering.cpp
@@ -5537,3 +5537,10 @@
return AM.Scale != 0 && AM.Scale != 1;
return -1;
}
+
+/// getMaximalGlobalOffset - Returns the maximal possible offset which can
+/// be used for loads / stores from the global.
+unsigned AArch64TargetLowering::getMaximalGlobalOffset() const {
+ return 4095;
+}
+
Index: lib/Target/AArch64/AArch64ISelLowering.h
===================================================================
--- lib/Target/AArch64/AArch64ISelLowering.h
+++ lib/Target/AArch64/AArch64ISelLowering.h
@@ -376,6 +376,10 @@
virtual bool getTgtMemIntrinsic(IntrinsicInfo &Info, const CallInst &I,
unsigned Intrinsic) const override;
+ /// getMaximalGlobalOffset - Returns the maximal possible offset which can
+ /// be used for loads / stores from the global.
+ unsigned getMaximalGlobalOffset() const override;
+
protected:
std::pair<const TargetRegisterClass*, uint8_t>
findRepresentativeClass(MVT VT) const;
Index: lib/Target/AArch64/AArch64TargetMachine.cpp
===================================================================
--- lib/Target/AArch64/AArch64TargetMachine.cpp
+++ lib/Target/AArch64/AArch64TargetMachine.cpp
@@ -19,6 +19,7 @@
#include "llvm/CodeGen/Passes.h"
#include "llvm/PassManager.h"
#include "llvm/Support/TargetRegistry.h"
+#include "llvm/Transforms/Scalar.h"
using namespace llvm;
@@ -86,11 +87,19 @@
return *getAArch64TargetMachine().getSubtargetImpl();
}
+ bool addPreISel() override;
virtual bool addInstSelector();
virtual bool addPreEmitPass();
};
} // namespace
+bool AArch64PassConfig::addPreISel() {
+ if (TM->getOptLevel() != CodeGenOpt::None)
+ addPass(createGlobalMergePass(TM));
+
+ return false;
+}
+
TargetPassConfig *AArch64TargetMachine::createPassConfig(PassManagerBase &PM) {
return new AArch64PassConfig(this, PM);
}
Index: test/CodeGen/AArch64/global_merge_1.ll
===================================================================
--- /dev/null
+++ test/CodeGen/AArch64/global_merge_1.ll
@@ -0,0 +1,17 @@
+; RUN: llc < %s -mtriple=aarch64-none-linux-gnu | FileCheck %s
+
+ at m = internal global i32 0, align 4
+ at n = internal global i32 0, align 4
+
+define void @f1(i32 %a1, i32 %a2) {
+; CHECK-LABEL: f1:
+; CHECK: adrp x{{[0-9]+}}, _MergedGlobals
+; CHECK-NOT: adrp
+ store i32 %a1, i32* @m, align 4
+ store i32 %a2, i32* @n, align 4
+ ret void
+}
+
+; CHECK: .local _MergedGlobals
+; CHECK: .comm _MergedGlobals,8,8
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3431.1.patch
Type: text/x-patch
Size: 2683 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140418/c555d4e9/attachment.bin>
More information about the llvm-commits
mailing list