diff --git a/README.md b/README.md index de0891a7044a94..05a302a8f193e3 100644 --- a/README.md +++ b/README.md @@ -1,5 +1 @@ # The LLVM Compiler Infrastructure - -This directory and its subdirectories contain source code for LLVM, -a toolkit for the construction of highly optimized compilers, -optimizers, and runtime environments. diff --git a/lldb/include/lldb/API/SBDebugger.h b/lldb/include/lldb/API/SBDebugger.h index 585d948d2394a1..417cead24a8c61 100644 --- a/lldb/include/lldb/API/SBDebugger.h +++ b/lldb/include/lldb/API/SBDebugger.h @@ -255,15 +255,11 @@ class LLDB_API SBDebugger { SBTypeFormat GetFormatForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryForType(SBTypeNameSpecifier); -#endif SBTypeFilter GetFilterForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier); -#endif void RunCommandInterpreter(bool auto_handle_events, bool spawn_thread); diff --git a/lldb/include/lldb/API/SBTypeCategory.h b/lldb/include/lldb/API/SBTypeCategory.h index 89ab7e56d7de1f..c0f4cee1d268f9 100644 --- a/lldb/include/lldb/API/SBTypeCategory.h +++ b/lldb/include/lldb/API/SBTypeCategory.h @@ -47,9 +47,7 @@ class LLDB_API SBTypeCategory { uint32_t GetNumFilters(); -#ifndef LLDB_DISABLE_PYTHON uint32_t GetNumSynthetics(); -#endif SBTypeNameSpecifier GetTypeNameSpecifierForFilterAtIndex(uint32_t); @@ -57,43 +55,29 @@ class LLDB_API SBTypeCategory { SBTypeNameSpecifier GetTypeNameSpecifierForSummaryAtIndex(uint32_t); -#ifndef LLDB_DISABLE_PYTHON SBTypeNameSpecifier GetTypeNameSpecifierForSyntheticAtIndex(uint32_t); -#endif SBTypeFilter GetFilterForType(SBTypeNameSpecifier); SBTypeFormat GetFormatForType(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryForType(SBTypeNameSpecifier); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticForType(SBTypeNameSpecifier); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeFilter GetFilterAtIndex(uint32_t); -#endif SBTypeFormat GetFormatAtIndex(uint32_t); -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary GetSummaryAtIndex(uint32_t); -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic GetSyntheticAtIndex(uint32_t); -#endif bool AddTypeFormat(SBTypeNameSpecifier, SBTypeFormat); bool DeleteTypeFormat(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON bool AddTypeSummary(SBTypeNameSpecifier, SBTypeSummary); -#endif bool DeleteTypeSummary(SBTypeNameSpecifier); @@ -101,11 +85,9 @@ class LLDB_API SBTypeCategory { bool DeleteTypeFilter(SBTypeNameSpecifier); -#ifndef LLDB_DISABLE_PYTHON bool AddTypeSynthetic(SBTypeNameSpecifier, SBTypeSynthetic); bool DeleteTypeSynthetic(SBTypeNameSpecifier); -#endif lldb::SBTypeCategory &operator=(const lldb::SBTypeCategory &rhs); diff --git a/lldb/include/lldb/API/SBTypeSynthetic.h b/lldb/include/lldb/API/SBTypeSynthetic.h index f2ca0f065e8979..c190643c1ebba9 100644 --- a/lldb/include/lldb/API/SBTypeSynthetic.h +++ b/lldb/include/lldb/API/SBTypeSynthetic.h @@ -12,8 +12,6 @@ #include "lldb/API/SBDefines.h" -#ifndef LLDB_DISABLE_PYTHON - namespace lldb { class LLDB_API SBTypeSynthetic { @@ -79,6 +77,4 @@ class LLDB_API SBTypeSynthetic { } // namespace lldb -#endif // LLDB_DISABLE_PYTHON - #endif // LLDB_SBTypeSynthetic_h_ diff --git a/lldb/include/lldb/API/SBValue.h b/lldb/include/lldb/API/SBValue.h index ffd15ae80d8317..be4080679caa03 100644 --- a/lldb/include/lldb/API/SBValue.h +++ b/lldb/include/lldb/API/SBValue.h @@ -112,9 +112,7 @@ class LLDB_API SBValue { lldb::SBTypeFilter GetTypeFilter(); -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSynthetic GetTypeSynthetic(); -#endif lldb::SBValue GetChildAtIndex(uint32_t idx); diff --git a/lldb/source/API/SBDebugger.cpp b/lldb/source/API/SBDebugger.cpp index 693b0fefee6d2c..2cc8157dfcb086 100644 --- a/lldb/source/API/SBDebugger.cpp +++ b/lldb/source/API/SBDebugger.cpp @@ -1476,7 +1476,6 @@ SBTypeFormat SBDebugger::GetFormatForType(SBTypeNameSpecifier type_name) { return LLDB_RECORD_RESULT(SBTypeFormat()); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, (lldb::SBTypeNameSpecifier), type_name); @@ -1486,7 +1485,6 @@ SBTypeSummary SBDebugger::GetSummaryForType(SBTypeNameSpecifier type_name) { return LLDB_RECORD_RESULT( SBTypeSummary(DataVisualization::GetSummaryForType(type_name.GetSP()))); } -#endif // LLDB_DISABLE_PYTHON SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, @@ -1498,7 +1496,6 @@ SBTypeFilter SBDebugger::GetFilterForType(SBTypeNameSpecifier type_name) { SBTypeFilter(DataVisualization::GetFilterForType(type_name.GetSP()))); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, (lldb::SBTypeNameSpecifier), type_name); @@ -1508,7 +1505,6 @@ SBTypeSynthetic SBDebugger::GetSyntheticForType(SBTypeNameSpecifier type_name) { return LLDB_RECORD_RESULT(SBTypeSynthetic( DataVisualization::GetSyntheticForType(type_name.GetSP()))); } -#endif // LLDB_DISABLE_PYTHON static llvm::ArrayRef GetCategoryArray(const char **categories) { if (categories == nullptr) diff --git a/lldb/source/API/SBFrame.cpp b/lldb/source/API/SBFrame.cpp index 6a28ef6cc60fa5..ffed53fa964362 100644 --- a/lldb/source/API/SBFrame.cpp +++ b/lldb/source/API/SBFrame.cpp @@ -1080,9 +1080,7 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, (const char *, const lldb::SBExpressionOptions &), expr, options); -#ifndef LLDB_DISABLE_PYTHON Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); -#endif SBValue expr_result; @@ -1122,12 +1120,10 @@ lldb::SBValue SBFrame::EvaluateExpression(const char *expr, } } -#ifndef LLDB_DISABLE_PYTHON if (expr_log) expr_log->Printf("** [SBFrame::EvaluateExpression] Expression result is " "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); -#endif return LLDB_RECORD_RESULT(expr_result); } diff --git a/lldb/source/API/SBReproducer.cpp b/lldb/source/API/SBReproducer.cpp index 697878c8f3f1ab..2a31986e5c4497 100644 --- a/lldb/source/API/SBReproducer.cpp +++ b/lldb/source/API/SBReproducer.cpp @@ -831,12 +831,10 @@ SBRegistry::SBRegistry() { ()); LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBDebugger, GetFormatForType, (lldb::SBTypeNameSpecifier)); -#ifndef LLDB_DISABLE_PYTHON LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBDebugger, GetSummaryForType, (lldb::SBTypeNameSpecifier)); LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBDebugger, GetSyntheticForType, (lldb::SBTypeNameSpecifier)); -#endif LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBDebugger, GetFilterForType, (lldb::SBTypeNameSpecifier)); LLDB_REGISTER_METHOD(bool, SBDebugger, EnableLog, @@ -2475,7 +2473,6 @@ SBRegistry::SBRegistry() { LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFormats, ()); LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSummaries, ()); LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumFilters, ()); -#ifndef LLDB_DISABLE_PYTHON LLDB_REGISTER_METHOD(uint32_t, SBTypeCategory, GetNumSynthetics, ()); LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, GetTypeNameSpecifierForSyntheticAtIndex, (uint32_t)); @@ -2495,7 +2492,6 @@ SBRegistry::SBRegistry() { (lldb::SBTypeNameSpecifier, lldb::SBTypeSynthetic)); LLDB_REGISTER_METHOD(bool, SBTypeCategory, DeleteTypeSynthetic, (lldb::SBTypeNameSpecifier)); -#endif LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, GetTypeNameSpecifierForFilterAtIndex, (uint32_t)); LLDB_REGISTER_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, @@ -2676,7 +2672,6 @@ SBRegistry::SBRegistry() { LLDB_REGISTER_METHOD(bool, SBTypeSummary, operator!=,(lldb::SBTypeSummary &)); } -#ifndef LLDB_DISABLE_PYTHON { LLDB_REGISTER_CONSTRUCTOR(SBTypeSynthetic, ()); LLDB_REGISTER_STATIC_METHOD(lldb::SBTypeSynthetic, SBTypeSynthetic, @@ -2705,7 +2700,6 @@ SBRegistry::SBRegistry() { LLDB_REGISTER_METHOD(bool, SBTypeSynthetic, operator!=,(lldb::SBTypeSynthetic &)); } -#endif { LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, ()); LLDB_REGISTER_CONSTRUCTOR(SBUnixSignals, (const lldb::SBUnixSignals &)); @@ -2763,9 +2757,7 @@ SBRegistry::SBRegistry() { LLDB_REGISTER_METHOD(lldb::SBTypeFormat, SBValue, GetTypeFormat, ()); LLDB_REGISTER_METHOD(lldb::SBTypeSummary, SBValue, GetTypeSummary, ()); LLDB_REGISTER_METHOD(lldb::SBTypeFilter, SBValue, GetTypeFilter, ()); -#ifndef LLDB_DISABLE_PYTHON LLDB_REGISTER_METHOD(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic, ()); -#endif LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, CreateChildAtOffset, (const char *, uint32_t, lldb::SBType)); LLDB_REGISTER_METHOD(lldb::SBValue, SBValue, Cast, (lldb::SBType)); diff --git a/lldb/source/API/SBTarget.cpp b/lldb/source/API/SBTarget.cpp index c168ae0d2cc9d6..0cf42d2e639165 100644 --- a/lldb/source/API/SBTarget.cpp +++ b/lldb/source/API/SBTarget.cpp @@ -2352,9 +2352,7 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, (const char *, const lldb::SBExpressionOptions &), expr, options); -#if !defined(LLDB_DISABLE_PYTHON) Log *expr_log(GetLogIfAllCategoriesSet(LIBLLDB_LOG_EXPRESSIONS)); -#endif SBValue expr_result; ValueObjectSP expr_value_sp; TargetSP target_sp(GetSP()); @@ -2387,13 +2385,10 @@ lldb::SBValue SBTarget::EvaluateExpression(const char *expr, expr_result.SetSP(expr_value_sp, options.GetFetchDynamicValue()); } } -#ifndef LLDB_DISABLE_PYTHON if (expr_log) expr_log->Printf("** [SBTarget::EvaluateExpression] Expression result is " "%s, summary %s **", expr_result.GetValue(), expr_result.GetSummary()); -#endif - return LLDB_RECORD_RESULT(expr_result); } diff --git a/lldb/source/API/SBTypeCategory.cpp b/lldb/source/API/SBTypeCategory.cpp index dac9f8a0407b79..f87884ea3d84d6 100644 --- a/lldb/source/API/SBTypeCategory.cpp +++ b/lldb/source/API/SBTypeCategory.cpp @@ -132,7 +132,6 @@ uint32_t SBTypeCategory::GetNumFilters() { m_opaque_sp->GetRegexTypeFiltersContainer()->GetCount(); } -#ifndef LLDB_DISABLE_PYTHON uint32_t SBTypeCategory::GetNumSynthetics() { LLDB_RECORD_METHOD_NO_ARGS(uint32_t, SBTypeCategory, GetNumSynthetics); @@ -141,7 +140,6 @@ uint32_t SBTypeCategory::GetNumSynthetics() { return m_opaque_sp->GetTypeSyntheticsContainer()->GetCount() + m_opaque_sp->GetRegexTypeSyntheticsContainer()->GetCount(); } -#endif lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForFilterAtIndex(uint32_t index) { @@ -176,7 +174,6 @@ SBTypeCategory::GetTypeNameSpecifierForSummaryAtIndex(uint32_t index) { m_opaque_sp->GetTypeNameSpecifierForSummaryAtIndex(index))); } -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeNameSpecifier SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) { LLDB_RECORD_METHOD(lldb::SBTypeNameSpecifier, SBTypeCategory, @@ -188,7 +185,6 @@ SBTypeCategory::GetTypeNameSpecifierForSyntheticAtIndex(uint32_t index) { return LLDB_RECORD_RESULT(SBTypeNameSpecifier( m_opaque_sp->GetTypeNameSpecifierForSyntheticAtIndex(index))); } -#endif SBTypeFilter SBTypeCategory::GetFilterForType(SBTypeNameSpecifier spec) { LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterForType, @@ -242,7 +238,6 @@ SBTypeFormat SBTypeCategory::GetFormatForType(SBTypeNameSpecifier spec) { return LLDB_RECORD_RESULT(lldb::SBTypeFormat(format_sp)); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryForType, (lldb::SBTypeNameSpecifier), spec); @@ -267,9 +262,7 @@ SBTypeSummary SBTypeCategory::GetSummaryForType(SBTypeNameSpecifier spec) { return LLDB_RECORD_RESULT(lldb::SBTypeSummary(summary_sp)); } -#endif // LLDB_DISABLE_PYTHON -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticForType, (lldb::SBTypeNameSpecifier), spec); @@ -297,9 +290,7 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticForType(SBTypeNameSpecifier spec) { return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); } -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) { LLDB_RECORD_METHOD(lldb::SBTypeFilter, SBTypeCategory, GetFilterAtIndex, (uint32_t), index); @@ -317,7 +308,6 @@ SBTypeFilter SBTypeCategory::GetFilterAtIndex(uint32_t index) { return LLDB_RECORD_RESULT(lldb::SBTypeFilter(filter_sp)); } -#endif SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) { LLDB_RECORD_METHOD(lldb::SBTypeFormat, SBTypeCategory, GetFormatAtIndex, @@ -329,7 +319,6 @@ SBTypeFormat SBTypeCategory::GetFormatAtIndex(uint32_t index) { SBTypeFormat(m_opaque_sp->GetFormatAtIndex((index)))); } -#ifndef LLDB_DISABLE_PYTHON SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) { LLDB_RECORD_METHOD(lldb::SBTypeSummary, SBTypeCategory, GetSummaryAtIndex, (uint32_t), index); @@ -339,9 +328,7 @@ SBTypeSummary SBTypeCategory::GetSummaryAtIndex(uint32_t index) { return LLDB_RECORD_RESULT( SBTypeSummary(m_opaque_sp->GetSummaryAtIndex((index)))); } -#endif -#ifndef LLDB_DISABLE_PYTHON SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) { LLDB_RECORD_METHOD(lldb::SBTypeSynthetic, SBTypeCategory, GetSyntheticAtIndex, (uint32_t), index); @@ -359,7 +346,6 @@ SBTypeSynthetic SBTypeCategory::GetSyntheticAtIndex(uint32_t index) { return LLDB_RECORD_RESULT(lldb::SBTypeSynthetic(synth_sp)); } -#endif bool SBTypeCategory::AddTypeFormat(SBTypeNameSpecifier type_name, SBTypeFormat format) { @@ -406,7 +392,6 @@ bool SBTypeCategory::DeleteTypeFormat(SBTypeNameSpecifier type_name) { ConstString(type_name.GetName())); } -#ifndef LLDB_DISABLE_PYTHON bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, SBTypeSummary summary) { LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSummary, @@ -467,7 +452,6 @@ bool SBTypeCategory::AddTypeSummary(SBTypeNameSpecifier type_name, return true; } -#endif bool SBTypeCategory::DeleteTypeSummary(SBTypeNameSpecifier type_name) { LLDB_RECORD_METHOD(bool, SBTypeCategory, DeleteTypeSummary, @@ -532,7 +516,6 @@ bool SBTypeCategory::DeleteTypeFilter(SBTypeNameSpecifier type_name) { ConstString(type_name.GetName())); } -#ifndef LLDB_DISABLE_PYTHON bool SBTypeCategory::AddTypeSynthetic(SBTypeNameSpecifier type_name, SBTypeSynthetic synth) { LLDB_RECORD_METHOD(bool, SBTypeCategory, AddTypeSynthetic, @@ -611,7 +594,6 @@ bool SBTypeCategory::DeleteTypeSynthetic(SBTypeNameSpecifier type_name) { return m_opaque_sp->GetTypeSyntheticsContainer()->Delete( ConstString(type_name.GetName())); } -#endif // LLDB_DISABLE_PYTHON bool SBTypeCategory::GetDescription(lldb::SBStream &description, lldb::DescriptionLevel description_level) { diff --git a/lldb/source/API/SBTypeSynthetic.cpp b/lldb/source/API/SBTypeSynthetic.cpp index 555820384acfc6..7f582682d9dd5d 100644 --- a/lldb/source/API/SBTypeSynthetic.cpp +++ b/lldb/source/API/SBTypeSynthetic.cpp @@ -17,8 +17,6 @@ using namespace lldb; using namespace lldb_private; -#ifndef LLDB_DISABLE_PYTHON - SBTypeSynthetic::SBTypeSynthetic() : m_opaque_sp() { LLDB_RECORD_CONSTRUCTOR_NO_ARGS(SBTypeSynthetic); } @@ -212,5 +210,3 @@ bool SBTypeSynthetic::CopyOnWrite_Impl() { return true; } - -#endif // LLDB_DISABLE_PYTHON diff --git a/lldb/source/API/SBValue.cpp b/lldb/source/API/SBValue.cpp index 6ed526c9ec0cbf..da10dadaf20532 100644 --- a/lldb/source/API/SBValue.cpp +++ b/lldb/source/API/SBValue.cpp @@ -558,7 +558,6 @@ lldb::SBTypeFilter SBValue::GetTypeFilter() { return LLDB_RECORD_RESULT(filter); } -#ifndef LLDB_DISABLE_PYTHON lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { LLDB_RECORD_METHOD_NO_ARGS(lldb::SBTypeSynthetic, SBValue, GetTypeSynthetic); @@ -578,7 +577,6 @@ lldb::SBTypeSynthetic SBValue::GetTypeSynthetic() { } return LLDB_RECORD_RESULT(synthetic); } -#endif lldb::SBValue SBValue::CreateChildAtOffset(const char *name, uint32_t offset, SBType type) { diff --git a/llvm/include/llvm/Support/CodeGen.h b/llvm/include/llvm/Support/CodeGen.h index 3175b29a4dd9a6..a3f423e558cf2b 100644 --- a/llvm/include/llvm/Support/CodeGen.h +++ b/llvm/include/llvm/Support/CodeGen.h @@ -18,13 +18,14 @@ namespace llvm { // Relocation model types. namespace Reloc { - enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI }; + // Cannot be named PIC due to collision with -DPIC + enum Model { Static, PIC_, DynamicNoPIC, ROPI, RWPI, ROPI_RWPI }; } // Code model types. namespace CodeModel { // Sync changes with CodeGenCWrappers.h. - enum Model { Tiny, Small, Kernel, Medium, Large }; + enum Model { Tiny, Small, Kernel, Medium, Large }; } namespace PICLevel { diff --git a/llvm/test/Transforms/InstCombine/sadd-with-overflow.ll b/llvm/test/Transforms/InstCombine/sadd-with-overflow.ll index c2c554398f5faf..c08515c1dcd502 100644 --- a/llvm/test/Transforms/InstCombine/sadd-with-overflow.ll +++ b/llvm/test/Transforms/InstCombine/sadd-with-overflow.ll @@ -7,96 +7,107 @@ declare { i32, i1 } @llvm.sadd.with.overflow.i32(i32, i32) declare { i8, i1 } @llvm.sadd.with.overflow.i8(i8, i8) -define { i32, i1 } @simple_fold(i32) { +define { i32, i1 } @simple_fold(i32 %x) { ; CHECK-LABEL: @simple_fold( -; CHECK-NEXT: [[TMP2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP0:%.*]], i32 20) -; CHECK-NEXT: ret { i32, i1 } [[TMP2]] +; CHECK-NEXT: [[TMP1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X:%.*]], i32 20) +; CHECK-NEXT: ret { i32, i1 } [[TMP1]] ; - %2 = add nsw i32 %0, 7 - %3 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %2, i32 13) - ret { i32, i1 } %3 + %a = add nsw i32 %x, 7 + %b = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 13) + ret { i32, i1 } %b } -define { i32, i1 } @fold_mixed_signs(i32) { +define { i32, i1 } @fold_mixed_signs(i32 %x) { ; CHECK-LABEL: @fold_mixed_signs( -; CHECK-NEXT: [[TMP2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP0:%.*]], i32 6) -; CHECK-NEXT: ret { i32, i1 } [[TMP2]] +; CHECK-NEXT: [[TMP1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X:%.*]], i32 6) +; CHECK-NEXT: ret { i32, i1 } [[TMP1]] ; - %2 = add nsw i32 %0, 13 - %3 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %2, i32 -7) - ret { i32, i1 } %3 + %a = add nsw i32 %x, 13 + %b = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 -7) + ret { i32, i1 } %b } -define { i8, i1 } @fold_on_constant_add_no_overflow(i8) { +define { i8, i1 } @fold_on_constant_add_no_overflow(i8 %x) { ; CHECK-LABEL: @fold_on_constant_add_no_overflow( -; CHECK-NEXT: [[TMP2:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[TMP0:%.*]], i8 127) -; CHECK-NEXT: ret { i8, i1 } [[TMP2]] +; CHECK-NEXT: [[TMP1:%.*]] = call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[X:%.*]], i8 127) +; CHECK-NEXT: ret { i8, i1 } [[TMP1]] ; - %2 = add nsw i8 %0, 100 - %3 = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %2, i8 27) - ret { i8, i1 } %3 + %a = add nsw i8 %x, 100 + %b = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 27) + ret { i8, i1 } %b } -define { i8, i1 } @no_fold_on_constant_add_overflow(i8) { +define { i8, i1 } @no_fold_on_constant_add_overflow(i8 %x) { ; CHECK-LABEL: @no_fold_on_constant_add_overflow( -; CHECK-NEXT: [[TMP2:%.*]] = add nsw i8 [[TMP0:%.*]], 100 -; CHECK-NEXT: [[TMP3:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[TMP2]], i8 28) -; CHECK-NEXT: ret { i8, i1 } [[TMP3]] +; CHECK-NEXT: [[A:%.*]] = add nsw i8 [[X:%.*]], 100 +; CHECK-NEXT: [[B:%.*]] = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 [[A]], i8 28) +; CHECK-NEXT: ret { i8, i1 } [[B]] ; - %2 = add nsw i8 %0, 100 - %3 = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %2, i8 28) - ret { i8, i1 } %3 + %a = add nsw i8 %x, 100 + %b = tail call { i8, i1 } @llvm.sadd.with.overflow.i8(i8 %a, i8 28) + ret { i8, i1 } %b } -define { <2 x i32>, <2 x i1> } @fold_simple_splat_constant(<2 x i32>) { +define { <2 x i32>, <2 x i1> } @fold_simple_splat_constant(<2 x i32> %x) { ; CHECK-LABEL: @fold_simple_splat_constant( -; CHECK-NEXT: [[TMP2:%.*]] = call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[TMP0:%.*]], <2 x i32> ) -; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[TMP2]] +; CHECK-NEXT: [[TMP1:%.*]] = call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[X:%.*]], <2 x i32> ) +; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[TMP1]] ; - %2 = add nsw <2 x i32> %0, - %3 = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %2, <2 x i32> ) - ret { <2 x i32>, <2 x i1> } %3 + %a = add nsw <2 x i32> %x, + %b = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> ) + ret { <2 x i32>, <2 x i1> } %b } -define { <2 x i32>, <2 x i1> } @no_fold_splat_undef_constant(<2 x i32>) { +define { <2 x i32>, <2 x i1> } @no_fold_splat_undef_constant(<2 x i32> %x) { ; CHECK-LABEL: @no_fold_splat_undef_constant( -; CHECK-NEXT: [[TMP2:%.*]] = add nsw <2 x i32> [[TMP0:%.*]], -; CHECK-NEXT: [[TMP3:%.*]] = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[TMP2]], <2 x i32> ) -; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[TMP3]] +; CHECK-NEXT: [[A:%.*]] = add nsw <2 x i32> [[X:%.*]], +; CHECK-NEXT: [[B:%.*]] = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[A]], <2 x i32> ) +; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[B]] ; - %2 = add nsw <2 x i32> %0, - %3 = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %2, <2 x i32> ) - ret { <2 x i32>, <2 x i1> } %3 + %a = add nsw <2 x i32> %x, + %b = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> ) + ret { <2 x i32>, <2 x i1> } %b } -define { <2 x i32>, <2 x i1> } @no_fold_splat_not_constant(<2 x i32>, <2 x i32>) { +define { <2 x i32>, <2 x i1> } @no_fold_splat_not_constant(<2 x i32> %x, <2 x i32> %y) { ; CHECK-LABEL: @no_fold_splat_not_constant( -; CHECK-NEXT: [[TMP3:%.*]] = add nsw <2 x i32> [[TMP0:%.*]], [[TMP1:%.*]] -; CHECK-NEXT: [[TMP4:%.*]] = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[TMP3]], <2 x i32> ) -; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[TMP4]] +; CHECK-NEXT: [[A:%.*]] = add nsw <2 x i32> [[X:%.*]], [[Y:%.*]] +; CHECK-NEXT: [[B:%.*]] = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> [[A]], <2 x i32> ) +; CHECK-NEXT: ret { <2 x i32>, <2 x i1> } [[B]] ; - %3 = add nsw <2 x i32> %0, %1 - %4 = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %3, <2 x i32> ) - ret { <2 x i32>, <2 x i1> } %4 + %a = add nsw <2 x i32> %x, %y + %b = tail call { <2 x i32>, <2 x i1> } @llvm.sadd.with.overflow.v2i32(<2 x i32> %a, <2 x i32> ) + ret { <2 x i32>, <2 x i1> } %b } -define { i32, i1 } @fold_nuwnsw(i32) { +define { i32, i1 } @fold_nuwnsw(i32 %x) { ; CHECK-LABEL: @fold_nuwnsw( -; CHECK-NEXT: [[TMP2:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP0:%.*]], i32 42) -; CHECK-NEXT: ret { i32, i1 } [[TMP2]] +; CHECK-NEXT: [[TMP1:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X:%.*]], i32 42) +; CHECK-NEXT: ret { i32, i1 } [[TMP1]] ; - %2 = add nuw nsw i32 %0, 12 - %3 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %2, i32 30) - ret { i32, i1 } %3 + %a = add nuw nsw i32 %x, 12 + %b = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 30) + ret { i32, i1 } %b } -define { i32, i1 } @no_fold_nuw(i32) { +define { i32, i1 } @no_fold_nuw(i32 %x) { ; CHECK-LABEL: @no_fold_nuw( -; CHECK-NEXT: [[TMP2:%.*]] = add nuw i32 [[TMP0:%.*]], 12 -; CHECK-NEXT: [[TMP3:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[TMP2]], i32 30) -; CHECK-NEXT: ret { i32, i1 } [[TMP3]] +; CHECK-NEXT: [[A:%.*]] = add nuw i32 [[X:%.*]], 12 +; CHECK-NEXT: [[B:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[A]], i32 30) +; CHECK-NEXT: ret { i32, i1 } [[B]] ; - %2 = add nuw i32 %0, 12 - %3 = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %2, i32 30) - ret { i32, i1 } %3 + %a = add nuw i32 %x, 12 + %b = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 %a, i32 30) + ret { i32, i1 } %b +} + +define { i32, i1 } @no_fold_wrapped_add(i32 %x) { +; CHECK-LABEL: @no_fold_wrapped_add( +; CHECK-NEXT: [[A:%.*]] = add i32 [[X:%.*]], 12 +; CHECK-NEXT: [[B:%.*]] = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[A]], i32 30) +; CHECK-NEXT: ret { i32, i1 } [[B]] +; + %a = add i32 %x, 12 + %b = tail call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 30, i32 %a) + ret { i32, i1 } %b } diff --git a/llvm/test/Transforms/InstCombine/with_overflow.ll b/llvm/test/Transforms/InstCombine/with_overflow.ll index 267db829ef15e1..c03c3693c0bc2b 100644 --- a/llvm/test/Transforms/InstCombine/with_overflow.ll +++ b/llvm/test/Transforms/InstCombine/with_overflow.ll @@ -468,3 +468,57 @@ define i1 @uadd_res_ult_const_minus_one(i32 %x, i1* %p) nounwind { %d = icmp ult i32 %c, -1 ret i1 %d } + +define { i32, i1 } @sadd_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @sadd_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 [[X:%.*]], i32 42) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.sadd.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +} + +define { i32, i1 } @uadd_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @uadd_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 [[X:%.*]], i32 42) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.uadd.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +} + +define { i32, i1 } @ssub_no_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @ssub_no_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 42, i32 [[X:%.*]]) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.ssub.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +} + +define { i32, i1 } @usub_no_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @usub_no_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 42, i32 [[X:%.*]]) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.usub.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +} + +define { i32, i1 } @smul_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @smul_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 [[X:%.*]], i32 42) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.smul.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +} + +define { i32, i1 } @umul_canonicalize_constant_arg0(i32 %x) nounwind { +; CHECK-LABEL: @umul_canonicalize_constant_arg0( +; CHECK-NEXT: [[A:%.*]] = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 [[X:%.*]], i32 42) +; CHECK-NEXT: ret { i32, i1 } [[A]] +; + %a = call { i32, i1 } @llvm.umul.with.overflow.i32(i32 42, i32 %x) + ret { i32, i1 } %a +}