diff --git a/flang/lib/Optimizer/Passes/Pipelines.cpp b/flang/lib/Optimizer/Passes/Pipelines.cpp index 0c774eede4c9a..00248032daf92 100644 --- a/flang/lib/Optimizer/Passes/Pipelines.cpp +++ b/flang/lib/Optimizer/Passes/Pipelines.cpp @@ -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 forceNoAlias("force-no-alias", llvm::cl::Hidden, + llvm::cl::init(false)); namespace fir { @@ -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()) - 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, diff --git a/flang/test/Fir/struct-passing-x86-64-byval.fir b/flang/test/Fir/struct-passing-x86-64-byval.fir index 997d2930f836c..e22c3a23ef9da 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-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..d54f98b72b3d2 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 %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..b04e23a018e7e 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 %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