2010-10-08 01:55:47 +08:00
|
|
|
//===-- Utils.cpp - TransformUtils Infrastructure -------------------------===//
|
|
|
|
//
|
|
|
|
// The LLVM Compiler Infrastructure
|
|
|
|
//
|
|
|
|
// This file is distributed under the University of Illinois Open Source
|
|
|
|
// License. See LICENSE.TXT for details.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
//
|
|
|
|
// This file defines the common initialization infrastructure for the
|
|
|
|
// TransformUtils library.
|
|
|
|
//
|
|
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
|
2018-03-29 01:44:36 +08:00
|
|
|
#include "llvm/Transforms/Utils.h"
|
2010-10-08 01:55:47 +08:00
|
|
|
#include "llvm-c/Initialization.h"
|
2018-03-29 15:56:53 +08:00
|
|
|
#include "llvm-c/Transforms/Scalar.h"
|
2018-03-29 01:44:36 +08:00
|
|
|
#include "llvm/IR/LegacyPassManager.h"
|
2017-06-06 19:49:48 +08:00
|
|
|
#include "llvm/InitializePasses.h"
|
2014-01-07 19:48:04 +08:00
|
|
|
#include "llvm/PassRegistry.h"
|
2010-10-08 01:55:47 +08:00
|
|
|
|
|
|
|
using namespace llvm;
|
|
|
|
|
|
|
|
/// initializeTransformUtils - Initialize all passes in the TransformUtils
|
|
|
|
/// library.
|
|
|
|
void llvm::initializeTransformUtils(PassRegistry &Registry) {
|
2016-06-16 05:51:30 +08:00
|
|
|
initializeAddDiscriminatorsLegacyPassPass(Registry);
|
2010-10-08 01:55:47 +08:00
|
|
|
initializeBreakCriticalEdgesPass(Registry);
|
|
|
|
initializeInstNamerPass(Registry);
|
2016-06-10 03:44:46 +08:00
|
|
|
initializeLCSSAWrapperPassPass(Registry);
|
Conditionally eliminate library calls where the result value is not used
Summary:
This pass shrink-wraps a condition to some library calls where the call
result is not used. For example:
sqrt(val);
is transformed to
if (val < 0)
sqrt(val);
Even if the result of library call is not being used, the compiler cannot
safely delete the call because the function can set errno on error
conditions.
Note in many functions, the error condition solely depends on the incoming
parameter. In this optimization, we can generate the condition can lead to
the errno to shrink-wrap the call. Since the chances of hitting the error
condition is low, the runtime call is effectively eliminated.
These partially dead calls are usually results of C++ abstraction penalty
exposed by inlining. This optimization hits 108 times in 19 C/C++ programs
in SPEC2006.
Reviewers: hfinkel, mehdi_amini, davidxl
Subscribers: modocache, mgorny, mehdi_amini, xur, llvm-commits, beanz
Differential Revision: https://reviews.llvm.org/D24414
llvm-svn: 284542
2016-10-19 05:36:27 +08:00
|
|
|
initializeLibCallsShrinkWrapLegacyPassPass(Registry);
|
2010-10-08 01:55:47 +08:00
|
|
|
initializeLoopSimplifyPass(Registry);
|
2016-08-13 01:28:27 +08:00
|
|
|
initializeLowerInvokeLegacyPassPass(Registry);
|
2010-10-08 01:55:47 +08:00
|
|
|
initializeLowerSwitchPass(Registry);
|
2016-09-17 00:56:30 +08:00
|
|
|
initializeNameAnonGlobalLegacyPassPass(Registry);
|
2016-06-14 11:22:22 +08:00
|
|
|
initializePromoteLegacyPassPass(Registry);
|
2016-10-26 02:44:13 +08:00
|
|
|
initializeStripNonLineTableDebugInfoPass(Registry);
|
2010-10-08 01:55:47 +08:00
|
|
|
initializeUnifyFunctionExitNodesPass(Registry);
|
2010-12-21 04:54:37 +08:00
|
|
|
initializeInstSimplifierPass(Registry);
|
2018-03-29 01:44:36 +08:00
|
|
|
initializeMetaRenamerPass(Registry);
|
2016-10-22 02:43:16 +08:00
|
|
|
initializeStripGCRelocatesPass(Registry);
|
Add PredicateInfo utility and printing pass
Summary:
This patch adds a utility to build extended SSA (see "ABCD: eliminating
array bounds checks on demand"), and an intrinsic to support it. This
is then used to get functionality equivalent to propagateEquality in
GVN, in NewGVN (without having to replace instructions as we go). It
would work similarly in SCCP or other passes. This has been talked
about a few times, so i built a real implementation and tried to
productionize it.
Copies are inserted for operands used in assumes and conditional
branches that are based on comparisons (see below for more)
Every use affected by the predicate is renamed to the appropriate
intrinsic result.
E.g.
%cmp = icmp eq i32 %x, 50
br i1 %cmp, label %true, label %false
true:
ret i32 %x
false:
ret i32 1
will become
%cmp = icmp eq i32, %x, 50
br i1 %cmp, label %true, label %false
true:
; Has predicate info
; branch predicate info { TrueEdge: 1 Comparison: %cmp = icmp eq i32 %x, 50 }
%x.0 = call @llvm.ssa_copy.i32(i32 %x)
ret i32 %x.0
false:
ret i23 1
(you can use -print-predicateinfo to get an annotated-with-predicateinfo dump)
This enables us to easily determine what operations are affected by a
given predicate, and how operations affected by a chain of
predicates.
Reviewers: davide, sanjoy
Subscribers: mgorny, llvm-commits, Prazek
Differential Revision: https://reviews.llvm.org/D29519
Update for review comments
Fix a bug Nuno noticed where we are giving information about and/or on edges where the info is not useful and easy to use wrong
Update for review comments
llvm-svn: 294351
2017-02-08 05:10:46 +08:00
|
|
|
initializePredicateInfoPrinterLegacyPassPass(Registry);
|
2010-10-08 01:55:47 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/// LLVMInitializeTransformUtils - C binding for initializeTransformUtilsPasses.
|
|
|
|
void LLVMInitializeTransformUtils(LLVMPassRegistryRef R) {
|
|
|
|
initializeTransformUtils(*unwrap(R));
|
|
|
|
}
|
2018-03-29 01:44:36 +08:00
|
|
|
|
|
|
|
void LLVMAddLowerSwitchPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createLowerSwitchPass());
|
|
|
|
}
|
|
|
|
|
|
|
|
void LLVMAddPromoteMemoryToRegisterPass(LLVMPassManagerRef PM) {
|
|
|
|
unwrap(PM)->add(createPromoteMemoryToRegisterPass());
|
|
|
|
}
|
|
|
|
|