Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[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

Open
wants to merge 3 commits into
base: main
Choose a base branch
Loading
from

Conversation

ampandey-1995
Copy link
Contributor

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.

@llvmbot llvmbot added the clang Clang issues not falling into any other category label Apr 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Apr 29, 2025

@llvm/pr-subscribers-flang-driver
@llvm/pr-subscribers-clang-driver

@llvm/pr-subscribers-clang

Author: Amit Kumar Pandey (ampandey-1995)

Changes

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.


Full diff: https://github.com/llvm/llvm-project/pull/137759.diff

1 Files Affected:

  • (modified) clang/include/clang/Driver/Options.td (+1-1)
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>">,

@kiranchandramohan
Copy link
Contributor

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.
@llvmbot llvmbot added clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' flang:driver flang Flang issues not falling into any other category labels May 15, 2025
Copy link
Contributor

@tarunprabhu tarunprabhu left a 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.
Copy link
Contributor

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;
Copy link
Contributor

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()) {
Copy link
Contributor

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:driver 'clang' and 'clang++' user-facing binaries. Not 'clang-cl' clang Clang issues not falling into any other category flang:driver flang Flang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.