Skip to content

[flang] Disable noalias by default #142128

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 2 commits into from
May 30, 2025
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
12 changes: 9 additions & 3 deletions flang/lib/Optimizer/Passes/Pipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@
/// 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));

namespace fir {

Expand Down Expand Up @@ -350,9 +355,10 @@ void createDefaultFIRCodeGenPassPipeline(mlir::PassManager &pm,
else
framePointerKind = mlir::LLVM::framePointerKind::FramePointerKind::None;

bool setNoCapture = false, setNoAlias = false;
if (config.OptLevel.isOptimizingForSpeed())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tom, will you be okay if I just remove this if? The LIT tests should still work, and it will be easier to re-enable the code, when function speciailization is fixed.

setNoCapture = setNoAlias = true;
// TODO: re-enable setNoAlias by default (when optimizing for speed) once
// function specialization is fixed.
bool setNoAlias = forceNoAlias;
bool setNoCapture = config.OptLevel.isOptimizingForSpeed();

pm.addPass(fir::createFunctionAttr(
{framePointerKind, config.InstrumentFunctionEntry,
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Fir/struct-passing-x86-64-byval.fir
Original file line number Diff line number Diff line change
@@ -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-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"} {

Expand Down
2 changes: 1 addition & 1 deletion flang/test/Fir/target-rewrite-complex-10-x86.fir
Original file line number Diff line number Diff line change
@@ -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 %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"} {

Expand Down
2 changes: 1 addition & 1 deletion flang/test/Fir/target.fir
Original file line number Diff line number Diff line change
@@ -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 %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
Expand Down