|
58 | 58 | #include "llvm/Support/Signals.h"
|
59 | 59 | #include "llvm/Support/ToolOutputFile.h"
|
60 | 60 | #include "llvm/Support/raw_ostream.h"
|
| 61 | +#include "llvm/Transforms/Utils/ValueMapper.h" |
| 62 | +#include "llvm/Transforms/Utils/Cloning.h" |
61 | 63 |
|
62 | 64 | #include <iostream>
|
63 | 65 | #include <memory>
|
@@ -564,9 +566,12 @@ bool createAliasFromMap(
|
564 | 566 |
|
565 | 567 | Function *Aliasee = M->getFunction(AliaseeName);
|
566 | 568 | if (Aliasee) {
|
567 |
| - GlobalAlias::create(AliasName, Aliasee); |
| 569 | + // TODO - rename 'alias*' to 'clone*' |
| 570 | + ValueToValueMapTy Dummy; |
| 571 | + Function *NewF = CloneFunction(Aliasee, Dummy); |
| 572 | + NewF->setName(std::string(AliasName)); |
568 | 573 | } else if (Verbose) {
|
569 |
| - std::cout << "Could not create alias " << AliasName.data() << " : missing " |
| 574 | + std::cout << "Could not create copy " << AliasName.data() << " : missing " |
570 | 575 | << AliaseeName.data() << std::endl;
|
571 | 576 | }
|
572 | 577 |
|
@@ -661,10 +666,14 @@ int main(int argc, const char **argv) {
|
661 | 666 | return 1;
|
662 | 667 | }
|
663 | 668 |
|
664 |
| - bool Success = true; |
| 669 | + std::vector<Function *> FuncList; |
665 | 670 | for (auto &Func : M->getFunctionList())
|
666 |
| - Success = remangleFunction(Func, M.get(), Replacements) && Success; |
| 671 | + FuncList.push_back(&Func); |
667 | 672 |
|
| 673 | + bool Success = true; |
| 674 | + for (auto Func : FuncList){ |
| 675 | + Success = remangleFunction(*Func, M.get(), Replacements) && Success; |
| 676 | + } |
668 | 677 | // Only fail after all to give as much context as possible.
|
669 | 678 | if (!Success) {
|
670 | 679 | errs() << "Failed to remangle all mangled functions in module.\n";
|
|
0 commit comments