Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Bitcode/Regression/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
7 changes: 7 additions & 0 deletions Bitcode/Regression/sap_fct_splitting/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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
)
33 changes: 33 additions & 0 deletions Bitcode/Regression/sap_fct_splitting/README.md
Original file line number Diff line number Diff line change
@@ -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 <ir-file> -o <bitcode-file>
```
20 changes: 20 additions & 0 deletions Bitcode/Regression/sap_fct_splitting/mocks.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#include <stdint.h>

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;
}
Binary file not shown.