-
Notifications
You must be signed in to change notification settings - Fork 13.5k
[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?
Conversation
@llvm/pr-subscribers-flang-driver @llvm/pr-subscribers-clang Author: Amit Kumar Pandey (ampandey-1995) ChangesFlang Driver currently dosen't support option sanitizer flags such as '-fsanitize='. This patch currently supports enabling sanitizer flags for the flang driver apart from clang independently. Full diff: https://github.com/llvm/llvm-project/pull/137759.diff 1 Files Affected:
diff --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index e69cd6b833c3a..cde9ff48a58ce 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -2309,7 +2309,7 @@ def fmemory_profile_use_EQ : Joined<["-"], "fmemory-profile-use=">,
// Begin sanitizer flags. These should all be core options exposed in all driver
// modes.
-let Visibility = [ClangOption, CC1Option, CLOption] in {
+let Visibility = [ClangOption, CC1Option, CLOption, FlangOption, FC1Option] in {
def fsanitize_EQ : CommaJoined<["-"], "fsanitize=">, Group<f_clang_Group>,
MetaVarName<"<check>">,
|
Is enabling the flag sufficient? Is there additional work in the Frontend to make this flag and its options useful? |
Flang Driver currently dosen't support option sanitizer flags such as '-fsanitize='. This patch currently supports enabling sanitizer flags for the flang driver apart from clang independently.
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.
Thanks. We should try to share code between clang
and flang
where appropriate.
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 comment
The 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 clang
. If the code is identical to what is in clang
, it should be shared rather than copied. Such code can be moved somewhere in llvm/include/llvm/Frontend
and llvm/lib/Frontend/
. See #136098 for some suggestions. That PR is still awaiting approval from the clang developers, but I don't anticipate any major objections.
#include <optional> | ||
#include <string.h> | ||
|
||
namespace Fortran::frontend { | ||
|
||
using namespace llvm; |
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.
@@ -787,6 +792,11 @@ void CodeGenAction::generateLLVMIR() { | ||
return; | ||
} | ||
|
||
for (llvm::Function &F : llvmModule->getFunctionList()) { |
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 use slightly different coding conventions in flang. In particular, we use camel-casing in most places, so only type names should start with uppercase.
Flang Driver currently dosen't support option sanitizer flags such as '-fsanitize='. This patch currently supports enabling sanitizer flags for the flang driver apart from clang independently.