-
Notifications
You must be signed in to change notification settings - Fork 13.7k
[Flang][Sanitizer] Support sanitizer flag for Flang Driver. #137759
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,17 +11,46 @@ | |
//===----------------------------------------------------------------------===// | ||
|
||
#include "flang/Frontend/CodeGenOptions.h" | ||
#include "llvm/TargetParser/Triple.h" | ||
#include <optional> | ||
#include <string.h> | ||
|
||
namespace Fortran::frontend { | ||
|
||
using namespace llvm; | ||
|
||
CodeGenOptions::CodeGenOptions() { | ||
#define CODEGENOPT(Name, Bits, Default) Name = Default; | ||
#define ENUM_CODEGENOPT(Name, Type, Bits, Default) set##Name(Default); | ||
#include "flang/Frontend/CodeGenOptions.def" | ||
} | ||
|
||
// Check if ASan should use GC-friendly instrumentation for globals. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It looks like this and much of the other code here has been copied from |
||
// First of all, there is no point if -fdata-sections is off (expect for MachO, | ||
// where this is not a factor). Also, on ELF this feature requires an assembler | ||
// extension that only works with -integrated-as at the moment. | ||
bool asanUseGlobalsGC(const Triple &T, const CodeGenOptions &CGOpts) { | ||
if (!CGOpts.SanitizeAddressGlobalsDeadStripping) | ||
return false; | ||
switch (T.getObjectFormat()) { | ||
case Triple::MachO: | ||
case Triple::COFF: | ||
return true; | ||
case Triple::ELF: | ||
return !CGOpts.DisableIntegratedAS; | ||
case Triple::GOFF: | ||
llvm::report_fatal_error("ASan not implemented for GOFF"); | ||
case Triple::XCOFF: | ||
llvm::report_fatal_error("ASan not implemented for XCOFF."); | ||
case Triple::Wasm: | ||
case Triple::DXContainer: | ||
case Triple::SPIRV: | ||
case Triple::UnknownObjectFormat: | ||
break; | ||
} | ||
return false; | ||
} | ||
|
||
std::optional<llvm::CodeModel::Model> getCodeModel(llvm::StringRef string) { | ||
return llvm::StringSwitch<std::optional<llvm::CodeModel::Model>>(string) | ||
.Case("tiny", llvm::CodeModel::Model::Tiny) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We generally do not use
using namespace llvm
in flang.