Skip to content

Commit 12e9cbb

Browse files
authored
Merge branch 'main' into hgh/libcxx/P2164R9-ranges-enumerate_view
2 parents 31ddab0 + eb7c947 commit 12e9cbb

File tree

28 files changed

+528
-169
lines changed

28 files changed

+528
-169
lines changed

libclc/amdgcn/lib/cl_khr_int64_extended_atomics/minmax_helpers.ll

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,3 @@
1-
#if __clang_major__ >= 7
2-
target datalayout = "e-p:64:64-p1:64:64-p2:32:32-p3:32:32-p4:64:64-p5:32:32-p6:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64-S32-A5"
3-
#else
4-
target datalayout = "e-p:32:32-p1:64:64-p2:64:64-p3:32:32-p4:64:64-p5:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
5-
#endif
6-
71
define i64 @__clc__sync_fetch_and_min_global_8(i64 addrspace(1)* nocapture %ptr, i64 %value) nounwind alwaysinline {
82
entry:
93
%0 = atomicrmw volatile min i64 addrspace(1)* %ptr, i64 %value seq_cst

libclc/cmake/modules/AddLibclc.cmake

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,8 @@ function(add_libclc_builtin_set)
225225
message( FATAL_ERROR "Must provide ARCH, ARCH_SUFFIX, and TRIPLE" )
226226
endif()
227227

228-
set( bytecode_files "" )
228+
set( bytecode_files )
229+
set( bytecode_ir_files )
229230
foreach( file IN LISTS ARG_GEN_FILES ARG_LIB_FILES )
230231
# We need to take each file and produce an absolute input file, as well
231232
# as a unique architecture-specific output file. We deal with a mix of
@@ -263,9 +264,23 @@ function(add_libclc_builtin_set)
263264
"${ARG_COMPILE_FLAGS}" -I${CMAKE_CURRENT_SOURCE_DIR}/${file_dir}
264265
DEPENDENCIES ${input_file_dep}
265266
)
266-
list( APPEND bytecode_files ${output_file} )
267+
268+
# Collect all files originating in LLVM IR separately
269+
get_filename_component( file_ext ${file} EXT )
270+
if( ${file_ext} STREQUAL ".ll" )
271+
list( APPEND bytecode_ir_files ${output_file} )
272+
else()
273+
list( APPEND bytecode_files ${output_file} )
274+
endif()
267275
endforeach()
268276

277+
# Prepend all LLVM IR files to the list so they are linked into the final
278+
# bytecode modules first. This helps to suppress unnecessary warnings
279+
# regarding different data layouts while linking. Any LLVM IR files without a
280+
# data layout will (silently) be given the first data layout the linking
281+
# process comes across.
282+
list( PREPEND bytecode_files ${bytecode_ir_files} )
283+
269284
set( builtins_comp_lib_tgt builtins.comp.${ARG_ARCH_SUFFIX} )
270285
add_custom_target( ${builtins_comp_lib_tgt}
271286
DEPENDS ${bytecode_files}

libclc/r600/lib/image/get_image_attributes_impl.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
2-
31
%opencl.image2d_t = type opaque
42
%opencl.image3d_t = type opaque
53

libclc/r600/lib/image/read_image_impl.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
2-
31
%opencl.image2d_t = type opaque
42

53
declare <4 x float> @llvm.R600.tex(<4 x float>, i32, i32, i32, i32, i32, i32,

libclc/r600/lib/image/write_image_impl.ll

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-v2048:2048-n32:64"
2-
31
%opencl.image2d_t = type opaque
42
%opencl.image3d_t = type opaque
53

llvm/docs/GitHub.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -438,7 +438,7 @@ Releases
438438
Backporting Fixes to the Release Branches
439439
-----------------------------------------
440440
You can use special comments on issues or pull requests to make backport
441-
requests for the release branches. To do this, after your pull reuest has been
441+
requests for the release branches. To do this, after your pull request has been
442442
merged:
443443

444444
1. Edit "Milestone" at the right side of the isssue or pull request

llvm/lib/CodeGen/RegAllocEvictionAdvisor.h renamed to llvm/include/llvm/CodeGen/RegAllocEvictionAdvisor.h

Lines changed: 89 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,18 @@
99
#ifndef LLVM_CODEGEN_REGALLOCEVICTIONADVISOR_H
1010
#define LLVM_CODEGEN_REGALLOCEVICTIONADVISOR_H
1111

12+
#include "llvm/ADT/Any.h"
1213
#include "llvm/ADT/ArrayRef.h"
1314
#include "llvm/ADT/SmallSet.h"
1415
#include "llvm/ADT/StringRef.h"
16+
#include "llvm/CodeGen/MachineBlockFrequencyInfo.h"
17+
#include "llvm/CodeGen/MachineLoopInfo.h"
1518
#include "llvm/CodeGen/Register.h"
1619
#include "llvm/Config/llvm-config.h"
20+
#include "llvm/IR/PassManager.h"
1721
#include "llvm/MC/MCRegister.h"
1822
#include "llvm/Pass.h"
23+
#include "llvm/Support/Compiler.h"
1924

2025
namespace llvm {
2126
class AllocationOrder;
@@ -149,6 +154,35 @@ class RegAllocEvictionAdvisor {
149154
const bool EnableLocalReassign;
150155
};
151156

157+
/// Common provider for legacy and new pass managers.
158+
/// This keeps the state for logging, and sets up and holds the provider.
159+
/// The legacy pass itself used to keep the logging state and provider,
160+
/// so this extraction helps the NPM analysis to reuse the logic.
161+
/// TODO: Coalesce this with the NPM analysis when legacy PM is removed.
162+
class RegAllocEvictionAdvisorProvider {
163+
public:
164+
enum class AdvisorMode : int { Default, Release, Development };
165+
RegAllocEvictionAdvisorProvider(AdvisorMode Mode, LLVMContext &Ctx)
166+
: Ctx(Ctx), Mode(Mode) {}
167+
168+
virtual ~RegAllocEvictionAdvisorProvider() = default;
169+
170+
virtual void logRewardIfNeeded(const MachineFunction &MF,
171+
llvm::function_ref<float()> GetReward) {}
172+
173+
virtual std::unique_ptr<RegAllocEvictionAdvisor>
174+
getAdvisor(const MachineFunction &MF, const RAGreedy &RA,
175+
MachineBlockFrequencyInfo *MBFI, MachineLoopInfo *Loops) = 0;
176+
177+
AdvisorMode getAdvisorMode() const { return Mode; }
178+
179+
protected:
180+
LLVMContext &Ctx;
181+
182+
private:
183+
const AdvisorMode Mode;
184+
};
185+
152186
/// ImmutableAnalysis abstraction for fetching the Eviction Advisor. We model it
153187
/// as an analysis to decouple the user from the implementation insofar as
154188
/// dependencies on other analyses goes. The motivation for it being an
@@ -164,40 +198,86 @@ class RegAllocEvictionAdvisor {
164198
///
165199
/// Because we need to offer additional services in 'development' mode, the
166200
/// implementations of this analysis need to implement RTTI support.
167-
class RegAllocEvictionAdvisorAnalysis : public ImmutablePass {
201+
class RegAllocEvictionAdvisorAnalysisLegacy : public ImmutablePass {
168202
public:
169203
enum class AdvisorMode : int { Default, Release, Development };
170204

171-
RegAllocEvictionAdvisorAnalysis(AdvisorMode Mode)
172-
: ImmutablePass(ID), Mode(Mode){};
205+
RegAllocEvictionAdvisorAnalysisLegacy(AdvisorMode Mode)
206+
: ImmutablePass(ID), Mode(Mode) {};
173207
static char ID;
174208

175209
/// Get an advisor for the given context (i.e. machine function, etc)
176-
virtual std::unique_ptr<RegAllocEvictionAdvisor>
177-
getAdvisor(const MachineFunction &MF, const RAGreedy &RA) = 0;
210+
RegAllocEvictionAdvisorProvider &getProvider() { return *Provider; }
211+
178212
AdvisorMode getAdvisorMode() const { return Mode; }
179213
virtual void logRewardIfNeeded(const MachineFunction &MF,
180-
llvm::function_ref<float()> GetReward){};
214+
function_ref<float()> GetReward) {};
181215

182216
protected:
183217
// This analysis preserves everything, and subclasses may have additional
184218
// requirements.
185219
void getAnalysisUsage(AnalysisUsage &AU) const override {
186220
AU.setPreservesAll();
187221
}
222+
std::unique_ptr<RegAllocEvictionAdvisorProvider> Provider;
188223

189224
private:
190225
StringRef getPassName() const override;
191226
const AdvisorMode Mode;
192227
};
193228

229+
/// A MachineFunction analysis for fetching the Eviction Advisor.
230+
/// This sets up the Provider lazily and caches it.
231+
/// - in the ML implementation case, the evaluator is stateless but (especially
232+
/// in the development mode) expensive to set up. With a Module Analysis, we
233+
/// `require` it and set it up once.
234+
/// - in the 'development' mode ML case, we want to capture the training log
235+
/// during allocation (this is a log of features encountered and decisions
236+
/// made), and then measure a score, potentially a few steps after allocation
237+
/// completes. So we need a Module analysis to keep the logger state around
238+
/// until we can make that measurement.
239+
class RegAllocEvictionAdvisorAnalysis
240+
: public AnalysisInfoMixin<RegAllocEvictionAdvisorAnalysis> {
241+
static AnalysisKey Key;
242+
friend AnalysisInfoMixin<RegAllocEvictionAdvisorAnalysis>;
243+
244+
public:
245+
struct Result {
246+
// owned by this analysis
247+
RegAllocEvictionAdvisorProvider *Provider;
248+
249+
bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
250+
MachineFunctionAnalysisManager::Invalidator &Inv) {
251+
// Provider is stateless and constructed only once. Do not get
252+
// invalidated.
253+
return false;
254+
}
255+
};
256+
257+
Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MAM);
258+
259+
private:
260+
void
261+
initializeProvider(RegAllocEvictionAdvisorAnalysisLegacy::AdvisorMode Mode,
262+
LLVMContext &Ctx);
263+
264+
std::unique_ptr<RegAllocEvictionAdvisorProvider> Provider;
265+
};
266+
194267
/// Specialization for the API used by the analysis infrastructure to create
195268
/// an instance of the eviction advisor.
196-
template <> Pass *callDefaultCtor<RegAllocEvictionAdvisorAnalysis>();
269+
template <> Pass *callDefaultCtor<RegAllocEvictionAdvisorAnalysisLegacy>();
270+
271+
RegAllocEvictionAdvisorAnalysisLegacy *createReleaseModeAdvisorAnalysisLegacy();
272+
273+
RegAllocEvictionAdvisorAnalysisLegacy *
274+
createDevelopmentModeAdvisorAnalysisLegacy();
197275

198-
RegAllocEvictionAdvisorAnalysis *createReleaseModeAdvisor();
276+
LLVM_ATTRIBUTE_RETURNS_NONNULL RegAllocEvictionAdvisorProvider *
277+
createReleaseModeAdvisorProvider(LLVMContext &Ctx);
199278

200-
RegAllocEvictionAdvisorAnalysis *createDevelopmentModeAdvisor();
279+
RegAllocEvictionAdvisorProvider *
280+
createDevelopmentModeAdvisorProvider(LLVMContext &Ctx);
201281

202282
// TODO: move to RegAllocEvictionAdvisor.cpp when we move implementation
203283
// out of RegAllocGreedy.cpp

llvm/include/llvm/InitializePasses.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -251,7 +251,7 @@ void initializePseudoProbeInserterPass(PassRegistry &);
251251
void initializeRAGreedyPass(PassRegistry &);
252252
void initializeReachingDefAnalysisPass(PassRegistry &);
253253
void initializeReassociateLegacyPassPass(PassRegistry &);
254-
void initializeRegAllocEvictionAdvisorAnalysisPass(PassRegistry &);
254+
void initializeRegAllocEvictionAdvisorAnalysisLegacyPass(PassRegistry &);
255255
void initializeRegAllocFastPass(PassRegistry &);
256256
void initializeRegAllocPriorityAdvisorAnalysisPass(PassRegistry &);
257257
void initializeRegAllocScoringPass(PassRegistry &);

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@
5757
#include "llvm/CodeGen/PeepholeOptimizer.h"
5858
#include "llvm/CodeGen/PostRASchedulerList.h"
5959
#include "llvm/CodeGen/PreISelIntrinsicLowering.h"
60+
#include "llvm/CodeGen/RegAllocEvictionAdvisor.h"
6061
#include "llvm/CodeGen/RegAllocFast.h"
6162
#include "llvm/CodeGen/RegUsageInfoCollector.h"
6263
#include "llvm/CodeGen/RegUsageInfoPropagate.h"

llvm/include/llvm/Passes/MachinePassRegistry.def

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ MACHINE_FUNCTION_ANALYSIS("machine-post-dom-tree",
114114
MachinePostDominatorTreeAnalysis())
115115
MACHINE_FUNCTION_ANALYSIS("machine-trace-metrics", MachineTraceMetricsAnalysis())
116116
MACHINE_FUNCTION_ANALYSIS("pass-instrumentation", PassInstrumentationAnalysis(PIC))
117+
MACHINE_FUNCTION_ANALYSIS("regalloc-evict", RegAllocEvictionAdvisorAnalysis())
117118
MACHINE_FUNCTION_ANALYSIS("slot-indexes", SlotIndexesAnalysis())
118119
MACHINE_FUNCTION_ANALYSIS("spill-code-placement", SpillPlacementAnalysis())
119120
MACHINE_FUNCTION_ANALYSIS("virtregmap", VirtRegMapAnalysis())

0 commit comments

Comments
 (0)