mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
Also respect -mergeable-traps when merging cond_fails in SILOptimizer
This commit is contained in:
@@ -39,10 +39,12 @@ private func runMergeCondFails(function: Function, context: FunctionPassContext)
|
||||
|
||||
for inst in block.instructions {
|
||||
if let cfi = inst as? CondFailInst {
|
||||
let messageIsSame = condFailToMerge.isEmpty || cfi.message == condFailToMerge.first!.message
|
||||
let forceAllowMerge = context.options.enableMergeableTraps
|
||||
|
||||
// Do not process arithmetic overflow checks. We typically generate more
|
||||
// efficient code with separate jump-on-overflow.
|
||||
if !hasOverflowConditionOperand(cfi) &&
|
||||
(condFailToMerge.isEmpty || cfi.message == condFailToMerge.first!.message) {
|
||||
if !hasOverflowConditionOperand(cfi) && (messageIsSame || forceAllowMerge) {
|
||||
condFailToMerge.push(cfi)
|
||||
}
|
||||
} else if inst.mayHaveSideEffects || inst.mayReadFromMemory {
|
||||
|
||||
@@ -40,6 +40,10 @@ struct Options {
|
||||
_bridged.hasFeature(.Embedded)
|
||||
}
|
||||
|
||||
var enableMergeableTraps: Bool {
|
||||
_bridged.enableMergeableTraps()
|
||||
}
|
||||
|
||||
func hasFeature(_ feature: BridgedFeature) -> Bool {
|
||||
_bridged.hasFeature(feature)
|
||||
}
|
||||
|
||||
@@ -335,6 +335,9 @@ public:
|
||||
/// Temporarily used to bootstrap the AddressableParameters feature.
|
||||
bool EnableAddressDependencies = true;
|
||||
|
||||
// Whether to allow merging traps and cond_fails.
|
||||
bool MergeableTraps = false;
|
||||
|
||||
SILOptions() {}
|
||||
|
||||
/// Return a hash code of any components from these options that should
|
||||
|
||||
@@ -376,6 +376,7 @@ struct BridgedPassContext {
|
||||
|
||||
BRIDGED_INLINE bool useAggressiveReg2MemForCodeSize() const;
|
||||
BRIDGED_INLINE bool enableStackProtection() const;
|
||||
BRIDGED_INLINE bool enableMergeableTraps() const;
|
||||
BRIDGED_INLINE bool hasFeature(BridgedFeature feature) const;
|
||||
BRIDGED_INLINE bool enableMoveInoutStackProtection() const;
|
||||
BRIDGED_INLINE AssertConfiguration getAssertConfiguration() const;
|
||||
|
||||
@@ -543,6 +543,11 @@ bool BridgedPassContext::enableStackProtection() const {
|
||||
return mod->getOptions().EnableStackProtection;
|
||||
}
|
||||
|
||||
bool BridgedPassContext::enableMergeableTraps() const {
|
||||
swift::SILModule *mod = invocation->getPassManager()->getModule();
|
||||
return mod->getOptions().MergeableTraps;
|
||||
}
|
||||
|
||||
bool BridgedPassContext::hasFeature(BridgedFeature feature) const {
|
||||
swift::SILModule *mod = invocation->getPassManager()->getModule();
|
||||
return mod->getASTContext().LangOpts.hasFeature((swift::Feature)feature);
|
||||
|
||||
@@ -3109,11 +3109,11 @@ static bool ParseSILArgs(SILOptions &Opts, ArgList &Args,
|
||||
Opts.ShouldFunctionsBePreservedToDebugger &=
|
||||
LTOKind.value() == IRGenLLVMLTOKind::None;
|
||||
|
||||
|
||||
Opts.EnableAddressDependencies =
|
||||
Opts.EnableAddressDependencies =
|
||||
Args.hasFlag(OPT_enable_address_dependencies,
|
||||
OPT_disable_address_dependencies,
|
||||
Opts.EnableAddressDependencies);
|
||||
Opts.MergeableTraps = Args.hasArg(OPT_mergeable_traps);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user