mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-18 11:24:01 +00:00
Optimize trivial branches in CodeGenPrepare, which often get created from the
lowering of objectsize intrinsics. Unfortunately, a number of tests were relying on llc not optimizing trivial branches, so I had to add an option to allow them to continue to test what they originally tested. This fixes <rdar://problem/8785296> and <rdar://problem/9112893>. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@127459 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -58,6 +58,10 @@ STATISTIC(NumMemoryInsts, "Number of memory instructions whose address "
|
||||
STATISTIC(NumExtsMoved, "Number of [s|z]ext instructions combined with loads");
|
||||
STATISTIC(NumExtUses, "Number of uses of [s|z]ext instructions optimized");
|
||||
|
||||
static cl::opt<bool> DisableBranchOpts(
|
||||
"disable-cgp-branch-opts", cl::Hidden, cl::init(false),
|
||||
cl::desc("Disable branch optimizations in CodeGenPrepare"));
|
||||
|
||||
namespace {
|
||||
class CodeGenPrepare : public FunctionPass {
|
||||
/// TLI - Keep a pointer of a TargetLowering to consult for determining
|
||||
@ -130,6 +134,16 @@ bool CodeGenPrepare::runOnFunction(Function &F) {
|
||||
|
||||
SunkAddrs.clear();
|
||||
|
||||
if (!DisableBranchOpts) {
|
||||
MadeChange = false;
|
||||
for (Function::iterator BB = F.begin(), E = F.end(); BB != E; ++BB)
|
||||
MadeChange |= ConstantFoldTerminator(BB);
|
||||
|
||||
if (MadeChange && DT)
|
||||
DT->DT->recalculate(F);
|
||||
EverMadeChange |= MadeChange;
|
||||
}
|
||||
|
||||
return EverMadeChange;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user