Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(520)

Unified Diff: lib/Transforms/NaCl/ReplacePtrsWithInts.cpp

Issue 809483003: Update ReplacePtrsWithInts to also fix up refs from subprogram debug metadata. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
diff --git a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
index 19f0789fb3c61693e147abb2d71ea6eff1211883..ed6cf876c89287a993fe3ab573353ab40294d9b6 100644
--- a/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
+++ b/lib/Transforms/NaCl/ReplacePtrsWithInts.cpp
@@ -46,6 +46,7 @@
#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallPtrSet.h"
#include "llvm/IR/DataLayout.h"
+#include "llvm/IR/DebugInfo.h"
#include "llvm/IR/DerivedTypes.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/Instructions.h"
@@ -567,6 +568,7 @@ INITIALIZE_PASS(ReplacePtrsWithInts, "replace-ptrs-with-ints",
bool ReplacePtrsWithInts::runOnModule(Module &M) {
DataLayout DL(&M);
+ DenseMap<const Function *, DISubprogram> FunctionDIs = makeSubprogramMap(M);
Type *IntPtrType = DL.getIntPtrType(M.getContext());
for (Module::iterator Iter = M.begin(), E = M.end(); Iter != E; ) {
@@ -624,6 +626,12 @@ bool ReplacePtrsWithInts::runOnModule(Module &M) {
}
}
FC.eraseReplacedInstructions();
+
+ // Patch the pointer to LLVM function in debug info descriptor.
+ auto DI = FunctionDIs.find(OldFunc);
+ if (DI != FunctionDIs.end())
+ DI->second.replaceFunction(NewFunc);
+
OldFunc->eraseFromParent();
}
// Now that all functions have their normalized types, we can remove
« no previous file with comments | « no previous file | test/Transforms/NaCl/replace-ptrs-with-ints.ll » ('j') | test/Transforms/NaCl/replace-ptrs-with-ints.ll » ('J')

Powered by Google App Engine
This is Rietveld 408576698