diff --git a/Bitcode/Regression/CMakeLists.txt b/Bitcode/Regression/CMakeLists.txt index d37f61ee34..e4303b926e 100644 --- a/Bitcode/Regression/CMakeLists.txt +++ b/Bitcode/Regression/CMakeLists.txt @@ -9,4 +9,7 @@ if(ARCH STREQUAL "x86") NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0") add_subdirectory(fft) endif() + + # E2E regression tests from SAP + add_subdirectory(sap_fct_splitting) endif() diff --git a/Bitcode/Regression/sap_fct_splitting/CMakeLists.txt b/Bitcode/Regression/sap_fct_splitting/CMakeLists.txt new file mode 100644 index 0000000000..4bd61b8ad0 --- /dev/null +++ b/Bitcode/Regression/sap_fct_splitting/CMakeLists.txt @@ -0,0 +1,7 @@ +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/sap_fct_splitting.bc PROPERTIES LANGUAGE C) +SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/mocks.c PROPERTIES LANGUAGE C) + +llvm_multisource(sap_fct_splitting + ${CMAKE_CURRENT_SOURCE_DIR}/sap_fct_splitting.bc + ${CMAKE_CURRENT_SOURCE_DIR}/mocks.c +) diff --git a/Bitcode/Regression/sap_fct_splitting/README.md b/Bitcode/Regression/sap_fct_splitting/README.md new file mode 100644 index 0000000000..7fe49d9e0d --- /dev/null +++ b/Bitcode/Regression/sap_fct_splitting/README.md @@ -0,0 +1,33 @@ +# SAP function splitting regression test + +## Purpose +This tests the correct compilation of `indirectbr` and `blockaddr` in combination with custom cost-based function outlining. + +## Regenerate bitcode file +This bitcode test was generated from this high level program: + +``` +Int32 main() { + Bool x; + Int32 counter = test::produce(5); + while (counter < 10) { + counter++; +// Creation of subfunction forced here - start + if (counter >= 8) { + break; // triggers indirectbr + } else if (counter >= 4) { + continue; // triggers indirectbr + } +// Creation of subfunction forced here - end + test::consume(counter); + } + return 1; +} + +``` + +convert IR to bitcode using this command: + +```sh +llvm-as -o +``` diff --git a/Bitcode/Regression/sap_fct_splitting/mocks.c b/Bitcode/Regression/sap_fct_splitting/mocks.c new file mode 100644 index 0000000000..79f2515d02 --- /dev/null +++ b/Bitcode/Regression/sap_fct_splitting/mocks.c @@ -0,0 +1,20 @@ +#include + +typedef char* opaque_ptr; + +// Globals +opaque_ptr _debugInfo = 0; +opaque_ptr _sourceCodeObj = 0; + +// Mock functions +uint64_t llangStackTracePushVoid(opaque_ptr context, uint32_t lineNumber, uint64_t returnCode, opaque_ptr literal, opaque_ptr debugInfo, opaque_ptr sourceCodeObj) { + return 0; +} + +int64_t llangTestProduce(opaque_ptr obj, int64_t input) { + return input; +} + +int64_t llangTestConsume(opaque_ptr obj, int64_t input) { + return input; +} diff --git a/Bitcode/Regression/sap_fct_splitting/sap_fct_splitting.bc b/Bitcode/Regression/sap_fct_splitting/sap_fct_splitting.bc new file mode 100644 index 0000000000..88413bdf83 Binary files /dev/null and b/Bitcode/Regression/sap_fct_splitting/sap_fct_splitting.bc differ