mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-27 14:24:40 +00:00
opt: Add option to strip or add llvm value names
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@240583 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -104,6 +104,12 @@ static cl::opt<bool>
|
|||||||
StripDebug("strip-debug",
|
StripDebug("strip-debug",
|
||||||
cl::desc("Strip debugger symbol info from translation unit"));
|
cl::desc("Strip debugger symbol info from translation unit"));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
StripValueNames("strip-value-names", cl::desc("Remove llvm value names"));
|
||||||
|
|
||||||
|
static cl::opt<bool>
|
||||||
|
NameValues("name-values", cl::desc("Give anonymous llvm values a name"));
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
DisableInline("disable-inlining", cl::desc("Do not run the inliner pass"));
|
DisableInline("disable-inlining", cl::desc("Do not run the inliner pass"));
|
||||||
|
|
||||||
@ -281,6 +287,37 @@ static TargetMachine* GetTargetMachine(Triple TheTriple, StringRef CPUStr,
|
|||||||
GetCodeGenOptLevel());
|
GetCodeGenOptLevel());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void removeValueNames(Module &Mod) {
|
||||||
|
for (Function &F : Mod) {
|
||||||
|
for (BasicBlock &BB : F) {
|
||||||
|
BB.setName("");
|
||||||
|
for (Instruction &I : BB)
|
||||||
|
I.setName("");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nameValuesInFunction(Function &F) {
|
||||||
|
bool FirstBB = true;
|
||||||
|
for (BasicBlock &BB : F) {
|
||||||
|
if (!BB.hasName())
|
||||||
|
BB.setName(FirstBB ? "entry" : "BB");
|
||||||
|
FirstBB = false;
|
||||||
|
|
||||||
|
for (Instruction &I : BB) {
|
||||||
|
if (I.getType()->isVoidTy())
|
||||||
|
continue;
|
||||||
|
if (!I.hasName())
|
||||||
|
I.setName("v");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void nameValues(Module &Mod) {
|
||||||
|
for (Function &F : Mod)
|
||||||
|
nameValuesInFunction(F);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef LINK_POLLY_INTO_TOOLS
|
#ifdef LINK_POLLY_INTO_TOOLS
|
||||||
namespace polly {
|
namespace polly {
|
||||||
void initializePollyPasses(llvm::PassRegistry &Registry);
|
void initializePollyPasses(llvm::PassRegistry &Registry);
|
||||||
@ -351,6 +388,12 @@ int main(int argc, char **argv) {
|
|||||||
if (StripDebug)
|
if (StripDebug)
|
||||||
StripDebugInfo(*M);
|
StripDebugInfo(*M);
|
||||||
|
|
||||||
|
if (StripValueNames)
|
||||||
|
removeValueNames(*M);
|
||||||
|
|
||||||
|
if (NameValues)
|
||||||
|
nameValues(*M);
|
||||||
|
|
||||||
// Immediately run the verifier to catch any problems before starting up the
|
// Immediately run the verifier to catch any problems before starting up the
|
||||||
// pass pipelines. Otherwise we can crash on broken code during
|
// pass pipelines. Otherwise we can crash on broken code during
|
||||||
// doInitialization().
|
// doInitialization().
|
||||||
|
Reference in New Issue
Block a user