[llvm] 2d8a2a9 - [llvm-reduce] Check if module data strings are empty before attempting to reduce
Arthur Eubanks via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 24 10:23:47 PDT 2021
Author: Arthur Eubanks
Date: 2021-08-24T10:23:00-07:00
New Revision: 2d8a2a91b195420c48763217436698997147519d
URL: https://github.com/llvm/llvm-project/commit/2d8a2a91b195420c48763217436698997147519d
DIFF: https://github.com/llvm/llvm-project/commit/2d8a2a91b195420c48763217436698997147519d.diff
LOG: [llvm-reduce] Check if module data strings are empty before attempting to reduce
Added:
Modified:
llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp
Removed:
################################################################################
diff --git a/llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp b/llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp
index 8aa3c5ff8860..c51386938d6c 100644
--- a/llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp
+++ b/llvm/tools/llvm-reduce/deltas/ReduceModuleData.cpp
@@ -17,20 +17,36 @@ using namespace llvm;
static void clearModuleData(std::vector<Chunk> ChunksToKeep, Module *Program) {
Oracle O(ChunksToKeep);
- if (!O.shouldKeep())
+ if (!Program->getModuleIdentifier().empty() && !O.shouldKeep())
Program->setModuleIdentifier("");
- if (!O.shouldKeep())
+ if (!Program->getSourceFileName().empty() && !O.shouldKeep())
Program->setSourceFileName("");
- if (!O.shouldKeep())
+ if (!Program->getDataLayoutStr().empty() && !O.shouldKeep())
Program->setDataLayout("");
- if (!O.shouldKeep())
+ if (!Program->getTargetTriple().empty() && !O.shouldKeep())
Program->setTargetTriple("");
// TODO: clear line by line rather than all at once
- if (!O.shouldKeep())
+ if (!Program->getModuleInlineAsm().empty() && !O.shouldKeep())
Program->setModuleInlineAsm("");
}
+static int countModuleData(Module *M) {
+ int Count = 0;
+ if (!M->getModuleIdentifier().empty())
+ ++Count;
+ if (!M->getSourceFileName().empty())
+ ++Count;
+ if (!M->getDataLayoutStr().empty())
+ ++Count;
+ if (!M->getTargetTriple().empty())
+ ++Count;
+ if (!M->getModuleInlineAsm().empty())
+ ++Count;
+ return Count;
+}
+
void llvm::reduceModuleDataDeltaPass(TestRunner &Test) {
outs() << "*** Reducing Module Data...\n";
- runDeltaPass(Test, 5, clearModuleData);
+ int Count = countModuleData(Test.getProgram());
+ runDeltaPass(Test, Count, clearModuleData);
}
More information about the llvm-commits
mailing list