Index: include/llvm/CodeGen/StackProtector.h =================================================================== --- include/llvm/CodeGen/StackProtector.h +++ include/llvm/CodeGen/StackProtector.h @@ -102,7 +102,7 @@ bool RequiresStackProtector(); public: - static char ID; // Pass identification, replacement for typeid. + static char &ID; // Pass identification, replacement for typeid. StackProtector() : FunctionPass(ID), SSPBufferSize(8) { initializeStackProtectorPass(*PassRegistry::getPassRegistry()); Index: include/llvm/IR/Passes.h =================================================================== --- /dev/null +++ include/llvm/IR/Passes.h @@ -0,0 +1,24 @@ +//===- llvm/Passes.h - Cross-module pass IDs --------------------*- C++ -*-===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// +// +// This file defines pass IDs of passes that are defined in one module but +// referenced via addPreserved in another. Defining such pass IDs in the core +// module allows us to avoid unnecessary or even cyclic linker dependencies. +// +//===----------------------------------------------------------------------===// + +#ifndef LLVM_PASSES_H +#define LLVM_PASSES_H + +namespace llvm { + +extern char &StackProtectorID; + +} // namespace llvm + +#endif // LLVM_PASSES_H Index: lib/CodeGen/StackProtector.cpp =================================================================== --- lib/CodeGen/StackProtector.cpp +++ lib/CodeGen/StackProtector.cpp @@ -39,6 +39,7 @@ #include "llvm/IR/Intrinsics.h" #include "llvm/IR/MDBuilder.h" #include "llvm/IR/Module.h" +#include "llvm/IR/Passes.h" #include "llvm/IR/Type.h" #include "llvm/IR/User.h" #include "llvm/Pass.h" @@ -59,7 +60,7 @@ static cl::opt EnableSelectionDAGSP("enable-selectiondag-sp", cl::init(true), cl::Hidden); -char StackProtector::ID = 0; +char &StackProtector::ID = StackProtectorID; INITIALIZE_PASS_BEGIN(StackProtector, DEBUG_TYPE, "Insert stack protectors", false, true) Index: lib/IR/CMakeLists.txt =================================================================== --- lib/IR/CMakeLists.txt +++ lib/IR/CMakeLists.txt @@ -42,6 +42,7 @@ Operator.cpp OptBisect.cpp Pass.cpp + Passes.cpp PassInstrumentation.cpp PassManager.cpp PassRegistry.cpp Index: lib/IR/Passes.cpp =================================================================== --- /dev/null +++ lib/IR/Passes.cpp @@ -0,0 +1,14 @@ +//===- Passes.cpp - Cross-module pass IDs ---------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#include "llvm/IR/Passes.h" + +using namespace llvm; + +static char theStackProtectorID = 0; +char &llvm::StackProtectorID = theStackProtectorID; Index: lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp =================================================================== --- lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp +++ lib/Target/AMDGPU/AMDGPUISelDAGToDAG.cpp @@ -46,6 +46,7 @@ #include "llvm/Support/ErrorHandling.h" #include "llvm/Support/MachineValueType.h" #include "llvm/Support/MathExtras.h" +#include "llvm/Transforms/Utils.h" #include #include #include @@ -86,6 +87,10 @@ void getAnalysisUsage(AnalysisUsage &AU) const override { AU.addRequired(); AU.addRequired(); + // LCSSA generates a phi node in an exit block so that use divergence + // info can be passed to isel in the cases where the value is uniform + // inside the loop but is non-uniform for uses outside the loop. + AU.addRequiredID(LCSSAID); AU.addRequired(); SelectionDAGISel::getAnalysisUsage(AU); } @@ -292,6 +297,7 @@ "AMDGPU DAG->DAG Pattern Instruction Selection", false, false) INITIALIZE_PASS_DEPENDENCY(AMDGPUArgumentUsageInfo) INITIALIZE_PASS_DEPENDENCY(AMDGPUPerfHintAnalysis) +INITIALIZE_PASS_DEPENDENCY(LCSSAWrapperPass) INITIALIZE_PASS_DEPENDENCY(LegacyDivergenceAnalysis) INITIALIZE_PASS_END(AMDGPUDAGToDAGISel, "amdgpu-isel", "AMDGPU DAG->DAG Pattern Instruction Selection", false, false) Index: lib/Transforms/Utils/LCSSA.cpp =================================================================== --- lib/Transforms/Utils/LCSSA.cpp +++ lib/Transforms/Utils/LCSSA.cpp @@ -42,12 +42,14 @@ #include "llvm/IR/Function.h" #include "llvm/IR/Instructions.h" #include "llvm/IR/IntrinsicInst.h" +#include "llvm/IR/Passes.h" #include "llvm/IR/PredIteratorCache.h" #include "llvm/Pass.h" #include "llvm/Transforms/Utils.h" #include "llvm/Transforms/Utils/Local.h" #include "llvm/Transforms/Utils/LoopUtils.h" #include "llvm/Transforms/Utils/SSAUpdater.h" +#include "llvm/CodeGen/Passes.h" using namespace llvm; #define DEBUG_TYPE "lcssa" @@ -446,6 +448,7 @@ AU.addPreserved(); AU.addPreserved(); AU.addPreserved(); + AU.addPreservedID(StackProtectorID); // This is needed to perform LCSSA verification inside LPPassManager AU.addRequired();