Skip to content

Commit b8723af

Browse files
committed
[Passes] Report error when pass requires target machine
1 parent 972ecc3 commit b8723af

21 files changed

+81
-45
lines changed

llvm/include/llvm/CodeGen/AtomicExpand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AtomicExpandPass : public PassInfoMixin<AtomicExpandPass> {
2121
const TargetMachine *TM;
2222

2323
public:
24-
AtomicExpandPass(const TargetMachine *TM) : TM(TM) {}
24+
AtomicExpandPass(const TargetMachine &TM) : TM(&TM) {}
2525
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2626
};
2727

llvm/include/llvm/CodeGen/BasicBlockSectionsProfileReader.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ class BasicBlockSectionsProfileReaderAnalysis
167167
public:
168168
static AnalysisKey Key;
169169
typedef BasicBlockSectionsProfileReader Result;
170-
BasicBlockSectionsProfileReaderAnalysis(const TargetMachine *TM) : TM(TM) {}
170+
BasicBlockSectionsProfileReaderAnalysis(const TargetMachine &TM) : TM(&TM) {}
171171

172172
Result run(Function &F, FunctionAnalysisManager &AM);
173173

llvm/include/llvm/CodeGen/CodeGenPrepare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class CodeGenPreparePass : public PassInfoMixin<CodeGenPreparePass> {
2626
const TargetMachine *TM;
2727

2828
public:
29-
CodeGenPreparePass(const TargetMachine *TM) : TM(TM) {}
29+
CodeGenPreparePass(const TargetMachine &TM) : TM(&TM) {}
3030
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
3131
};
3232

llvm/include/llvm/CodeGen/ComplexDeinterleavingPass.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,10 @@ class TargetMachine;
2424
struct ComplexDeinterleavingPass
2525
: public PassInfoMixin<ComplexDeinterleavingPass> {
2626
private:
27-
TargetMachine *TM;
27+
const TargetMachine *TM;
2828

2929
public:
30-
ComplexDeinterleavingPass(TargetMachine *TM) : TM(TM) {}
30+
ComplexDeinterleavingPass(const TargetMachine &TM) : TM(&TM) {}
3131

3232
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
3333
};

llvm/include/llvm/CodeGen/DwarfEHPrepare.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class DwarfEHPreparePass : public PassInfoMixin<DwarfEHPreparePass> {
2424
const TargetMachine *TM;
2525

2626
public:
27-
explicit DwarfEHPreparePass(const TargetMachine *TM_) : TM(TM_) {}
27+
explicit DwarfEHPreparePass(const TargetMachine &TM_) : TM(&TM_) {}
2828
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
2929
};
3030

llvm/include/llvm/CodeGen/ExpandFp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ExpandFpPass : public PassInfoMixin<ExpandFpPass> {
2020
const TargetMachine *TM;
2121

2222
public:
23-
explicit ExpandFpPass(const TargetMachine *TM_) : TM(TM_) {}
23+
explicit ExpandFpPass(const TargetMachine &TM_) : TM(&TM_) {}
2424

2525
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2626
};

llvm/include/llvm/CodeGen/ExpandLargeDivRem.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class ExpandLargeDivRemPass : public PassInfoMixin<ExpandLargeDivRemPass> {
2020
const TargetMachine *TM;
2121

2222
public:
23-
explicit ExpandLargeDivRemPass(const TargetMachine *TM_) : TM(TM_) {}
23+
explicit ExpandLargeDivRemPass(const TargetMachine &TM_) : TM(&TM_) {}
2424

2525
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
2626
};

llvm/include/llvm/CodeGen/ExpandMemCmp.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class ExpandMemCmpPass : public PassInfoMixin<ExpandMemCmpPass> {
1919
const TargetMachine *TM;
2020

2121
public:
22-
explicit ExpandMemCmpPass(const TargetMachine *TM_) : TM(TM_) {}
22+
explicit ExpandMemCmpPass(const TargetMachine &TM_) : TM(&TM_) {}
2323

2424
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
2525
};

llvm/include/llvm/CodeGen/IndirectBrExpand.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class IndirectBrExpandPass : public PassInfoMixin<IndirectBrExpandPass> {
1919
const TargetMachine *TM;
2020

2121
public:
22-
IndirectBrExpandPass(const TargetMachine *TM) : TM(TM) {}
22+
IndirectBrExpandPass(const TargetMachine &TM) : TM(&TM) {}
2323
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
2424
};
2525

llvm/include/llvm/CodeGen/InterleavedAccess.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class InterleavedAccessPass : public PassInfoMixin<InterleavedAccessPass> {
2525
const TargetMachine *TM;
2626

2727
public:
28-
explicit InterleavedAccessPass(const TargetMachine *TM) : TM(TM) {}
28+
explicit InterleavedAccessPass(const TargetMachine &TM) : TM(&TM) {}
2929
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
3030
};
3131

llvm/include/llvm/CodeGen/InterleavedLoadCombine.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ class InterleavedLoadCombinePass
2020
const TargetMachine *TM;
2121

2222
public:
23-
explicit InterleavedLoadCombinePass(const TargetMachine *TM) : TM(TM) {}
23+
explicit InterleavedLoadCombinePass(const TargetMachine &TM) : TM(&TM) {}
2424
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
2525
};
2626

llvm/include/llvm/CodeGen/MachineFunctionAnalysis.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ class MachineFunctionAnalysis
4242
FunctionAnalysisManager::Invalidator &);
4343
};
4444

45-
MachineFunctionAnalysis(const TargetMachine *TM) : TM(TM) {};
45+
MachineFunctionAnalysis(const TargetMachine &TM) : TM(&TM) {};
4646
LLVM_ABI Result run(Function &F, FunctionAnalysisManager &FAM);
4747
};
4848

llvm/include/llvm/CodeGen/SafeStack.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ class SafeStackPass : public PassInfoMixin<SafeStackPass> {
1919
const TargetMachine *TM;
2020

2121
public:
22-
explicit SafeStackPass(const TargetMachine *TM_) : TM(TM_) {}
22+
explicit SafeStackPass(const TargetMachine &TM_) : TM(&TM_) {}
2323
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
2424
};
2525

llvm/include/llvm/CodeGen/SelectOptimize.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class SelectOptimizePass : public PassInfoMixin<SelectOptimizePass> {
2525
const TargetMachine *TM;
2626

2727
public:
28-
explicit SelectOptimizePass(const TargetMachine *TM) : TM(TM) {}
28+
explicit SelectOptimizePass(const TargetMachine &TM) : TM(&TM) {}
2929
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
3030
};
3131

llvm/include/llvm/CodeGen/StackProtector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ class StackProtectorPass : public PassInfoMixin<StackProtectorPass> {
8686
const TargetMachine *TM;
8787

8888
public:
89-
explicit StackProtectorPass(const TargetMachine *TM) : TM(TM) {}
89+
explicit StackProtectorPass(const TargetMachine &TM) : TM(&TM) {}
9090
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM);
9191
};
9292

llvm/include/llvm/CodeGen/TypePromotion.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ class TypePromotionPass : public PassInfoMixin<TypePromotionPass> {
2626
const TargetMachine *TM;
2727

2828
public:
29-
TypePromotionPass(const TargetMachine *TM): TM(TM) { }
29+
TypePromotionPass(const TargetMachine &TM) : TM(&TM) {}
3030
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM);
3131
};
3232

llvm/include/llvm/Passes/CodeGenPassBuilder.h

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -672,8 +672,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPasses(
672672
addPass(LowerEmuTLSPass());
673673

674674
addPass(PreISelIntrinsicLoweringPass(&TM));
675-
addPass(ExpandLargeDivRemPass(&TM));
676-
addPass(ExpandFpPass(&TM));
675+
addPass(ExpandLargeDivRemPass(TM));
676+
addPass(ExpandFpPass(TM));
677677

678678
derived().addIRPasses(addPass);
679679
derived().addCodeGenPrepare(addPass);
@@ -704,7 +704,7 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
704704
// target lowering hook.
705705
if (!Opt.DisableMergeICmps)
706706
addPass(MergeICmpsPass());
707-
addPass(ExpandMemCmpPass(&TM));
707+
addPass(ExpandMemCmpPass(TM));
708708
}
709709

710710
// Run GC lowering passes for builtin collectors
@@ -742,7 +742,7 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addIRPasses(
742742

743743
// Convert conditional moves to conditional jumps when profitable.
744744
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableSelectOptimize)
745-
addPass(SelectOptimizePass(&TM));
745+
addPass(SelectOptimizePass(TM));
746746

747747
if (Opt.EnableGlobalMergeFunc)
748748
addPass(GlobalMergeFuncPass());
@@ -769,14 +769,14 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addPassesToHandleExceptions(
769769
case ExceptionHandling::ARM:
770770
case ExceptionHandling::AIX:
771771
case ExceptionHandling::ZOS:
772-
addPass(DwarfEHPreparePass(&TM));
772+
addPass(DwarfEHPreparePass(TM));
773773
break;
774774
case ExceptionHandling::WinEH:
775775
// We support using both GCC-style and MSVC-style exceptions on Windows, so
776776
// add both preparation passes. Each pass will only actually run if it
777777
// recognizes the personality function.
778778
addPass(WinEHPreparePass());
779-
addPass(DwarfEHPreparePass(&TM));
779+
addPass(DwarfEHPreparePass(TM));
780780
break;
781781
case ExceptionHandling::Wasm:
782782
// Wasm EH uses Windows EH instructions, but it does not need to demote PHIs
@@ -801,7 +801,7 @@ template <typename Derived, typename TargetMachineT>
801801
void CodeGenPassBuilder<Derived, TargetMachineT>::addCodeGenPrepare(
802802
AddIRPass &addPass) const {
803803
if (getOptLevel() != CodeGenOptLevel::None && !Opt.DisableCGP)
804-
addPass(CodeGenPreparePass(&TM));
804+
addPass(CodeGenPreparePass(TM));
805805
// TODO: Default ctor'd RewriteSymbolPass is no-op.
806806
// addPass(RewriteSymbolPass());
807807
}
@@ -816,8 +816,8 @@ void CodeGenPassBuilder<Derived, TargetMachineT>::addISelPrepare(
816816
addPass(CallBrPreparePass());
817817
// Add both the safe stack and the stack protection passes: each of them will
818818
// only protect functions that have corresponding attributes.
819-
addPass(SafeStackPass(&TM));
820-
addPass(StackProtectorPass(&TM));
819+
addPass(SafeStackPass(TM));
820+
addPass(StackProtectorPass(TM));
821821

822822
if (Opt.PrintISelInput)
823823
addPass(PrintFunctionPass(dbgs(),

llvm/lib/Passes/PassBuilder.cpp

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1882,6 +1882,14 @@ Error PassBuilder::parseModulePass(ModulePassManager &MPM,
18821882
}
18831883
#define FUNCTION_PASS(NAME, CREATE_PASS) \
18841884
if (Name == NAME) { \
1885+
if constexpr (std::is_constructible_v< \
1886+
std::remove_reference_t<decltype(CREATE_PASS)>, \
1887+
const TargetMachine &>) { \
1888+
if (!TM) \
1889+
return make_error<StringError>( \
1890+
formatv("Pass '{0}' requires TargetMachine", Name).str(), \
1891+
inconvertibleErrorCode()); \
1892+
} \
18851893
MPM.addPass(createModuleToFunctionPassAdaptor(CREATE_PASS)); \
18861894
return Error::success(); \
18871895
}
@@ -1997,6 +2005,14 @@ Error PassBuilder::parseCGSCCPass(CGSCCPassManager &CGPM,
19972005
}
19982006
#define FUNCTION_PASS(NAME, CREATE_PASS) \
19992007
if (Name == NAME) { \
2008+
if constexpr (std::is_constructible_v< \
2009+
std::remove_reference_t<decltype(CREATE_PASS)>, \
2010+
const TargetMachine &>) { \
2011+
if (!TM) \
2012+
return make_error<StringError>( \
2013+
formatv("Pass '{0}' requires TargetMachine", Name).str(), \
2014+
inconvertibleErrorCode()); \
2015+
} \
20002016
CGPM.addPass(createCGSCCToFunctionPassAdaptor(CREATE_PASS)); \
20012017
return Error::success(); \
20022018
}
@@ -2091,6 +2107,14 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
20912107
// Now expand the basic registered passes from the .inc file.
20922108
#define FUNCTION_PASS(NAME, CREATE_PASS) \
20932109
if (Name == NAME) { \
2110+
if constexpr (std::is_constructible_v< \
2111+
std::remove_reference_t<decltype(CREATE_PASS)>, \
2112+
const TargetMachine &>) { \
2113+
if (!TM) \
2114+
return make_error<StringError>( \
2115+
formatv("Pass '{0}' requires TargetMachine", Name).str(), \
2116+
inconvertibleErrorCode()); \
2117+
} \
20942118
FPM.addPass(CREATE_PASS); \
20952119
return Error::success(); \
20962120
}
@@ -2104,9 +2128,17 @@ Error PassBuilder::parseFunctionPass(FunctionPassManager &FPM,
21042128
}
21052129
#define FUNCTION_ANALYSIS(NAME, CREATE_PASS) \
21062130
if (Name == "require<" NAME ">") { \
2131+
if constexpr (std::is_constructible_v< \
2132+
std::remove_reference_t<decltype(CREATE_PASS)>, \
2133+
const TargetMachine &>) { \
2134+
if (!TM) \
2135+
return make_error<StringError>( \
2136+
formatv("Pass '{0}' requires TargetMachine", Name).str(), \
2137+
inconvertibleErrorCode()); \
2138+
} \
21072139
FPM.addPass( \
2108-
RequireAnalysisPass< \
2109-
std::remove_reference_t<decltype(CREATE_PASS)>, Function>()); \
2140+
RequireAnalysisPass<std::remove_reference_t<decltype(CREATE_PASS)>, \
2141+
Function>()); \
21102142
return Error::success(); \
21112143
} \
21122144
if (Name == "invalidate<" NAME ">") { \

llvm/lib/Passes/PassRegistry.def

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ CGSCC_PASS_WITH_PARAMS(
286286
FUNCTION_ANALYSIS("aa", AAManager())
287287
FUNCTION_ANALYSIS("access-info", LoopAccessAnalysis())
288288
FUNCTION_ANALYSIS("assumptions", AssumptionAnalysis())
289-
FUNCTION_ANALYSIS("bb-sections-profile-reader", BasicBlockSectionsProfileReaderAnalysis(TM))
289+
FUNCTION_ANALYSIS("bb-sections-profile-reader", BasicBlockSectionsProfileReaderAnalysis(*TM))
290290
FUNCTION_ANALYSIS("block-freq", BlockFrequencyAnalysis())
291291
FUNCTION_ANALYSIS("branch-prob", BranchProbabilityAnalysis())
292292
FUNCTION_ANALYSIS("cycles", CycleAnalysis())
@@ -297,7 +297,7 @@ FUNCTION_ANALYSIS("domfrontier", DominanceFrontierAnalysis())
297297
FUNCTION_ANALYSIS("domtree", DominatorTreeAnalysis())
298298
FUNCTION_ANALYSIS("ephemerals", EphemeralValuesAnalysis())
299299
FUNCTION_ANALYSIS("func-properties", FunctionPropertiesAnalysis())
300-
FUNCTION_ANALYSIS("machine-function-info", MachineFunctionAnalysis(TM))
300+
FUNCTION_ANALYSIS("machine-function-info", MachineFunctionAnalysis(*TM))
301301
FUNCTION_ANALYSIS("gc-function", GCFunctionAnalysis())
302302
FUNCTION_ANALYSIS("inliner-size-estimator", InlineSizeEstimatorAnalysis())
303303
FUNCTION_ANALYSIS("last-run-tracking", LastRunTrackingAnalysis())
@@ -347,14 +347,14 @@ FUNCTION_PASS("alignment-from-assumptions", AlignmentFromAssumptionsPass())
347347
FUNCTION_PASS("annotation-remarks", AnnotationRemarksPass())
348348
FUNCTION_PASS("assume-builder", AssumeBuilderPass())
349349
FUNCTION_PASS("assume-simplify", AssumeSimplifyPass())
350-
FUNCTION_PASS("atomic-expand", AtomicExpandPass(TM))
350+
FUNCTION_PASS("atomic-expand", AtomicExpandPass(*TM))
351351
FUNCTION_PASS("bdce", BDCEPass())
352352
FUNCTION_PASS("break-crit-edges", BreakCriticalEdgesPass())
353353
FUNCTION_PASS("callbr-prepare", CallBrPreparePass())
354354
FUNCTION_PASS("callsite-splitting", CallSiteSplittingPass())
355355
FUNCTION_PASS("chr", ControlHeightReductionPass())
356-
FUNCTION_PASS("codegenprepare", CodeGenPreparePass(TM))
357-
FUNCTION_PASS("complex-deinterleaving", ComplexDeinterleavingPass(TM))
356+
FUNCTION_PASS("codegenprepare", CodeGenPreparePass(*TM))
357+
FUNCTION_PASS("complex-deinterleaving", ComplexDeinterleavingPass(*TM))
358358
FUNCTION_PASS("consthoist", ConstantHoistingPass())
359359
FUNCTION_PASS("constraint-elimination", ConstraintEliminationPass())
360360
FUNCTION_PASS("coro-elide", CoroElidePass())
@@ -371,10 +371,10 @@ FUNCTION_PASS("dot-dom-only", DomOnlyPrinter())
371371
FUNCTION_PASS("dot-post-dom", PostDomPrinter())
372372
FUNCTION_PASS("dot-post-dom-only", PostDomOnlyPrinter())
373373
FUNCTION_PASS("dse", DSEPass())
374-
FUNCTION_PASS("dwarf-eh-prepare", DwarfEHPreparePass(TM))
375-
FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(TM))
376-
FUNCTION_PASS("expand-fp", ExpandFpPass(TM))
377-
FUNCTION_PASS("expand-memcmp", ExpandMemCmpPass(TM))
374+
FUNCTION_PASS("dwarf-eh-prepare", DwarfEHPreparePass(*TM))
375+
FUNCTION_PASS("expand-large-div-rem", ExpandLargeDivRemPass(*TM))
376+
FUNCTION_PASS("expand-fp", ExpandFpPass(*TM))
377+
FUNCTION_PASS("expand-memcmp", ExpandMemCmpPass(*TM))
378378
FUNCTION_PASS("extra-vector-passes",
379379
ExtraFunctionPassManager<ShouldRunExtraVectorPasses>())
380380
FUNCTION_PASS("fix-irreducible", FixIrreduciblePass())
@@ -385,15 +385,15 @@ FUNCTION_PASS("guard-widening", GuardWideningPass())
385385
FUNCTION_PASS("gvn-hoist", GVNHoistPass())
386386
FUNCTION_PASS("gvn-sink", GVNSinkPass())
387387
FUNCTION_PASS("helloworld", HelloWorldPass())
388-
FUNCTION_PASS("indirectbr-expand", IndirectBrExpandPass(TM))
388+
FUNCTION_PASS("indirectbr-expand", IndirectBrExpandPass(*TM))
389389
FUNCTION_PASS("infer-address-spaces", InferAddressSpacesPass())
390390
FUNCTION_PASS("infer-alignment", InferAlignmentPass())
391391
FUNCTION_PASS("inject-tli-mappings", InjectTLIMappings())
392392
FUNCTION_PASS("instcount", InstCountPass())
393393
FUNCTION_PASS("instnamer", InstructionNamerPass())
394394
FUNCTION_PASS("instsimplify", InstSimplifyPass())
395-
FUNCTION_PASS("interleaved-access", InterleavedAccessPass(TM))
396-
FUNCTION_PASS("interleaved-load-combine", InterleavedLoadCombinePass(TM))
395+
FUNCTION_PASS("interleaved-access", InterleavedAccessPass(*TM))
396+
FUNCTION_PASS("interleaved-load-combine", InterleavedLoadCombinePass(*TM))
397397
FUNCTION_PASS("invalidate<all>", InvalidateAllAnalysesPass())
398398
FUNCTION_PASS("irce", IRCEPass())
399399
FUNCTION_PASS("jump-threading", JumpThreadingPass())
@@ -469,25 +469,25 @@ FUNCTION_PASS("print<uniformity>", UniformityInfoPrinterPass(errs()))
469469
FUNCTION_PASS("reassociate", ReassociatePass())
470470
FUNCTION_PASS("redundant-dbg-inst-elim", RedundantDbgInstEliminationPass())
471471
FUNCTION_PASS("reg2mem", RegToMemPass())
472-
FUNCTION_PASS("safe-stack", SafeStackPass(TM))
472+
FUNCTION_PASS("safe-stack", SafeStackPass(*TM))
473473
FUNCTION_PASS("sandbox-vectorizer", SandboxVectorizerPass())
474474
FUNCTION_PASS("scalarize-masked-mem-intrin", ScalarizeMaskedMemIntrinPass())
475475
FUNCTION_PASS("sccp", SCCPPass())
476-
FUNCTION_PASS("select-optimize", SelectOptimizePass(TM))
476+
FUNCTION_PASS("select-optimize", SelectOptimizePass(*TM))
477477
FUNCTION_PASS("separate-const-offset-from-gep",
478478
SeparateConstOffsetFromGEPPass())
479479
FUNCTION_PASS("sink", SinkingPass())
480480
FUNCTION_PASS("sjlj-eh-prepare", SjLjEHPreparePass(TM))
481481
FUNCTION_PASS("slp-vectorizer", SLPVectorizerPass())
482482
FUNCTION_PASS("slsr", StraightLineStrengthReducePass())
483-
FUNCTION_PASS("stack-protector", StackProtectorPass(TM))
483+
FUNCTION_PASS("stack-protector", StackProtectorPass(*TM))
484484
FUNCTION_PASS("strip-gc-relocates", StripGCRelocates())
485485
FUNCTION_PASS("tailcallelim", TailCallElimPass())
486486
FUNCTION_PASS("transform-warning", WarnMissedTransformationsPass())
487487
FUNCTION_PASS("trigger-crash-function", TriggerCrashFunctionPass())
488488
FUNCTION_PASS("trigger-verifier-error", TriggerVerifierErrorPass())
489489
FUNCTION_PASS("tsan", ThreadSanitizerPass())
490-
FUNCTION_PASS("typepromotion", TypePromotionPass(TM))
490+
FUNCTION_PASS("typepromotion", TypePromotionPass(*TM))
491491
FUNCTION_PASS("unify-loop-exits", UnifyLoopExitsPass())
492492
FUNCTION_PASS("vector-combine", VectorCombinePass())
493493
FUNCTION_PASS("verify", VerifierPass())

llvm/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2038,7 +2038,7 @@ void AMDGPUCodeGenPassBuilder::addIRPasses(AddIRPass &addPass) const {
20382038
(AMDGPUAtomicOptimizerStrategy != ScanOptions::None))
20392039
addPass(AMDGPUAtomicOptimizerPass(TM, AMDGPUAtomicOptimizerStrategy));
20402040

2041-
addPass(AtomicExpandPass(&TM));
2041+
addPass(AtomicExpandPass(TM));
20422042

20432043
if (TM.getOptLevel() > CodeGenOptLevel::None) {
20442044
addPass(AMDGPUPromoteAllocaPass(TM));
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
; Report error when pass requires TargetMachine.
2+
; RUN: not opt -passes=codegenprepare -disable-output %s 2>&1 | FileCheck %s
3+
define void @foo() { ret void }
4+
; CHECK: Pass 'codegenpreparee' requires TargetMachine

0 commit comments

Comments
 (0)