Skip to content

Commit 4d0836b

Browse files
authored
Lower -profiling option to -debug-info-kind=line-tables-only (#395)
* Lower -profiling option to -debug-info-kind=line-tables-only '-profiling' option aims source code view under VTune. Turning it on means that debug information will be generated and all optimizations will be made. Most of OpenCL transformation passes (vectorizer, barrier, etc.) work with debug information too offhandedly. To minimize risks to get debug information broken, let's generate it as less as possible. The patch also does other several things: 1. Update minimum cmake version to 3.13.4 to align with LLVM's cmake requirement. 2. Remove unused header and format code 3. Fix some build warnings * Add -gno-column-info option for Windows. It's the follow up for preview patch to remove dwarf-column-info. On windows the presence of column info in the debug info causes undesirable stepping behavior in the Visual Studio debugger.
1 parent 1c91f98 commit 4d0836b

File tree

6 files changed

+20
-16
lines changed

6 files changed

+20
-16
lines changed

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.4.3)
1+
cmake_minimum_required(VERSION 3.13.4)
22

33
if(NOT DEFINED BASE_LLVM_VERSION)
44
set(BASE_LLVM_VERSION 16.0.0)
@@ -84,6 +84,8 @@ if (NOT WIN32)
8484
add_subdirectory( linux_linker bin)
8585
endif()
8686

87+
use_rtti(FALSE)
88+
8789
if (CMAKE_SIZEOF_VOID_P EQUAL 4)
8890
set(ADDR 32)
8991
else ()

cl_headers/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ add_custom_target (
101101
function(pack_to_obj SRC DST TAG)
102102
add_custom_command (
103103
OUTPUT ${DST}
104-
DEPENDS ${SRC} linux_resource_linker
104+
DEPENDS ${SRC} ${LINUX_RESOURCE_LINKER_COMMAND}
105105
COMMAND ${LINUX_RESOURCE_LINKER_COMMAND} "${SRC}" "${DST}" "${TAG}"
106106
COMMENT "Packing ${SRC}"
107107
)

common_clang.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ Copyright (c) Intel Corporation (2009-2017).
4040
#include "llvm/Support/TargetSelect.h"
4141
#include "llvm/Support/ManagedStatic.h"
4242
#include "llvm/Support/Mutex.h"
43-
#include "llvm/Support/VirtualFileSystem.h"
4443
#include "clang/Basic/LangOptions.h"
4544
#include "clang/Basic/Diagnostic.h"
4645
#include "clang/Basic/DiagnosticIDs.h"
@@ -63,11 +62,8 @@ Copyright (c) Intel Corporation (2009-2017).
6362
#define CL_OUT_OF_HOST_MEMORY -6
6463

6564
#include "assert.h"
66-
#include <algorithm>
6765
#include <iosfwd>
6866
#include <iterator>
69-
#include <list>
70-
#include <streambuf>
7167
#ifdef _WIN32
7268
#include <ctype.h>
7369
#endif
@@ -265,8 +261,6 @@ Compile(const char *pszProgramSource, const char **pInputHeaders,
265261
ProcessWarningOptions(*Diags, compiler->getDiagnosticOpts());
266262

267263
// Map memory buffers to a virtual file system
268-
269-
// Source file
270264
MemFS->addFile(
271265
optionsParser.getSourceName(), (time_t)0,
272266
llvm::MemoryBuffer::getMemBuffer(

options.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ class OpenCLArgList : public llvm::opt::ArgList {
7171

7272
const char *MakeArgStringRef(llvm::StringRef str) const override;
7373

74+
virtual ~OpenCLArgList() {}
75+
7476
private:
7577
/// List of argument strings used by the contained Args.
7678
///
@@ -93,10 +95,10 @@ class OpenCLArgList : public llvm::opt::ArgList {
9395
//
9496
// OpenCL specific OptTable
9597
//
96-
class OpenCLOptTable : public llvm::opt::OptTable {
98+
class OpenCLOptTable : public llvm::opt::GenericOptTable {
9799
public:
98100
OpenCLOptTable(llvm::ArrayRef<Info> pOptionInfos)
99-
: OptTable(pOptionInfos) {}
101+
: llvm::opt::GenericOptTable(pOptionInfos) {}
100102

101103
OpenCLArgList *ParseArgs(const char *szOptions, unsigned &missingArgIndex,
102104
unsigned &missingArgCount) const;

options_compile.cpp

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,18 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
158158
// default:
159159
// assert(false && "some unknown argument");
160160
case OPT_COMPILE_profiling:
161-
case OPT_COMPILE_g_Flag:
162-
effectiveArgs.push_back("-debug-info-kind=limited");
163-
effectiveArgs.push_back("-dwarf-version=4");
164-
break;
165161
case OPT_COMPILE_gline_tables_only_Flag:
166162
effectiveArgs.push_back("-debug-info-kind=line-tables-only");
167163
effectiveArgs.push_back("-dwarf-version=4");
168164
break;
165+
case OPT_COMPILE_g_Flag:
166+
effectiveArgs.push_back("-debug-info-kind=limited");
167+
effectiveArgs.push_back("-dwarf-version=4");
168+
#ifdef _WIN32
169+
// Do not use column information on Windows.
170+
effectiveArgs.push_back("-gno-column-info");
171+
#endif
172+
break;
169173
}
170174
}
171175

@@ -221,7 +225,7 @@ std::string EffectiveOptionsFilter::processOptions(const OpenCLArgList &args,
221225
// OpenCL v2.0 s6.9.u - Implicit function declaration is not supported.
222226
// Behavior of clang is changed and now there is only warning about
223227
// implicit function declarations. To be more user friendly and avoid
224-
// unexpected indirect function calls in IR, let's force this warning to
228+
// unexpected indirect function calls in BE, let's force this warning to
225229
// error.
226230
effectiveArgs.push_back("-Werror=implicit-function-declaration");
227231

pch_mgr.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ Copyright (c) Intel Corporation (2009-2017).
1818

1919
#include "pch_mgr.h"
2020

21-
#include "llvm/Object/ELF.h"
2221
#include "llvm/ADT/Twine.h"
22+
#include "llvm/Object/ELF.h"
2323

2424
#include <cstdlib>
2525
#include <stdio.h>
@@ -35,6 +35,8 @@ struct auto_dlclose {
3535
auto_dlclose(void *module) : m_pModule(module) {}
3636

3737
~auto_dlclose() {
38+
if (m_pModule)
39+
dlclose(m_pModule);
3840
}
3941

4042
void *get() { return m_pModule; }

0 commit comments

Comments
 (0)