[llvm] [InferAddressSpaces] Register pass. (PR #65639)

Harald van Dijk via llvm-commits llvm-commits at lists.llvm.org
Thu Sep 7 09:54:11 PDT 2023


https://github.com/hvdijk created https://github.com/llvm/llvm-project/pull/65639:

InferAddressSpaces failed to call its initialization function. It was still called through initializeScalarOpts in llc and opt, but it was skipped entirely in clang. When the initialization function is not called, this results in confusing behavior where the pass appears to run, but not entirely as it should, e.g. the pass is excluded from -print-before-all and -print-after-all.

>From 711be0a4859a2201b888c355dfd9107886d4f050 Mon Sep 17 00:00:00 2001
From: Harald van Dijk <harald at gigawatt.nl>
Date: Thu, 7 Sep 2023 17:52:30 +0100
Subject: [PATCH] [InferAddressSpaces] Register pass.

InferAddressSpaces failed to call its initialization function. It was
still called through initializeScalarOpts in llc and opt, but it was
skipped entirely in clang. When the initialization function is not
called, this results in confusing behavior where the pass appears to
run, but not entirely as it should, e.g. the pass is excluded from
-print-before-all and -print-after-all.
---
 llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
index 8fc929ccbb3bd0b..2da521375c00161 100644
--- a/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
+++ b/llvm/lib/Transforms/Scalar/InferAddressSpaces.cpp
@@ -165,8 +165,12 @@ class InferAddressSpaces : public FunctionPass {
   static char ID;
 
   InferAddressSpaces()
-      : FunctionPass(ID), FlatAddrSpace(UninitializedAddressSpace) {}
-  InferAddressSpaces(unsigned AS) : FunctionPass(ID), FlatAddrSpace(AS) {}
+      : FunctionPass(ID), FlatAddrSpace(UninitializedAddressSpace) {
+    initializeInferAddressSpacesPass(*PassRegistry::getPassRegistry());
+  }
+  InferAddressSpaces(unsigned AS) : FunctionPass(ID), FlatAddrSpace(AS) {
+    initializeInferAddressSpacesPass(*PassRegistry::getPassRegistry());
+  }
 
   void getAnalysisUsage(AnalysisUsage &AU) const override {
     AU.setPreservesCFG();



More information about the llvm-commits mailing list