@@ -17,20 +17,36 @@ using namespace llvm;
17
17
static void clearModuleData (std::vector<Chunk> ChunksToKeep, Module *Program) {
18
18
Oracle O (ChunksToKeep);
19
19
20
- if (!O.shouldKeep ())
20
+ if (!Program-> getModuleIdentifier (). empty () && ! O.shouldKeep ())
21
21
Program->setModuleIdentifier (" " );
22
- if (!O.shouldKeep ())
22
+ if (!Program-> getSourceFileName (). empty () && ! O.shouldKeep ())
23
23
Program->setSourceFileName (" " );
24
- if (!O.shouldKeep ())
24
+ if (!Program-> getDataLayoutStr (). empty () && ! O.shouldKeep ())
25
25
Program->setDataLayout (" " );
26
- if (!O.shouldKeep ())
26
+ if (!Program-> getTargetTriple (). empty () && ! O.shouldKeep ())
27
27
Program->setTargetTriple (" " );
28
28
// TODO: clear line by line rather than all at once
29
- if (!O.shouldKeep ())
29
+ if (!Program-> getModuleInlineAsm (). empty () && ! O.shouldKeep ())
30
30
Program->setModuleInlineAsm (" " );
31
31
}
32
32
33
+ static int countModuleData (Module *M) {
34
+ int Count = 0 ;
35
+ if (!M->getModuleIdentifier ().empty ())
36
+ ++Count;
37
+ if (!M->getSourceFileName ().empty ())
38
+ ++Count;
39
+ if (!M->getDataLayoutStr ().empty ())
40
+ ++Count;
41
+ if (!M->getTargetTriple ().empty ())
42
+ ++Count;
43
+ if (!M->getModuleInlineAsm ().empty ())
44
+ ++Count;
45
+ return Count;
46
+ }
47
+
33
48
void llvm::reduceModuleDataDeltaPass (TestRunner &Test) {
34
49
outs () << " *** Reducing Module Data...\n " ;
35
- runDeltaPass (Test, 5 , clearModuleData);
50
+ int Count = countModuleData (Test.getProgram ());
51
+ runDeltaPass (Test, Count, clearModuleData);
36
52
}
0 commit comments