Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for custom allocators #390

Merged
merged 15 commits into from
Jul 6, 2017
Merged

Conversation

marcelolr
Copy link
Contributor

This is a big change that cleans up various aspects of memory management and adds support for memory allocators to be passed into the library.

There is a new entry point into dxcompiler, DxcCreateInstance2, which allows for the caller to provide an IMalloc implementation that will be used for all memory operations involving calls into that object. In support of this, the following changes are made.

  • On-demand global initialization from statistics is disabled.
  • operator new and operator delete are overridden to use the current call's allocator, stored in thread-local storage
  • A number of functions and RAII classes are added to work with this TLS-based allocator.
  • Objects that might outlive a call (include all top-level objects and blobs) now hold onto their allocator.
  • Exception handling has been cleaned up so memory is released properly and state is consistent while processing exceptions.

There is likely more work to be done on cleaning up in exception paths properly in the presence of bad_alloc exceptions, but this is a step in the right direction.

This capability allows the compiler and its component libraries to be used in scenarios where memory allocation policy is directed by the application, for example by limiting the maximum available memory, allocating with some particular book-keeping strategy, or using a specific area of memory.

@AppVeyorBot
Copy link

cl::desc("Maximum number of iterations SCEV will "
"symbolically execute a constant "
"derived loop"),
cl::init(100));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintended indentation changes?

"No vector functions library"),
clEnumValN(TargetLibraryInfoImpl::Accelerate, "Accelerate",
"Accelerate framework"),
clEnumValEnd));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More indent changes.

/// Enable an experimental feature to leverage information about dominating
/// conditions to compute known bits. The individual options below control how
/// hard we search. The defaults are choosen to be fairly aggressive. If you
/// run into compile time problems when testing, scale them back and report
/// your findings.
static cl::opt<bool> EnableDomConditions("value-tracking-dom-conditions",
cl::Hidden, cl::init(false));
cl::Hidden, cl::init(false));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More indent changes and below..

clEnumValN(Region::PrintRN, "rn",
"print regions in detail with element_iterator"),
"print regions in detail with element_iterator"),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indent changes...

static cl::opt<bool>
Delinearize("da-delinearize", cl::init(false), cl::Hidden, cl::ZeroOrMore,
cl::desc("Try to delinearize array references."));
cl::desc("Try to delinearize array references."));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unintended indent change?

unsigned Column) {
const std::string &Filename,
unsigned Line,
unsigned Column) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

More indent changes

llvm::outs()));
Loc.FileName, Loc.Line, Loc.Column,
getFrontendOpts().CodeCompleteOpts,
llvm::outs()));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent

Loc.Line, Loc.Column)) {
}
else if (EnableCodeCompletion(getPreprocessor(), Loc.FileName,
Loc.Line, Loc.Column)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formatting/indent

unsigned Line,
unsigned Column,
const CodeCompleteOptions &Opts,
raw_ostream &OS) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indent-only changes here and above/below

@@ -147,7 +148,13 @@ bool VersionSupportInfo::SkipDxil_1_1_Test() {
}
return false;
}

bool VersionSupportInfo::SkipOutOfMemoryTest() {
if (m_CompilerPreservesBBNames) { // same detection logic at the moment
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should probably just rename this member to m_CompilerIsDebugBuild or something, since that's what it really tracks.

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@AppVeyorBot
Copy link

@marcelolr marcelolr merged commit d5bb308 into microsoft:master Jul 6, 2017
@marcelolr marcelolr deleted the mruiz_mem branch July 6, 2017 23:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants