Skip to content

Instantly share code, notes, and snippets.

@Albocoder
Last active June 9, 2024 01:40
Show Gist options
  • Save Albocoder/f81771e4a8ea6cce8ec79279eb07d18c to your computer and use it in GitHub Desktop.
Save Albocoder/f81771e4a8ea6cce8ec79279eb07d18c to your computer and use it in GitHub Desktop.
clang13-bitcode-dump-patch
diff --git a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
index d95fd55870f8..dcc1e53fba7b 100644
--- a/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
+++ b/llvm/lib/Transforms/IPO/DeadArgumentElimination.cpp
@@ -50,6 +50,9 @@
#include <utility>
#include <vector>
+#include "llvm/Bitcode/BitcodeWriter.h"
+#include "llvm/Support/ToolOutputFile.h"
+
using namespace llvm;
#define DEBUG_TYPE "deadargelim"
@@ -1087,6 +1090,21 @@ bool DeadArgumentEliminationPass::RemoveDeadStuffFromFunction(Function *F) {
PreservedAnalyses DeadArgumentEliminationPass::run(Module &M,
ModuleAnalysisManager &) {
+ //outs() << "DeadArg Elimination on " << M.getName() << "\n";
+ std::string FileName = M.getSourceFileName();
+ if(FileName.find(".c") != FileName.npos){
+ std::string Path = M.getSourceFileName() + ".bc";
+ outs() << "Writing to " << Path << "\n";
+ std::error_code EC;
+ // sys::fs::OpenFlags oflags;
+ raw_fd_ostream out(Path, EC, (sys::fs::OpenFlags)0 );
+ // raw_fd_ostream out(Path, EC, );
+ WriteBitcodeToFile(M, out);
+ out.flush();
+ out.close();
+ outs() << "Write Done";
+ }
+
bool Changed = false;
// First pass: Do a simple check to see if any functions can have their "..."
diff --git a/llvm/utils/benchmark/src/benchmark_register.h b/llvm/utils/benchmark/src/benchmark_register.h
index 4caa5ad4da07..eaf4a75f7fc5 100644
--- a/llvm/utils/benchmark/src/benchmark_register.h
+++ b/llvm/utils/benchmark/src/benchmark_register.h
@@ -3,7 +3,7 @@
#include <limits>
#include <vector>
-
+#include <limits>
#include "check.h"
template <typename T>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment