Fix ENABLE_RR_DEBUG_INFO on LLVM 10
The LLVM debugging API changed since LLVM 7. Updated the code to work
with the new API.
Also enabled Kokoro builds with REACTOR_EMIT_DEBUG_INFO and
REACTOR_EMIT_PRINT_LOCATION on LLVM 10.
Bug: b/152339534
Change-Id: Ia3af789077842013aad74ac8af5f3e5582801963
Reviewed-on: https://swiftshader-review.googlesource.com/c/SwiftShader/+/46730
Tested-by: Antonio Maiorano <amaiorano@google.com>
Reviewed-by: Nicolas Capens <nicolascapens@google.com>
Kokoro-Result: kokoro <noreply+kokoro@google.com>
diff --git a/src/Reactor/LLVMReactorDebugInfo.cpp b/src/Reactor/LLVMReactorDebugInfo.cpp
index 2a5e157..04c12e5 100644
--- a/src/Reactor/LLVMReactorDebugInfo.cpp
+++ b/src/Reactor/LLVMReactorDebugInfo.cpp
@@ -97,17 +97,15 @@
auto file = getOrCreateFile(location.function.file.c_str());
auto sp = diBuilder->createFunction(
- file, // scope
- "ReactorFunction", // function name
- "ReactorFunction", // linkage
- file, // file
- location.line, // line
- funcTy, // type
- false, // internal linkage
- true, // definition
- location.line, // scope line
- DINode::FlagPrototyped, // flags
- false // is optimized
+ file, // scope
+ "ReactorFunction", // function name
+ "ReactorFunction", // linkage
+ file, // file
+ location.line, // line
+ funcTy, // type
+ location.line, // scope line
+ DINode::FlagPrototyped, // flags
+ DISubprogram::SPFlagDefinition // subprogram flags
);
diSubprogram = sp;
function->setSubprogram(sp);
@@ -142,6 +140,8 @@
void DebugInfo::syncScope(Backtrace const &backtrace)
{
+ using namespace ::llvm;
+
auto shrink = [this](size_t newsize) {
while(diScope.size() > newsize)
{
@@ -204,17 +204,15 @@
auto name = "jit!" + (status == 0 ? std::string(buf) : location.function.name);
auto func = diBuilder->createFunction(
- file, // scope
- name, // function name
- "", // linkage
- file, // file
- location.line, // line
- funcTy, // type
- false, // internal linkage
- true, // definition
- location.line, // scope line
- llvm::DINode::FlagPrototyped, // flags
- false // is optimized
+ file, // scope
+ name, // function name
+ "", // linkage
+ file, // file
+ location.line, // line
+ funcTy, // type
+ location.line, // scope line
+ DINode::FlagPrototyped, // flags
+ DISubprogram::SPFlagDefinition // subprogram flags
);
diScope.push_back({ location, func });
LOG("+ STACK(%d): di: %p, location: %s:%d", int(i), di,
@@ -381,13 +379,15 @@
void DebugInfo::NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L)
{
std::unique_lock<std::mutex> lock(jitEventListenerMutex);
- jitEventListener->NotifyObjectEmitted(Obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo &>(L));
+ auto key = reinterpret_cast<llvm::JITEventListener::ObjectKey>(&Obj);
+ jitEventListener->notifyObjectLoaded(key, Obj, static_cast<const llvm::RuntimeDyld::LoadedObjectInfo &>(L));
}
void DebugInfo::NotifyFreeingObject(const llvm::object::ObjectFile &Obj)
{
std::unique_lock<std::mutex> lock(jitEventListenerMutex);
- jitEventListener->NotifyFreeingObject(Obj);
+ auto key = reinterpret_cast<llvm::JITEventListener::ObjectKey>(&Obj);
+ jitEventListener->notifyFreeingObject(key);
}
void DebugInfo::registerBasicTypes()
diff --git a/tests/kokoro/gcp_ubuntu/continuous.sh b/tests/kokoro/gcp_ubuntu/continuous.sh
index 481ec8e..055fcfc 100755
--- a/tests/kokoro/gcp_ubuntu/continuous.sh
+++ b/tests/kokoro/gcp_ubuntu/continuous.sh
@@ -53,16 +53,14 @@
cd ..
build/ReactorUnitTests --gtest_filter=ReactorUnitTests.Print*
-if [ "${LLVM_VERSION}" -ne "10.0" ]; then
- # Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds
- cd build
- cmake .. "-DREACTOR_EMIT_DEBUG_INFO=1"
- cmake --build . --target ReactorUnitTests -- -j $(nproc)
- cd ..
+# Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds
+cd build
+cmake .. "-DREACTOR_EMIT_DEBUG_INFO=1"
+cmake --build . --target ReactorUnitTests -- -j $(nproc)
+cd ..
- # Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
- cd build
- cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=1"
- cmake --build . --target ReactorUnitTests -- -j $(nproc)
- cd ..
-fi
+# Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
+cd build
+cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=1"
+cmake --build . --target ReactorUnitTests -- -j $(nproc)
+cd ..
diff --git a/tests/kokoro/gcp_windows/continuous.bat b/tests/kokoro/gcp_windows/continuous.bat
index 8603840..930dae8 100644
--- a/tests/kokoro/gcp_windows/continuous.bat
+++ b/tests/kokoro/gcp_windows/continuous.bat
@@ -43,17 +43,15 @@
cd %SRC% || goto :error
build\Debug\ReactorUnitTests.exe --gtest_filter=ReactorUnitTests.Print* || goto :error
-IF NOT "%LLVM_VERSION%"=="10.0" (
- REM Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds
- cd %SRC%\build || goto :error
- cmake "-DREACTOR_EMIT_DEBUG_INFO=1" .. || goto :error
- cmake --build . --target ReactorUnitTests || goto :error
+REM Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds
+cd %SRC%\build || goto :error
+cmake "-DREACTOR_EMIT_DEBUG_INFO=1" .. || goto :error
+cmake --build . --target ReactorUnitTests || goto :error
- REM Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
- cd %SRC%\build || goto :error
- cmake "-REACTOR_EMIT_PRINT_LOCATION=1" .. || goto :error
- cmake --build . --target ReactorUnitTests || goto :error
-)
+REM Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
+cd %SRC%\build || goto :error
+cmake "-REACTOR_EMIT_PRINT_LOCATION=1" .. || goto :error
+cmake --build . --target ReactorUnitTests || goto :error
exit /b 0
diff --git a/third_party/llvm-10.0/CMakeLists.txt b/third_party/llvm-10.0/CMakeLists.txt
index b1424ef..c5e1a86 100644
--- a/third_party/llvm-10.0/CMakeLists.txt
+++ b/third_party/llvm-10.0/CMakeLists.txt
@@ -384,6 +384,7 @@
${LLVM_DIR}/lib/DebugInfo/DWARF/DWARFVerifier.cpp
${LLVM_DIR}/lib/Demangle/ItaniumDemangle.cpp
${LLVM_DIR}/lib/ExecutionEngine/ExecutionEngine.cpp
+ ${LLVM_DIR}/lib/ExecutionEngine/GDBRegistrationListener.cpp
${LLVM_DIR}/lib/ExecutionEngine/Orc/CompileUtils.cpp
${LLVM_DIR}/lib/ExecutionEngine/Orc/Core.cpp
${LLVM_DIR}/lib/ExecutionEngine/Orc/IRCompileLayer.cpp