Skip to content

Commit 6241e63

Browse files
authored
[RegressionTest] Add bitcode E2E test by SAP for cost-based function outlining with indirectbr/blockaddr (#293)
* Add regression bitcode test for SAP usecase * Add purpose section to README of test * Apply feedback * Delete ll file * Rephase purpose * Remove llvm-as section in README
1 parent 47075dc commit 6241e63

File tree

5 files changed

+57
-0
lines changed

5 files changed

+57
-0
lines changed

Bitcode/Regression/CMakeLists.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,7 @@ if(ARCH STREQUAL "x86")
99
NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "5.0")
1010
add_subdirectory(fft)
1111
endif()
12+
13+
# E2E regression tests from SAP
14+
add_subdirectory(sap_fct_splitting)
1215
endif()
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/sap_fct_splitting.bc PROPERTIES LANGUAGE C)
2+
SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/mocks.c PROPERTIES LANGUAGE C)
3+
4+
llvm_multisource(sap_fct_splitting
5+
${CMAKE_CURRENT_SOURCE_DIR}/sap_fct_splitting.bc
6+
${CMAKE_CURRENT_SOURCE_DIR}/mocks.c
7+
)
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SAP function splitting regression test
2+
3+
## Purpose
4+
This tests the correct compilation of `indirectbr` and `blockaddr` in combination with custom cost-based function outlining.
5+
6+
## Produce bitcode file
7+
This bitcode test was generated from this high level program:
8+
9+
```
10+
Int32 main() {
11+
Bool x;
12+
Int32 counter = test::produce(5);
13+
while (counter < 10) {
14+
counter++;
15+
// Creation of subfunction forced here - start
16+
if (counter >= 8) {
17+
break; // triggers indirectbr
18+
} else if (counter >= 4) {
19+
continue; // triggers indirectbr
20+
}
21+
// Creation of subfunction forced here - end
22+
test::consume(counter);
23+
}
24+
return 1;
25+
}
26+
27+
```
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
#include <stdint.h>
2+
3+
typedef char* opaque_ptr;
4+
5+
// Globals
6+
opaque_ptr _debugInfo = 0;
7+
opaque_ptr _sourceCodeObj = 0;
8+
9+
// Mock functions
10+
uint64_t llangStackTracePushVoid(opaque_ptr context, uint32_t lineNumber, uint64_t returnCode, opaque_ptr literal, opaque_ptr debugInfo, opaque_ptr sourceCodeObj) {
11+
return 0;
12+
}
13+
14+
int64_t llangTestProduce(opaque_ptr obj, int64_t input) {
15+
return input;
16+
}
17+
18+
int64_t llangTestConsume(opaque_ptr obj, int64_t input) {
19+
return input;
20+
}
3.71 KB
Binary file not shown.

0 commit comments

Comments
 (0)