Skip to content
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
6 changes: 5 additions & 1 deletion flang/docs/Extensions.md
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,11 @@ end
* `<>` as synonym for `.NE.` and `/=`
* `$` and `@` as legal characters in names
* Initialization in type declaration statements using `/values/`
* Saved variables without explicit or default initializers are zero initialized.
* Saved variables without explicit or default initializers are zero initialized,
except for scalar variables from the main program that are not explicitly
initialized or marked with an explicit SAVE attribute (these variables may be
placed on the stack by flang and not zero initialized). It is not advised to
rely on this extension in new code.
* In a saved entity of a type with a default initializer, components without default
values are zero initialized.
* Kind specification with `*`, e.g. `REAL*4`
Expand Down
37 changes: 22 additions & 15 deletions flang/lib/Optimizer/Transforms/StackArrays.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,18 @@ std::optional<AllocationState> LatticePoint::get(mlir::Value val) const {
return it->second;
}

static mlir::Value lookThroughDeclaresAndConverts(mlir::Value value) {
while (mlir::Operation *op = value.getDefiningOp()) {
if (auto declareOp = llvm::dyn_cast<fir::DeclareOp>(op))
value = declareOp.getMemref();
else if (auto convertOp = llvm::dyn_cast<fir::ConvertOp>(op))
value = convertOp->getOperand(0);
else
return value;
}
return value;
}

mlir::LogicalResult AllocationAnalysis::visitOperation(
mlir::Operation *op, const LatticePoint &before, LatticePoint *after) {
LLVM_DEBUG(llvm::dbgs() << "StackArrays: Visiting operation: " << *op
Expand Down Expand Up @@ -363,10 +375,10 @@ mlir::LogicalResult AllocationAnalysis::visitOperation(
mlir::Value operand = op->getOperand(0);

// Note: StackArrays is scheduled in the pass pipeline after lowering hlfir
// to fir. Therefore, we only need to handle `fir::DeclareOp`s.
if (auto declareOp =
llvm::dyn_cast_if_present<fir::DeclareOp>(operand.getDefiningOp()))
operand = declareOp.getMemref();
// to fir. Therefore, we only need to handle `fir::DeclareOp`s. Also look
// past converts in case the pointer was changed between different pointer
// types.
operand = lookThroughDeclaresAndConverts(operand);

std::optional<AllocationState> operandState = before.get(operand);
if (operandState && *operandState == AllocationState::Allocated) {
Expand Down Expand Up @@ -535,17 +547,12 @@ AllocMemConversion::matchAndRewrite(fir::AllocMemOp allocmem,

// remove freemem operations
llvm::SmallVector<mlir::Operation *> erases;
for (mlir::Operation *user : allocmem.getOperation()->getUsers()) {
if (auto declareOp = mlir::dyn_cast_if_present<fir::DeclareOp>(user)) {
for (mlir::Operation *user : declareOp->getUsers()) {
if (mlir::isa<fir::FreeMemOp>(user))
erases.push_back(user);
}
}

if (mlir::isa<fir::FreeMemOp>(user))
erases.push_back(user);
}
mlir::Operation *parent = allocmem->getParentOp();
// TODO: this shouldn't need to be re-calculated for every allocmem
parent->walk([&](fir::FreeMemOp freeOp) {
if (lookThroughDeclaresAndConverts(freeOp->getOperand(0)) == allocmem)
erases.push_back(freeOp);
});

// now we are done iterating the users, it is safe to mutate them
for (mlir::Operation *erase : erases)
Expand Down
20 changes: 19 additions & 1 deletion flang/test/Transforms/stack-arrays.fir
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,8 @@ func.func @placement_loop_declare() {
%3 = arith.addi %c1, %c2 : index
// operand is now available
%4 = fir.allocmem !fir.array<?xi32>, %3
%5 = fir.declare %4 {uniq_name = "temp"} : (!fir.heap<!fir.array<?xi32>>) -> !fir.heap<!fir.array<?xi32>>
%shape = fir.shape %3 : (index) -> !fir.shape<1>
%5 = fir.declare %4(%shape) {uniq_name = "temp"} : (!fir.heap<!fir.array<?xi32>>, !fir.shape<1>) -> !fir.heap<!fir.array<?xi32>>
// ...
fir.freemem %5 : !fir.heap<!fir.array<?xi32>>
fir.result %3, %c1_i32 : index, i32
Expand All @@ -400,3 +401,20 @@ func.func @placement_loop_declare() {
// CHECK-NEXT: }
// CHECK-NEXT: return
// CHECK-NEXT: }

// Can we look through fir.convert and fir.declare?
func.func @lookthrough() {
%0 = fir.allocmem !fir.array<42xi32>
%c42 = arith.constant 42 : index
%shape = fir.shape %c42 : (index) -> !fir.shape<1>
%1 = fir.declare %0(%shape) {uniq_name = "name"} : (!fir.heap<!fir.array<42xi32>>, !fir.shape<1>) -> !fir.heap<!fir.array<42xi32>>
%2 = fir.convert %1 : (!fir.heap<!fir.array<42xi32>>) -> !fir.ref<!fir.array<42xi32>>
// use the ref so the converts aren't folded
%3 = fir.load %2 : !fir.ref<!fir.array<42xi32>>
%4 = fir.convert %2 : (!fir.ref<!fir.array<42xi32>>) -> !fir.heap<!fir.array<42xi32>>
fir.freemem %4 : !fir.heap<!fir.array<42xi32>>
return
}
// CHECK: func.func @lookthrough() {
// CHECK: fir.alloca !fir.array<42xi32>
// CHECK-NOT: fir.freemem
15 changes: 12 additions & 3 deletions llvm/Maintainers.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,12 @@ Matthew.Arsenault@amd.com, arsenm2@gmail.com (email), [arsenm](https://github.co

#### Inlining

Chandler Carruth \
chandlerc@gmail.com, chandlerc@google.com (email), [chandlerc](https://github.com/chandlerc) (GitHub)
Arthur Eubanks \
aeubanks@google.com (email), [aeubanks](https://github.com/aeubanks) (GitHub) \
Mircea Trofin (esp. ML inliner) \
mtrofin@google.com (email), [mtrofin](https://github.com/mtrofin) (GitHub) \
Kazu Hirata (esp. module inliner and inline order) \
kazu@google.com (email), [kazutakahirata](https://github.com/kazutakahirata) (GitHub)

#### InstCombine, InstSimplify, ValueTracking, ConstantFold

Expand All @@ -65,6 +69,11 @@ mail@justinbogner.com (email), [bogner](https://github.com/bogner) (GitHub)
Diego Novillo \
dnovillo@google.com (email), [dnovillo](https://github.com/dnovillo) (GitHub)

#### New pass manager, CGSCC, LazyCallGraph

Arthur Eubanks \
aeubanks@google.com (email), [aeubanks](https://github.com/aeubanks) (GitHub)

#### LoopStrengthReduce

Quentin Colombet \
Expand Down Expand Up @@ -462,7 +471,7 @@ sabre@nondot.org (email), [lattner](https://github.com/lattner) (GitHub), clattn

Paul C. Anagnostopoulos (paul@windfall.com, [Paul-C-Anagnostopoulos](https://github.com/Paul-C-Anagnostopoulos)) -- TableGen \
Justin Bogner (mail@justinbogner.com, [bogner](https://github.com/bogner)) -- SelectionDAG \
Chandler Carruth (chandlerc@gmail.com, chandlerc@google.com, [chandlerc](https://github.com/chandlerc)) -- ADT, Support \
Chandler Carruth (chandlerc@gmail.com, chandlerc@google.com, [chandlerc](https://github.com/chandlerc)) -- ADT, Support, Inlining \
Peter Collingbourne (peter@pcc.me.uk, [pcc](https://github.com/pcc)) -- LTO \
Evan Cheng (evan.cheng@apple.com) -- Parts of code generator not covered by someone else \
Jake Ehrlich (jakehehrlich@google.com, [jakehehrlich](https://github.com/jakehehrlich)) -- llvm-objcopy and ObjCopy library \
Expand Down
4 changes: 2 additions & 2 deletions llvm/include/llvm/ADT/STLFunctionalExtras.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ namespace llvm {
/// a function_ref.
template<typename Fn> class function_ref;

template<typename Ret, typename ...Params>
class function_ref<Ret(Params...)> {
template <typename Ret, typename... Params>
class LLVM_GSL_POINTER function_ref<Ret(Params...)> {
Ret (*callback)(intptr_t callable, Params ...params) = nullptr;
intptr_t callable;

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Analysis/ScalarEvolution.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ static cl::opt<unsigned> RangeIterThreshold(

static cl::opt<unsigned> MaxLoopGuardCollectionDepth(
"scalar-evolution-max-loop-guard-collection-depth", cl::Hidden,
cl::desc("Maximum depth for recrusive loop guard collection"), cl::init(1));
cl::desc("Maximum depth for recursive loop guard collection"), cl::init(1));

static cl::opt<bool>
ClassifyExpressions("scalar-evolution-classify-expressions",
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/CodeGenPrepare.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ static cl::opt<bool>

static cl::opt<bool>
EnableAndCmpSinking("enable-andcmp-sinking", cl::Hidden, cl::init(true),
cl::desc("Enable sinkinig and/cmp into branches."));
cl::desc("Enable sinking and/cmp into branches."));

static cl::opt<bool> DisableStoreExtract(
"disable-cgp-store-extract", cl::Hidden, cl::init(false),
Expand Down
5 changes: 3 additions & 2 deletions llvm/lib/CodeGen/MIRSampleProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,9 @@ static cl::opt<bool> ShowFSBranchProb(
cl::desc("Print setting flow sensitive branch probabilities"));
static cl::opt<unsigned> FSProfileDebugProbDiffThreshold(
"fs-profile-debug-prob-diff-threshold", cl::init(10),
cl::desc("Only show debug message if the branch probility is greater than "
"this value (in percentage)."));
cl::desc(
"Only show debug message if the branch probability is greater than "
"this value (in percentage)."));

static cl::opt<unsigned> FSProfileDebugBWThreshold(
"fs-profile-debug-bw-threshold", cl::init(10000),
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineBlockPlacement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ static cl::opt<unsigned> JumpInstCost("jump-inst-cost",
static cl::opt<bool>
TailDupPlacement("tail-dup-placement",
cl::desc("Perform tail duplication during placement. "
"Creates more fallthrough opportunites in "
"Creates more fallthrough opportunities in "
"outline branches."),
cl::init(true), cl::Hidden);

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/MachineBranchProbabilityInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ namespace llvm {
cl::opt<unsigned>
StaticLikelyProb("static-likely-prob",
cl::desc("branch probability threshold in percentage"
"to be considered very likely"),
" to be considered very likely"),
cl::init(80), cl::Hidden);

cl::opt<unsigned> ProfileLikelyProb(
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/RegAllocGreedy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ static cl::opt<bool> GreedyReverseLocalAssignment(
static cl::opt<unsigned> SplitThresholdForRegWithHint(
"split-threshold-for-reg-with-hint",
cl::desc("The threshold for splitting a virtual register with a hint, in "
"percentate"),
"percentage"),
cl::init(75), cl::Hidden);

static RegisterRegAlloc greedyRegAlloc("greedy", "greedy register allocator",
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/RegisterCoalescer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ static cl::opt<unsigned> LargeIntervalSizeThreshold(

static cl::opt<unsigned> LargeIntervalFreqThreshold(
"large-interval-freq-threshold", cl::Hidden,
cl::desc("For a large interval, if it is coalesed with other live "
cl::desc("For a large interval, if it is coalesced with other live "
"intervals many times more than the threshold, stop its "
"coalescing to control the compile time. "),
cl::init(256));
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ static cl::opt<bool> EnableReduceLoadOpStoreWidth(
static cl::opt<bool> ReduceLoadOpStoreWidthForceNarrowingProfitable(
"combiner-reduce-load-op-store-width-force-narrowing-profitable",
cl::Hidden, cl::init(false),
cl::desc("DAG combiner force override the narrowing profitable check when"
cl::desc("DAG combiner force override the narrowing profitable check when "
"reducing the width of load/op/store sequences"));

static cl::opt<bool> EnableShrinkLoadReplaceStoreWithStore(
Expand Down
25 changes: 25 additions & 0 deletions llvm/lib/CodeGen/SelectionDAG/LegalizeVectorOps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1777,6 +1777,31 @@ void VectorLegalizer::ExpandUINT_TO_FLOAT(SDNode *Node,
assert((BW == 64 || BW == 32) &&
"Elements in vector-UINT_TO_FP must be 32 or 64 bits wide");

// If STRICT_/FMUL is not supported by the target (in case of f16) replace the
// UINT_TO_FP with a larger float and round to the smaller type
if ((!IsStrict && !TLI.isOperationLegalOrCustom(ISD::FMUL, DstVT)) ||
(IsStrict && !TLI.isOperationLegalOrCustom(ISD::STRICT_FMUL, DstVT))) {
EVT FPVT = BW == 32 ? MVT::f32 : MVT::f64;
SDValue UIToFP;
SDValue Result;
SDValue TargetZero = DAG.getIntPtrConstant(0, DL, /*isTarget=*/true);
EVT FloatVecVT = SrcVT.changeVectorElementType(FPVT);
if (IsStrict) {
UIToFP = DAG.getNode(ISD::STRICT_UINT_TO_FP, DL, {FloatVecVT, MVT::Other},
{Node->getOperand(0), Src});
Result = DAG.getNode(ISD::STRICT_FP_ROUND, DL, {DstVT, MVT::Other},
{Node->getOperand(0), UIToFP, TargetZero});
Results.push_back(Result);
Results.push_back(Result.getValue(1));
} else {
UIToFP = DAG.getNode(ISD::UINT_TO_FP, DL, FloatVecVT, Src);
Result = DAG.getNode(ISD::FP_ROUND, DL, DstVT, UIToFP, TargetZero);
Results.push_back(Result);
}

return;
}

SDValue HalfWord = DAG.getConstant(BW / 2, DL, SrcVT);

// Constants to clear the upper part of the word.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/ScheduleDAGRRList.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ static cl::opt<int> MaxReorderWindow(
cl::desc("Number of instructions to allow ahead of the critical path "
"in sched=list-ilp"));

static cl::opt<unsigned> AvgIPC(
"sched-avg-ipc", cl::Hidden, cl::init(1),
cl::desc("Average inst/cycle whan no target itinerary exists."));
static cl::opt<unsigned>
AvgIPC("sched-avg-ipc", cl::Hidden, cl::init(1),
cl::desc("Average inst/cycle when no target itinerary exists."));

namespace {

Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/CodeGen/SelectionDAG/ScheduleDAGSDNodes.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ STATISTIC(LoadsClustered, "Number of loads clustered together");
// without a target itinerary. The choice of number here has more to do with
// balancing scheduler heuristics than with the actual machine latency.
static cl::opt<int> HighLatencyCycles(
"sched-high-latency-cycles", cl::Hidden, cl::init(10),
cl::desc("Roughly estimate the number of cycles that 'long latency'"
"instructions take for targets with no itinerary"));
"sched-high-latency-cycles", cl::Hidden, cl::init(10),
cl::desc("Roughly estimate the number of cycles that 'long latency' "
"instructions take for targets with no itinerary"));

ScheduleDAGSDNodes::ScheduleDAGSDNodes(MachineFunction &mf)
: ScheduleDAG(mf), InstrItins(mf.getSubtarget().getInstrItineraryData()) {}
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Passes/PassBuilderPipelines.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,9 +189,9 @@ static cl::opt<bool> EnableGlobalAnalyses(
"enable-global-analyses", cl::init(true), cl::Hidden,
cl::desc("Enable inter-procedural analyses"));

static cl::opt<bool>
RunPartialInlining("enable-partial-inlining", cl::init(false), cl::Hidden,
cl::desc("Run Partial inlinining pass"));
static cl::opt<bool> RunPartialInlining("enable-partial-inlining",
cl::init(false), cl::Hidden,
cl::desc("Run Partial inlining pass"));

static cl::opt<bool> ExtraVectorizerPasses(
"extra-vectorizer-passes", cl::init(false), cl::Hidden,
Expand Down Expand Up @@ -264,7 +264,7 @@ static cl::opt<bool>
static cl::opt<bool> FlattenedProfileUsed(
"flattened-profile-used", cl::init(false), cl::Hidden,
cl::desc("Indicate the sample profile being used is flattened, i.e., "
"no inline hierachy exists in the profile"));
"no inline hierarchy exists in the profile"));

static cl::opt<bool> EnableOrderFileInstrumentation(
"enable-order-file-instrumentation", cl::init(false), cl::Hidden,
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AArch64/AArch64InstrFormats.td
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,9 @@ class TMSystemException<bits<3> op1, string asm, list<dag> pattern>
}

class APASI : SimpleSystemI<0, (ins GPR64:$Xt), "apas", "\t$Xt">, Sched<[]> {
bits<5> Xt;
let Inst{20-5} = 0b0111001110000000;
let Inst{4-0} = Xt;
let DecoderNamespace = "APAS";
}

Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/AArch64/AArch64TargetTransformInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4748,7 +4748,7 @@ InstructionCost AArch64TTIImpl::getShuffleCost(
LT.second.getVectorNumElements() / 2) {
if (Index == 0)
return 0;
if (Index == LT.second.getVectorNumElements() / 2)
if (Index == (int)LT.second.getVectorNumElements() / 2)
return 1;
}
Kind = TTI::SK_PermuteSingleSrc;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ static cl::opt<int> BrMergingCcmpBias(

static cl::opt<bool>
WidenShift("x86-widen-shift", cl::init(true),
cl::desc("Replacte narrow shifts with wider shifts."),
cl::desc("Replace narrow shifts with wider shifts."),
cl::Hidden);

static cl::opt<int> BrMergingLikelyBias(
Expand Down
14 changes: 7 additions & 7 deletions llvm/lib/Transforms/IPO/FunctionSpecialization.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,19 +66,19 @@ static cl::opt<unsigned> MaxCodeSizeGrowth(
"Maximum codesize growth allowed per function"));

static cl::opt<unsigned> MinCodeSizeSavings(
"funcspec-min-codesize-savings", cl::init(20), cl::Hidden, cl::desc(
"Reject specializations whose codesize savings are less than this"
"much percent of the original function size"));
"funcspec-min-codesize-savings", cl::init(20), cl::Hidden,
cl::desc("Reject specializations whose codesize savings are less than this "
"much percent of the original function size"));

static cl::opt<unsigned> MinLatencySavings(
"funcspec-min-latency-savings", cl::init(40), cl::Hidden,
cl::desc("Reject specializations whose latency savings are less than this"
cl::desc("Reject specializations whose latency savings are less than this "
"much percent of the original function size"));

static cl::opt<unsigned> MinInliningBonus(
"funcspec-min-inlining-bonus", cl::init(300), cl::Hidden, cl::desc(
"Reject specializations whose inlining bonus is less than this"
"much percent of the original function size"));
"funcspec-min-inlining-bonus", cl::init(300), cl::Hidden,
cl::desc("Reject specializations whose inlining bonus is less than this "
"much percent of the original function size"));

static cl::opt<bool> SpecializeOnAddress(
"funcspec-on-address", cl::init(false), cl::Hidden, cl::desc(
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/GlobalOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ static cl::opt<int> ColdCCRelFreq(
"coldcc-rel-freq", cl::Hidden, cl::init(2),
cl::desc(
"Maximum block frequency, expressed as a percentage of caller's "
"entry frequency, for a call site to be considered cold for enabling"
"entry frequency, for a call site to be considered cold for enabling "
"coldcc"));

/// Is this global variable possibly used by a leak checker as a root? If so,
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Transforms/IPO/OpenMPOpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ static cl::opt<bool> PrintModuleBeforeOptimizations(

static cl::opt<bool> AlwaysInlineDeviceFunctions(
"openmp-opt-inline-device",
cl::desc("Inline all applicible functions on the device."), cl::Hidden,
cl::desc("Inline all applicable functions on the device."), cl::Hidden,
cl::init(false));

static cl::opt<bool>
Expand Down
Loading