Skip to content

[ARM] Always lower direct calls as direct when the outliner is enabled #66434

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions llvm/lib/CodeGen/TargetPassConfig.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,9 @@ void TargetPassConfig::addMachinePasses() {
addPass(&LiveDebugValuesID);
addPass(&MachineSanitizerBinaryMetadataID);

if (EnableMachineOutliner == RunOutliner::NeverOutline)
TM->Options.EnableMachineOutliner = false;

if (TM->Options.EnableMachineOutliner &&
getOptLevel() != CodeGenOptLevel::None &&
EnableMachineOutliner != RunOutliner::NeverOutline) {
Expand Down
8 changes: 8 additions & 0 deletions llvm/lib/Target/ARM/ARMISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2395,6 +2395,14 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
return isa<Instruction>(U) &&
cast<Instruction>(U)->getParent() == BB;
}) > 2;
// The indirect call lowering hinders the MachineOutliner's ability to
// recognize common sequences. The resulting indirect calls all have the
// same target, but the outliner can't tell this a priori, since the
// branch target is turned into a register operand, and those can't (yet?)
// be assumed to have the same value at runtime.
const TargetOptions &Options = DAG.getTarget().Options;
if (Options.EnableMachineOutliner)
PreferIndirect = false;
}
}
if (isTailCall) {
Expand Down
13 changes: 9 additions & 4 deletions llvm/test/CodeGen/ARM/minsize-call-cse.ll
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
; RUN: llc < %s | FileCheck %s
; RUN: llc < %s | FileCheck %s --check-prefixes=OUTLINER,CHECK
; RUN: llc -enable-machine-outliner=always < %s | FileCheck %s --check-prefixes=OUTLINER,CHECK
; RUN: llc -enable-machine-outliner=never < %s | FileCheck %s --check-prefixes=INDIRECT,CHECK

target datalayout = "e-m:e-p:32:32-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7m-arm-none-eabi"

; CHECK-LABEL: f:
; CHECK: blx r
; CHECK: blx r
; CHECK: blx r
; OUTLINER: bl g
; OUTLINER: bl g
; OUTLINER: bl g
; INDIRECT: blx r
; INDIRECT: blx r
; INDIRECT: blx r
define void @f() minsize optsize {
entry:
call void @g(i32 45, i32 66)
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/ARM/pr42062.ll
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc -o - %s 2>&1 | FileCheck %s --implicit-check-not=error
; RUN: llc -o - %s -enable-machine-outliner=never 2>&1 | FileCheck %s --implicit-check-not=error
target triple = "thumbv8m.base-arm-none-eabi"
@foo = external global i8
declare i32 @bar(ptr nocapture, i32, i32, ptr nocapture)
Expand Down