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

Fix for top-of-tree LLVM #6386

Merged
merged 3 commits into from
Nov 3, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 17 additions & 8 deletions src/CodeGen_LLVM.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1159,21 +1159,30 @@ void CodeGen_LLVM::optimize_module() {
#endif
pb.registerOptimizerLastEPCallback(
[](ModulePassManager &mpm, OptimizationLevel level) {
#if LLVM_VERSION >= 140
AddressSanitizerOptions asan_options; // default values are good...
asan_options.UseAfterScope = true; // ... except this one
Copy link
Member

Choose a reason for hiding this comment

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

I assume you're just basing it off the existing code, but do we know why UseAfterScope is true? Would be good to elaborate in the comment if so.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do not know.

mpm.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(asan_options)));
#else
constexpr bool compile_kernel = false;
constexpr bool recover = false;
constexpr bool use_after_scope = true;
#if LLVM_VERSION >= 140
// TODO: this is the value that the default ctor uses.
// Not sure if it's ideal for Halide.
constexpr AsanDetectStackUseAfterReturnMode use_after_return = AsanDetectStackUseAfterReturnMode::Runtime;
mpm.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
AddressSanitizerOptions{compile_kernel, recover, use_after_scope, use_after_return})));
#else
mpm.addPass(createModuleToFunctionPassAdaptor(AddressSanitizerPass(
compile_kernel, recover, use_after_scope)));
#endif
});
#if LLVM_VERSION >= 120
#if LLVM_VERSION >= 140
pb.registerPipelineStartEPCallback(
[](ModulePassManager &mpm, OptimizationLevel) {
AddressSanitizerOptions asan_options; // default values are good
constexpr bool use_global_gc = true;
constexpr bool use_odr_indicator = true;
constexpr auto destructor_kind = AsanDtorKind::Global;
mpm.addPass(ModuleAddressSanitizerPass(
asan_options, use_global_gc,
use_odr_indicator, destructor_kind));
});
#elif LLVM_VERSION >= 120
pb.registerPipelineStartEPCallback(
[](ModulePassManager &mpm, OptimizationLevel) {
constexpr bool compile_kernel = false;
Expand Down