[PATCH] D155375: [wip/help] Access TargetMachine without crashing
Jon Chesterfield via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Jul 15 10:31:43 PDT 2023
JonChesterfield updated this revision to Diff 540704.
JonChesterfield added a comment.
- comment
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155375/new/
https://reviews.llvm.org/D155375
Files:
llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
Index: llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPULowerModuleLDSPass.cpp
@@ -186,6 +186,7 @@
#include "llvm/ADT/SetOperations.h"
#include "llvm/ADT/SetVector.h"
#include "llvm/Analysis/CallGraph.h"
+#include "llvm/CodeGen/TargetPassConfig.h"
#include "llvm/IR/Constants.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/IRBuilder.h"
@@ -199,6 +200,7 @@
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Support/OptimizedStructLayout.h"
+#include "llvm/Target/TargetMachine.h"
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
#include "llvm/Transforms/Utils/ModuleUtils.h"
@@ -333,7 +335,20 @@
public:
static char ID;
- AMDGPULowerModuleLDS() : ModulePass(ID) {
+ AMDGPULowerModuleLDS()
+ : ModulePass(ID)
+
+ {
+ // Asserts
+ // assert(PI && "getAnalysis for unregistered pass!");
+ // Can change to getAnalysisIfAvailable, which asserts
+ // assert(Resolver && "Pass not resident in a PassManager object!");
+ // Thus... how do I get at the TargetMachine from a ModulePass?
+
+ TargetPassConfig &TPC = getAnalysis<TargetPassConfig>();
+ const TargetMachine &TM = TPC.getTM<TargetMachine>();
+ (void)TM;
+
initializeAMDGPULowerModuleLDSPass(*PassRegistry::getPassRegistry());
}
@@ -1268,6 +1283,10 @@
return Changed;
}
+ void getAnalysisUsage(AnalysisUsage &AU) const override {
+ AU.addRequired<TargetPassConfig>();
+ }
+
private:
// Increase the alignment of LDS globals if necessary to maximise the chance
// that we can use aligned LDS instructions to access them.
@@ -1533,9 +1552,13 @@
char &llvm::AMDGPULowerModuleLDSID = AMDGPULowerModuleLDS::ID;
-INITIALIZE_PASS(AMDGPULowerModuleLDS, DEBUG_TYPE,
- "Lower uses of LDS variables from non-kernel functions", false,
- false)
+INITIALIZE_PASS_BEGIN(AMDGPULowerModuleLDS, DEBUG_TYPE,
+ "Lower uses of LDS variables from non-kernel functions",
+ false, false)
+INITIALIZE_PASS_DEPENDENCY(TargetPassConfig)
+INITIALIZE_PASS_END(AMDGPULowerModuleLDS, DEBUG_TYPE,
+ "Lower uses of LDS variables from non-kernel functions",
+ false, false)
ModulePass *llvm::createAMDGPULowerModuleLDSPass() {
return new AMDGPULowerModuleLDS();
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D155375.540704.patch
Type: text/x-patch
Size: 2489 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230715/c96c26ac/attachment.bin>
More information about the llvm-commits
mailing list