- 
                Notifications
    
You must be signed in to change notification settings  - Fork 794
 
[SYCL] Don't print the header and footer in the preprocessed output. #15634
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
Conversation
| @@ -0,0 +1,86 @@ | |||
| /// Check compilation tool steps when using the integration footer | |||
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.
Test name is sycl-int-header.cpp but comments in the test are checking for the footer, but the tests themselves are checking for both.  Can this ben cleaned up?
| } | ||
| 
               | 
          ||
| // Add the -include-footer option to add the integration footer | ||
| // Add the -include-internal-footer option to add the integration footer | 
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.
Nit: Add the comment inside the 'if' construct so that it reads similar to the
'header' option?
        
          
                llvm/include/llvm/Support/Path.h
              
                Outdated
          
        
      | /// | ||
| /// @param path Input path. | ||
| /// @result The cleaned-up \a path. | ||
| StringRef remove_leading_dotbackslah(StringRef path); | 
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.
| StringRef remove_leading_dotbackslah(StringRef path); | |
| StringRef remove_leading_dotbackslash(StringRef path); | 
        
          
                llvm/lib/Support/Path.cpp
              
                Outdated
          
        
      | return Path; | ||
| } | ||
| 
               | 
          ||
| StringRef remove_leading_dotbackslah(StringRef Path) { | 
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.
| StringRef remove_leading_dotbackslah(StringRef Path) { | |
| StringRef remove_leading_dotbackslash(StringRef Path) { | 
| OS->write_escaped(CurFilename); | ||
| *OS << '"'; | ||
| StringRef CurFilenameWithNoLeaningDotSlash = | ||
| llvm::sys::path::remove_leading_dotbackslah(CurFilename.str()); | 
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.
| llvm::sys::path::remove_leading_dotbackslah(CurFilename.str()); | |
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | 
| unsigned ExtraLen) { | ||
| startNewLineIfNeeded(); | ||
| 
               | 
          ||
| // Emit #line directives or GNU line markers depending on what mode we're in. | 
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.
May be comment should be moved a bit down?
| MetaVarName<"<file>">, HelpText<"Include file before parsing">, | ||
| Visibility<[ClangOption, CC1Option]>; | ||
| def include_footer : Separate<["-"], "include-footer">, Group<clang_i_Group>, | ||
| def include_internal_footer : Separate<["-"], "include-internal-footer">, Group<clang_i_Group>, | 
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.
Is there a possibility where we want to include header and not footer...or the other way around? Just wondering if we need two options here.
Thanks
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.
Good question. @premanandrao What do you think?
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.
The behavior of -include-internal-header and -include-internal-footer is more than just the ability to pass in a file to be included, it also designates where in the preprocessing the file is expanded, so we need to have 2 options.
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 Mike!
| if (types::getPreprocessedType(Input.getType()) != types::TY_INVALID && | ||
| !Args.hasArg(options::OPT_fno_sycl_use_footer) && !Footer.empty()) { | ||
| CmdArgs.push_back("-include-footer"); | ||
| // Add the -include-internal-footer option to add the integration foote | 
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.
| // Add the -include-internal-footer option to add the integration foote | |
| // Add the -include-internal-footer option to add the integration footer | 
| AddImplicitInclude(Builder, Path); | ||
| } | ||
| 
               | 
          ||
| // Process -include-internal-header directive. | 
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.
Is this comment accurate? Is the 'processing' happening inside the function call?
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.
Yes. A #include header.h is added to the stream.
| if (value == '\\') | ||
| return true; | ||
| return false; | 
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.
| if (value == '\\') | |
| return true; | |
| return false; | |
| return value == '\\'; | 
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.
Minor nits. Overall looks good. Thanks
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.
LGTM. Thanks
| 
           @intel/dpcpp-cfe-reviewers can you please review this? Thanks.  | 
    
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.
@premanandrao can you please take a look at this? I believe you reviewed previous versions of this functionality.
| StringRef CurFilenameWithNoLeaningDotSlash = | ||
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | ||
| if ((CurFilenameWithNoLeaningDotSlash == | ||
| PP.getPreprocessorOpts().IncludeFooter) || | ||
| CurFilenameWithNoLeaningDotSlash == | 
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.
| StringRef CurFilenameWithNoLeaningDotSlash = | |
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | |
| if ((CurFilenameWithNoLeaningDotSlash == | |
| PP.getPreprocessorOpts().IncludeFooter) || | |
| CurFilenameWithNoLeaningDotSlash == | |
| StringRef CurFilenameWithNoLeadingDotSlash = | |
| llvm::sys::path::remove_leading_dotbackslash(CurFilename.str()); | |
| if ((CurFilenameWithNoLeadingDotSlash == | |
| PP.getPreprocessorOpts().IncludeFooter) || | |
| CurFilenameWithNoLeadingDotSlash == | 
| PP.getPreprocessorOpts().IncludeHeader) { | ||
| CurFilename = "<uninit>"; | ||
| } | ||
| // Emit #line directives or GNU line markers depending on what mode we're in. | 
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.
The indentation starting this line seems off to me. Please check.
| int bar() { return 21; } | ||
| 
               | 
          ||
| // CHECK: # 21 "" | ||
| // CHECK: # 1 "[[INPUT:.+\.c]]" 2 | 
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.
What is this line for?
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.
This is for the empty line. Fixed that.
| Path = Path.substr(2); | ||
| return Path; | ||
| } | ||
| 
               | 
          
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.
Instead of a new routine, can remove_leading_dotslash be reused with the appropriate Style?
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's not the Style argument that's the issue, it's the call to is_separator that would make the change more complicated than it should be. Furthermore, we only need to check if we have the .\\ at the beginning of the string, no need to visit the entire string which is what remove_leading_dotslash is doing.
But I can make the change if you don't want to see this additional function.
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.
I see. You specifically don't want the loop? In that case, I am fine with your new function - except maybe give it a distinct name, so the leading vs all distinction is clear.
How about something like: remove_leading_dotbackslash_only?   Just a suggestion.  Please pick a spelling that sounds good to you.
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.
Sure. I can name it that way. Thanks.
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.
Just one minor nit. Other than that, looks good.
| startNewLineIfNeeded(); | ||
| 
               | 
          ||
| if (PP.getLangOpts().isSYCL()) { | ||
| StringRef CurFilenameWithNoLeadingDotSlash = | 
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.
Indentation.
| 
           @intel/llvm-gatekeepers Can this be merged in please? Thanks.  | 
    
This is needed to support compilation with
ccache.When compiling with
ccache, the integration header and footer shouldn't be printed in the pre-processed output to not confuseccache. In order to do that we added a new option calledinclude-internal-footerto include the integration footer. For consistency theincludeoption, that was including the integration header was renamed-include-internal-header.