@@ -70,7 +70,8 @@ static llvm::cl::OptionCategory
70
70
static cl::opt<std::string>
71
71
InputIRFilename (" input-ir" , cl::desc(" <input bitcode>" ),
72
72
cl::cat(LibCLCRemanglerToolCategory));
73
- static cl::opt<std::string> OutputFilename (" o" , cl::desc(" Output filename" ));
73
+ static cl::opt<std::string> OutputFilename (" o" , cl::init(" -" ),
74
+ cl::desc(" Output filename" ));
74
75
static cl::opt<SupportedLongWidth>
75
76
LongWidth (" long-width" ,
76
77
cl::values (clEnumValN(SupportedLongWidth::L32, " l32" ,
@@ -87,6 +88,9 @@ static cl::opt<Signedness> CharSignedness(
87
88
static cl::opt<bool > Verbose (" v" , cl::desc(" Enable verbose output" ),
88
89
cl::init(false ),
89
90
cl::cat(LibCLCRemanglerToolCategory));
91
+ static cl::opt<bool > TextualOut (" S" , cl::desc(" Emit LLVM textual assembly" ),
92
+ cl::init(false ),
93
+ cl::cat(LibCLCRemanglerToolCategory));
90
94
static cl::opt<bool > TestRun (" t" , cl::desc(" Enable test run" ), cl::init(false ),
91
95
cl::cat(LibCLCRemanglerToolCategory));
92
96
@@ -842,8 +846,8 @@ class LibCLCRemangler : public ASTConsumer {
842
846
Function *NewF = CloneFunction (Clonee, Dummy);
843
847
NewF->setName (std::string (CloneName));
844
848
} else if (Verbose) {
845
- std::cout << " Could not create copy " << CloneName.data () << " : missing "
846
- << CloneeName.data () << std::endl ;
849
+ errs () << " Could not create copy " << CloneName.data () << " : missing "
850
+ << CloneeName.data () << ' \n ' ;
847
851
}
848
852
849
853
return true ;
@@ -874,16 +878,15 @@ class LibCLCRemangler : public ASTConsumer {
874
878
875
879
if (RemangledName != MangledName) {
876
880
if (Verbose || TestRun) {
877
- std::cout << " Mangling changed:"
878
- << " \n "
879
- << " Original: " << MangledName << " \n "
880
- << " New: " << RemangledName << " \n "
881
- << std::endl;
881
+ errs () << " Mangling changed:"
882
+ << " \n "
883
+ << " Original: " << MangledName << " \n "
884
+ << " New: " << RemangledName << " \n " ;
882
885
}
883
886
// In test run mode, where no substitution is made, change in mangling
884
887
// name represents a failure. Report an error.
885
888
if (TestRun) {
886
- std::cout << " Test run failure!" << std::endl ;
889
+ errs () << " Test run failure!\n " ;
887
890
return false ;
888
891
}
889
892
Func.setName (RemangledName);
@@ -934,12 +937,14 @@ class LibCLCRemangler : public ASTConsumer {
934
937
935
938
if (TestRun) {
936
939
if (Verbose)
937
- std::cout << " Successfully processed: " << NumProcessed << " functions."
938
- << std::endl;
940
+ errs () << " Successfully processed: " << NumProcessed << " functions.\n " ;
939
941
return ;
940
942
}
941
943
942
- WriteBitcodeToFile (*M, Out->os ());
944
+ if (TextualOut)
945
+ M->print (Out->os (), nullptr , true );
946
+ else
947
+ WriteBitcodeToFile (*M, Out->os ());
943
948
944
949
// Declare success.
945
950
Out->keep ();
0 commit comments