53
53
#include " llvm/Support/CommandLine.h"
54
54
#include " llvm/TargetParser/Triple.h"
55
55
56
- #include < cstdio>
57
-
58
56
#define DEBUG_TYPE " expand-variadics"
59
57
60
58
using namespace llvm ;
61
59
62
60
cl::opt<ExpandVariadicsMode> ExpandVariadicsModeOption (
63
61
DEBUG_TYPE " -override" , cl::desc(" Override the behaviour of " DEBUG_TYPE),
64
- cl::init(ExpandVariadicsMode::unspecified ),
65
- cl::values(clEnumValN(ExpandVariadicsMode::unspecified , " unspecified" ,
62
+ cl::init(ExpandVariadicsMode::Unspecified ),
63
+ cl::values(clEnumValN(ExpandVariadicsMode::Unspecified , " unspecified" ,
66
64
" Use the implementation defaults" ),
67
- clEnumValN(ExpandVariadicsMode::disable , " disable" ,
65
+ clEnumValN(ExpandVariadicsMode::Disable , " disable" ,
68
66
" Disable the pass entirely" ),
69
- clEnumValN(ExpandVariadicsMode::optimize , " optimize" ,
67
+ clEnumValN(ExpandVariadicsMode::Optimize , " optimize" ,
70
68
" Optimise without changing ABI" ),
71
- clEnumValN(ExpandVariadicsMode::lowering , " lowering" ,
69
+ clEnumValN(ExpandVariadicsMode::Lowering , " lowering" ,
72
70
" Change variadic calling convention" )));
73
71
74
72
namespace {
75
73
74
+ // At present Intrinsic:: has no interface to test if a declaration is in the
75
+ // module without creating one. Inserting a declaration and then testing if it
76
+ // has any uses and then deleting it seems a bad way to do the query.
76
77
// Module implements getFunction() which returns nullptr on missing declaration
77
78
// and getOrInsertFunction which creates one when absent. Intrinsics.h
78
79
// implements getDeclaration which creates one when missing. This should be
@@ -319,7 +320,7 @@ class ExpandVariadics : public ModulePass {
319
320
static ExpandVariadicsMode
320
321
withCommandLineOverride (ExpandVariadicsMode LLVMRequested) {
321
322
ExpandVariadicsMode UserRequested = ExpandVariadicsModeOption;
322
- return (UserRequested == ExpandVariadicsMode::unspecified ) ? LLVMRequested
323
+ return (UserRequested == ExpandVariadicsMode::Unspecified ) ? LLVMRequested
323
324
: UserRequested;
324
325
}
325
326
@@ -346,7 +347,7 @@ class ExpandVariadics : public ModulePass {
346
347
// Entry point
347
348
bool runOnModule (Module &M) override ;
348
349
349
- bool rewriteABI () { return Mode == ExpandVariadicsMode::lowering ; }
350
+ bool rewriteABI () { return Mode == ExpandVariadicsMode::Lowering ; }
350
351
351
352
void memcpyVAListPointers (const DataLayout &DL, IRBuilder<> &Builder,
352
353
Value *Dst, Value *Src) {
@@ -550,7 +551,7 @@ class ExpandVariadics : public ModulePass {
550
551
551
552
bool ExpandVariadics::runOnModule (Module &M) {
552
553
bool Changed = false ;
553
- if (Mode == ExpandVariadicsMode::disable )
554
+ if (Mode == ExpandVariadicsMode::Disable )
554
555
return Changed;
555
556
556
557
llvm::Triple Triple (M.getTargetTriple ());
@@ -562,7 +563,7 @@ bool ExpandVariadics::runOnModule(Module &M) {
562
563
563
564
ABI = VariadicABIInfo::create (Triple);
564
565
if (!ABI) {
565
- if (Mode == ExpandVariadicsMode::lowering ) {
566
+ if (Mode == ExpandVariadicsMode::Lowering ) {
566
567
report_fatal_error (
567
568
" Requested variadic lowering is unimplemented on this target" );
568
569
}
@@ -608,7 +609,7 @@ bool ExpandVariadics::runOnModule(Module &M) {
608
609
// and va_copy are removed. All that remains is for the lowering pass to find
609
610
// indirect calls and rewrite those as well.
610
611
611
- if (Mode == ExpandVariadicsMode::lowering ) {
612
+ if (Mode == ExpandVariadicsMode::Lowering ) {
612
613
for (Function &F : llvm::make_early_inc_range (M)) {
613
614
if (F.isDeclaration ())
614
615
continue ;
@@ -638,8 +639,6 @@ bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,
638
639
Function *F) {
639
640
bool Changed = false ;
640
641
641
- // fprintf(stderr, "Called runOn: %s\n", F->getName().str().c_str());
642
-
643
642
// This check might be too coarse - there are probably cases where
644
643
// splitting a function is bad but it's usable without splitting
645
644
if (!expansionApplicableToFunction (M, F))
@@ -674,7 +673,7 @@ bool ExpandVariadics::runOnFunction(Module &M, IRBuilder<> &Builder,
674
673
Value *calledOperand = CB->getCalledOperand ();
675
674
if (F == calledOperand) {
676
675
report_fatal_error (
677
- " ExpandVA abi requires eliminating call uses first\n " );
676
+ " ExpandVA abi requires eliminating call uses first" );
678
677
}
679
678
}
680
679
@@ -1049,8 +1048,8 @@ PreservedAnalyses ExpandVariadicsPass::run(Module &M, ModuleAnalysisManager &) {
1049
1048
1050
1049
ExpandVariadicsPass::ExpandVariadicsPass (OptimizationLevel Level)
1051
1050
: ExpandVariadicsPass(Level == OptimizationLevel::O0
1052
- ? ExpandVariadicsMode::disable
1053
- : ExpandVariadicsMode::optimize ) {}
1051
+ ? ExpandVariadicsMode::Disable
1052
+ : ExpandVariadicsMode::Optimize ) {}
1054
1053
1055
1054
ExpandVariadicsPass::ExpandVariadicsPass (ExpandVariadicsMode Mode)
1056
1055
: ConstructedMode(Mode) {}
0 commit comments