[PATCH] D113653: [NVPTX][AsmPrinter] Avoid removing globals before calling AsmPrinter::doFinalization()
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sat Nov 27 04:04:23 PST 2021
This revision was automatically updated to reflect the committed changes.
Closed by commit rG9f374a74c2aa: [NVPTX][AsmPrinter] Avoid removing globals before calling AsmPrinter… (authored by krisb).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D113653/new/
https://reviews.llvm.org/D113653
Files:
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
llvm/lib/Target/NVPTX/NVPTXAsmPrinter.h
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.h
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.h
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.h
@@ -306,6 +306,11 @@
std::string getVirtualRegisterName(unsigned) const;
const MCSymbol *getFunctionFrameSymbol() const override;
+
+ // Make emitGlobalVariable() no-op for NVPTX.
+ // Global variables have been already emitted by the time the base AsmPrinter
+ // attempts to do so in doFinalization() (see NVPTXAsmPrinter::emitGlobals()).
+ void emitGlobalVariable(const GlobalVariable *GV) override {}
};
} // end namespace llvm
Index: llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
===================================================================
--- llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
+++ llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp
@@ -887,33 +887,11 @@
GlobalsEmitted = true;
}
- // XXX Temproarily remove global variables so that doFinalization() will not
- // emit them again (global variables are emitted at beginning).
-
- Module::GlobalListType &global_list = M.getGlobalList();
- int i, n = global_list.size();
- GlobalVariable **gv_array = new GlobalVariable *[n];
-
- // first, back-up GlobalVariable in gv_array
- i = 0;
- for (Module::global_iterator I = global_list.begin(), E = global_list.end();
- I != E; ++I)
- gv_array[i++] = &*I;
-
- // second, empty global_list
- while (!global_list.empty())
- global_list.remove(global_list.begin());
-
// call doFinalization
bool ret = AsmPrinter::doFinalization(M);
- // now we restore global variables
- for (i = 0; i < n; i++)
- global_list.insert(global_list.end(), gv_array[i]);
-
clearAnnotationCache(&M);
- delete[] gv_array;
// Close the last emitted section
if (HasDebugInfo) {
static_cast<NVPTXTargetStreamer *>(OutStreamer->getTargetStreamer())
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D113653.390152.patch
Type: text/x-patch
Size: 1901 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20211127/aa364b38/attachment.bin>
More information about the llvm-commits
mailing list