Commit 7d529ff6 by Antonio Maiorano

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/+/46730Tested-by: 's avatarAntonio Maiorano <amaiorano@google.com> Reviewed-by: 's avatarNicolas Capens <nicolascapens@google.com> Kokoro-Result: kokoro <noreply+kokoro@google.com>
parent 6a6ae44f
...@@ -97,17 +97,15 @@ DebugInfo::DebugInfo( ...@@ -97,17 +97,15 @@ DebugInfo::DebugInfo(
auto file = getOrCreateFile(location.function.file.c_str()); auto file = getOrCreateFile(location.function.file.c_str());
auto sp = diBuilder->createFunction( auto sp = diBuilder->createFunction(
file, // scope file, // scope
"ReactorFunction", // function name "ReactorFunction", // function name
"ReactorFunction", // linkage "ReactorFunction", // linkage
file, // file file, // file
location.line, // line location.line, // line
funcTy, // type funcTy, // type
false, // internal linkage location.line, // scope line
true, // definition DINode::FlagPrototyped, // flags
location.line, // scope line DISubprogram::SPFlagDefinition // subprogram flags
DINode::FlagPrototyped, // flags
false // is optimized
); );
diSubprogram = sp; diSubprogram = sp;
function->setSubprogram(sp); function->setSubprogram(sp);
...@@ -142,6 +140,8 @@ void DebugInfo::Flush() ...@@ -142,6 +140,8 @@ void DebugInfo::Flush()
void DebugInfo::syncScope(Backtrace const &backtrace) void DebugInfo::syncScope(Backtrace const &backtrace)
{ {
using namespace ::llvm;
auto shrink = [this](size_t newsize) { auto shrink = [this](size_t newsize) {
while(diScope.size() > newsize) while(diScope.size() > newsize)
{ {
...@@ -204,17 +204,15 @@ void DebugInfo::syncScope(Backtrace const &backtrace) ...@@ -204,17 +204,15 @@ void DebugInfo::syncScope(Backtrace const &backtrace)
auto name = "jit!" + (status == 0 ? std::string(buf) : location.function.name); auto name = "jit!" + (status == 0 ? std::string(buf) : location.function.name);
auto func = diBuilder->createFunction( auto func = diBuilder->createFunction(
file, // scope file, // scope
name, // function name name, // function name
"", // linkage "", // linkage
file, // file file, // file
location.line, // line location.line, // line
funcTy, // type funcTy, // type
false, // internal linkage location.line, // scope line
true, // definition DINode::FlagPrototyped, // flags
location.line, // scope line DISubprogram::SPFlagDefinition // subprogram flags
llvm::DINode::FlagPrototyped, // flags
false // is optimized
); );
diScope.push_back({ location, func }); diScope.push_back({ location, func });
LOG("+ STACK(%d): di: %p, location: %s:%d", int(i), di, LOG("+ STACK(%d): di: %p, location: %s:%d", int(i), di,
...@@ -381,13 +379,15 @@ void DebugInfo::emitPending(Scope &scope, IRBuilder *builder) ...@@ -381,13 +379,15 @@ void DebugInfo::emitPending(Scope &scope, IRBuilder *builder)
void DebugInfo::NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L) void DebugInfo::NotifyObjectEmitted(const llvm::object::ObjectFile &Obj, const llvm::LoadedObjectInfo &L)
{ {
std::unique_lock<std::mutex> lock(jitEventListenerMutex); 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) void DebugInfo::NotifyFreeingObject(const llvm::object::ObjectFile &Obj)
{ {
std::unique_lock<std::mutex> lock(jitEventListenerMutex); std::unique_lock<std::mutex> lock(jitEventListenerMutex);
jitEventListener->NotifyFreeingObject(Obj); auto key = reinterpret_cast<llvm::JITEventListener::ObjectKey>(&Obj);
jitEventListener->notifyFreeingObject(key);
} }
void DebugInfo::registerBasicTypes() void DebugInfo::registerBasicTypes()
......
...@@ -53,16 +53,14 @@ cmake --build . --target ReactorUnitTests -- -j $(nproc) ...@@ -53,16 +53,14 @@ cmake --build . --target ReactorUnitTests -- -j $(nproc)
cd .. cd ..
build/ReactorUnitTests --gtest_filter=ReactorUnitTests.Print* build/ReactorUnitTests --gtest_filter=ReactorUnitTests.Print*
if [ "${LLVM_VERSION}" -ne "10.0" ]; then # Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds
# Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds cd build
cd build cmake .. "-DREACTOR_EMIT_DEBUG_INFO=1"
cmake .. "-DREACTOR_EMIT_DEBUG_INFO=1" cmake --build . --target ReactorUnitTests -- -j $(nproc)
cmake --build . --target ReactorUnitTests -- -j $(nproc) cd ..
cd ..
# Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds # Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
cd build cd build
cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=1" cmake .. "-DREACTOR_EMIT_PRINT_LOCATION=1"
cmake --build . --target ReactorUnitTests -- -j $(nproc) cmake --build . --target ReactorUnitTests -- -j $(nproc)
cd .. cd ..
fi
...@@ -43,17 +43,15 @@ cmake --build . --target ReactorUnitTests || goto :error ...@@ -43,17 +43,15 @@ cmake --build . --target ReactorUnitTests || goto :error
cd %SRC% || goto :error cd %SRC% || goto :error
build\Debug\ReactorUnitTests.exe --gtest_filter=ReactorUnitTests.Print* || 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
REM Incrementally build with REACTOR_EMIT_DEBUG_INFO to ensure it builds cd %SRC%\build || goto :error
cd %SRC%\build || goto :error cmake "-DREACTOR_EMIT_DEBUG_INFO=1" .. || goto :error
cmake "-DREACTOR_EMIT_DEBUG_INFO=1" .. || goto :error cmake --build . --target ReactorUnitTests || goto :error
cmake --build . --target ReactorUnitTests || goto :error
REM Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds
REM Incrementally build with REACTOR_EMIT_PRINT_LOCATION to ensure it builds cd %SRC%\build || goto :error
cd %SRC%\build || goto :error cmake "-REACTOR_EMIT_PRINT_LOCATION=1" .. || goto :error
cmake "-REACTOR_EMIT_PRINT_LOCATION=1" .. || goto :error cmake --build . --target ReactorUnitTests || goto :error
cmake --build . --target ReactorUnitTests || goto :error
)
exit /b 0 exit /b 0
......
...@@ -384,6 +384,7 @@ set(LLVM_LIST ...@@ -384,6 +384,7 @@ set(LLVM_LIST
${LLVM_DIR}/lib/DebugInfo/DWARF/DWARFVerifier.cpp ${LLVM_DIR}/lib/DebugInfo/DWARF/DWARFVerifier.cpp
${LLVM_DIR}/lib/Demangle/ItaniumDemangle.cpp ${LLVM_DIR}/lib/Demangle/ItaniumDemangle.cpp
${LLVM_DIR}/lib/ExecutionEngine/ExecutionEngine.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/CompileUtils.cpp
${LLVM_DIR}/lib/ExecutionEngine/Orc/Core.cpp ${LLVM_DIR}/lib/ExecutionEngine/Orc/Core.cpp
${LLVM_DIR}/lib/ExecutionEngine/Orc/IRCompileLayer.cpp ${LLVM_DIR}/lib/ExecutionEngine/Orc/IRCompileLayer.cpp
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment