[flang-commits] [flang] Revert "Reland "[flang] Added noalias attribute to function arguments… (PR #142128)
Tom Eccles via flang-commits
flang-commits at lists.llvm.org
Fri May 30 08:02:19 PDT 2025
https://github.com/tblah updated https://github.com/llvm/llvm-project/pull/142128
>From 645f6c332a1e7b9566900cd071cc44eca50d27a5 Mon Sep 17 00:00:00 2001
From: Tom Eccles <tom.eccles at arm.com>
Date: Fri, 30 May 2025 14:53:07 +0000
Subject: [PATCH] [flang] Disable noalias captures(none) by default
This is due to a 70% regression in exchange2_r on neoverse-v2
due to function specialization no longer triggering in the LTO
pipline.
---
flang/lib/Optimizer/Passes/Pipelines.cpp | 15 ++++++++++++---
flang/test/Fir/polymorphic.fir | 2 +-
flang/test/Fir/struct-passing-x86-64-byval.fir | 2 +-
flang/test/Fir/target-rewrite-complex-10-x86.fir | 2 +-
flang/test/Fir/target.fir | 2 +-
5 files changed, 16 insertions(+), 7 deletions(-)
diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp
index 0c774eede4c9a..ec17a93b53ff4 100644
--- a/flang/lib/Optimizer/Passes/Pipelines.cpp
+++ b/flang/lib/Optimizer/Passes/Pipelines.cpp
@@ -10,6 +10,14 @@
/// common to flang and the test tools.
#include "flang/Optimizer/Passes/Pipelines.h"
+#include "llvm/Support/CommandLine.h"
+
+/// Force setting the no-alias attribute on fuction arguments when possible.
+static llvm::cl::opt<bool> forceNoAlias("force-no-alias", llvm::cl::Hidden,
+ llvm::cl::init(false));
+/// Force setting the no-capture attribute on fuction arguments when possible.
+static llvm::cl::opt<bool> forceNoCapture("force-no-capture", llvm::cl::Hidden,
+ llvm::cl::init(false));
namespace fir {
@@ -350,9 +358,10 @@ void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
else
framePointerKind = mlir::LLVM::framePointerKind::FramePointerKind::None;
- bool setNoCapture = false, setNoAlias = false;
- if (config.OptLevel.isOptimizingForSpeed())
- setNoCapture = setNoAlias = true;
+ // TODO: re-enable setNoAlias by default (when optimizing for speed) once
+ // function specialization is fixed.
+ bool setNoAlias = forceNoAlias;
+ bool setNoCapture = forceNoCapture;
pm.addPass(fir::createFunctionAttr(
{framePointerKind, config.InstrumentFunctionEntry,
diff --git a/flang/test/Fir/polymorphic.fir b/flang/test/Fir/polymorphic.fir
index 84fa2e950633f..d9a13a99477ce 100644
--- a/flang/test/Fir/polymorphic.fir
+++ b/flang/test/Fir/polymorphic.fir
@@ -1,4 +1,4 @@
-// RUN: tco %s | FileCheck %s
+// RUN: tco --force-no-capture %s | FileCheck %s
// Test code gen for unlimited polymorphic type descriptor.
diff --git a/flang/test/Fir/struct-passing-x86-64-byval.fir b/flang/test/Fir/struct-passing-x86-64-byval.fir
index 997d2930f836c..dd25b80a3f81d 100644
--- a/flang/test/Fir/struct-passing-x86-64-byval.fir
+++ b/flang/test/Fir/struct-passing-x86-64-byval.fir
@@ -1,7 +1,7 @@
// Test X86-64 ABI rewrite of struct passed by value (BIND(C), VALUE derived types).
// This test test cases where the struct must be passed on the stack according
// to the System V ABI.
-// RUN: tco --target=x86_64-unknown-linux-gnu %s | FileCheck %s
+// RUN: tco --target=x86_64-unknown-linux-gnu --force-no-capture --force-no-alias %s | FileCheck %s
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
diff --git a/flang/test/Fir/target-rewrite-complex-10-x86.fir b/flang/test/Fir/target-rewrite-complex-10-x86.fir
index 5f917ee42d598..b05187c65a932 100644
--- a/flang/test/Fir/target-rewrite-complex-10-x86.fir
+++ b/flang/test/Fir/target-rewrite-complex-10-x86.fir
@@ -1,6 +1,6 @@
// Test COMPLEX(10) passing and returning on X86
// RUN: fir-opt --target-rewrite="target=x86_64-unknown-linux-gnu" %s | FileCheck %s --check-prefix=AMD64
-// RUN: tco -target="x86_64-unknown-linux-gnu" %s | FileCheck %s --check-prefix=AMD64_LLVM
+// RUN: tco -target="x86_64-unknown-linux-gnu" --force-no-alias --force-no-capture %s | FileCheck %s --check-prefix=AMD64_LLVM
module attributes {fir.defaultkind = "a1c4d8i4l4r4", fir.kindmap = "", llvm.data_layout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", llvm.target_triple = "x86_64-unknown-linux-gnu"} {
diff --git a/flang/test/Fir/target.fir b/flang/test/Fir/target.fir
index e1190649e0803..d40bcae4a8ad2 100644
--- a/flang/test/Fir/target.fir
+++ b/flang/test/Fir/target.fir
@@ -1,4 +1,4 @@
-// RUN: tco --target=i386-unknown-linux-gnu %s | FileCheck %s --check-prefix=I32
+// RUN: tco --target=i386-unknown-linux-gnu --force-no-alias --force-no-capture %s | FileCheck %s --check-prefix=I32
// RUN: tco --target=x86_64-unknown-linux-gnu %s | FileCheck %s --check-prefix=X64
// RUN: tco --target=aarch64-unknown-linux-gnu %s | FileCheck %s --check-prefix=AARCH64
// RUN: tco --target=powerpc64le-unknown-linux-gnu %s | FileCheck %s --check-prefix=PPC
More information about the flang-commits
mailing list