From 0c80a0bc0f9d407ca6378374d8fbf9bfb80e577c Mon Sep 17 00:00:00 2001 From: NeverSightAI Date: Fri, 24 Jul 2026 22:19:38 +0800 Subject: [PATCH] Fix opt crash in addVectorPasses when TargetMachine is null Null-check TM before querying the target triple so default pipelines no longer AV when opt runs without a target (e.g. empty IR). Closes #174 --- llvm/lib/Passes/PassBuilderPipelines.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp b/llvm/lib/Passes/PassBuilderPipelines.cpp index dc1711db963c..3f98f92284ef 100644 --- a/llvm/lib/Passes/PassBuilderPipelines.cpp +++ b/llvm/lib/Passes/PassBuilderPipelines.cpp @@ -1162,7 +1162,8 @@ PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level, void PassBuilder::addVectorPasses(OptimizationLevel Level, FunctionPassManager &FPM, bool IsFullLTO) { // Disable vector passes on windows. - if (TM->getTargetTriple().isOSWindows()) + // TM may be null when opt is run without a target triple (e.g. empty IR). + if (TM && TM->getTargetTriple().isOSWindows()) return; FPM.addPass(LoopVectorizePass(