Skip to content

Commit d89fedf

Browse files
jitlayers: Use GlobalISel on AArch64 at -O0/-O1
GlobalISel is LLVM's modern instruction selector that is designed to replace both FastISel and SelectionDAG. On AArch64, it is mature and enabled by default at -O0 in upstream LLVM. This enables GlobalISel with fallback mode on AArch64, which provides faster instruction selection than SelectionDAG while maintaining correctness by falling back to SelectionDAG for unsupported patterns. Note: This requires RemoveJuliaAddrspacesPass to run before codegen, which is already the case in the current pipeline (see pipeline.cpp comment about GlobalISel not liking Julia's address spaces). Co-authored-by: Claude <[email protected]>
1 parent 12fdcd5 commit d89fedf

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/jitlayers.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,17 @@ void optimizeDLSyms(Module &M) JL_NOTSAFEPOINT_LEAVE JL_NOTSAFEPOINT_ENTER {
18971897
void fixupTM(TargetMachine &TM) {
18981898
auto TheTriple = TM.getTargetTriple();
18991899
if (jl_options.opt_level < 2) {
1900-
if (!TheTriple.isARM() && !TheTriple.isPPC64())
1900+
// Try GlobalISel on AArch64 - it's the default in LLVM at -O0 and
1901+
// is apparently generally faster than SelectionDAG while producing good code.
1902+
// Use fallback mode so unsupported patterns fall back to SelectionDAG.
1903+
// Note: Requires RemoveJuliaAddrspacesPass to run before codegen
1904+
// because GlobalISel doesn't handle Julia's custom address spaces.
1905+
if (TheTriple.isAArch64()) {
1906+
TM.setGlobalISel(true);
1907+
TM.setGlobalISelAbort(GlobalISelAbortMode::Disable);
1908+
TM.setFastISel(false);
1909+
}
1910+
else if (!TheTriple.isARM() && !TheTriple.isPPC64()) {
19011911
TM.setFastISel(true);
19021912
else // FastISel seems to be buggy Ref #13321
19031913
TM.setFastISel(false);

0 commit comments

Comments
 (0)