Skip to content

[SYCL] Fix debug info generation when integration footer is present #6774

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

Merged
merged 9 commits into from
Sep 29, 2022

Conversation

zahiraam
Copy link
Contributor

@zahiraam zahiraam commented Sep 13, 2022

This patch is to fix two known issues with debugging caused by integration footer presence, without redesigning the integration footer approach.
One issue is the missing checksum for the main file on Windows. This causes the breakpoints not being hit.
The other issue being that the host compilation's DICompileUnit points to the temporary
file created instead of the original source file. So file names and checksums are different for host and compilation.

The changes made to fix the issues are:

  1. Driver passes an absolute path to an original source file through -main-file-name if integration footer is enabled.
  2. Driver passes a full path to the original source file through -full-main-file-name.
  3. Clang CodeGen uses the file specified through -main-file-name and full-main-file-name to calculate checksums and file names for the main file.

Joint work with @AlexeySachkov

Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
@zahiraam
Copy link
Contributor Author

/verify with intel/llvm-test-suite#1264

Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
@zahiraam zahiraam marked this pull request as ready for review September 21, 2022 15:00
@zahiraam zahiraam requested review from a team as code owners September 21, 2022 15:00
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
@stevemerr
Copy link
Contributor

FYI, I did some debug info testing with the current change set. It does resolve the originally reported issue with breakpoints on Windows and also removes any references to the temporary file. I did not encounter any negative impact from the change set.

@zahiraam
Copy link
Contributor Author

FYI, I did some debug info testing with the current change set. It does resolve the originally reported issue with breakpoints on Windows and also removes any references to the temporary file. I did not encounter any negative impact from the change set.

@stevemerr thanks for taking the time!

@zahiraam
Copy link
Contributor Author

zahiraam commented Sep 22, 2022

Not really sure what the issue is with CUDA testing. It's failing after 1mn with this error:
Starting download for sycl_linux_default
Error: Unable to find an artifact with the name: sycl_linux_default

@zahiraam
Copy link
Contributor Author

@intel/dpcpp-cfe-reviewers Can you please review the patch? Thanks.

Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

I'm not familiar with this at all. @premanandrao can you please take a look?

Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>

if (IsSYCL || Args.hasArg(options::OPT_fsycl_footer_path_EQ)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the IsSYCL check needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure. Does Args.hasArg(options::OPT_fsycl_footer_path_EQ) == true implies IsSYCL?

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 talked to Mike Rice and it looks like OpenMP doesn't use footers. So I can presumably just check for the option and not test for IsSycl.

Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
Copy link
Contributor

@elizabethandrews elizabethandrews left a comment

Choose a reason for hiding this comment

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

LGTM

@zahiraam
Copy link
Contributor Author

zahiraam commented Sep 27, 2022

Just heard from @stevemerr that the additional specific debugger testing passed with this patch. Thanks Steve!

@Fznamznon
Copy link
Contributor

Could you please take a look at failing test?

sycl-intelfpga-return-check and debug-info-srcspos-kernel.cpp. Both are using
the -fsycl-is-device and -fsycl-device-only repectively. When these options are used
isSYCL returns false. So it's needed in the condition, in order to set the option
"full-main-file-name".

Signed-off-by: Zahira Ammarguellat <zahira.ammarguellat@intel.com>
@zahiraam
Copy link
Contributor Author

Could you please take a look at failing test?
Removing the IsSYCL part of the condition leads to 2 fails: sycl-intelfpga-return-check and debug-info-srcspos-kernel.cpp. Both are using the -fsycl-is-device and -fsycl-device-only repectively. When these options are used isSYCL returns false. So isSYCL is needed in the condition, in order to set the option "full-main-file-name".

@zahiraam
Copy link
Contributor Author

@premanandrao , @Fznamznon at your convenience can you please review this? Thanks.

@premanandrao
Copy link
Contributor

Could you please take a look at failing test?
Removing the IsSYCL part of the condition leads to 2 fails: sycl-intelfpga-return-check and debug-info-srcspos-kernel.cpp. Both are using the -fsycl-is-device and -fsycl-device-only repectively. When these options are used isSYCL returns false. So isSYCL is needed in the condition, in order to set the option "full-main-file-name".

Thanks for the explanation.

@zahiraam
Copy link
Contributor Author

zahiraam commented Sep 29, 2022

@intel/llvm-gatekeepers PR is ready for review and merge. Thanks.

@pvchupin pvchupin merged commit 83febf9 into intel:sycl Sep 29, 2022
@pvchupin
Copy link
Contributor

@zahiraam, please follow up on post-commit issue on Windows: https://github.com/intel/llvm/actions/runs/3153782586

Failed Tests (1):
  Clang :: CodeGenSYCL/debug-info-file-checksum.cpp

@zahiraam
Copy link
Contributor Author

zahiraam commented Sep 30, 2022

@zahiraam, please follow up on post-commit issue on Windows: https://github.com/intel/llvm/actions/runs/3153782586

Failed Tests (1):
  Clang :: CodeGenSYCL/debug-info-file-checksum.cpp

@pvchupin I tried to reproduce the issue locally. Although the test is failing, I don't get the same fail. The one I get is the same than the one we get for CodeGen/debug-info-file-checksum.c on Windows; the checksums are different on windows and Linux because of some environmental line ending issue. That's a known issue and there is some on-going fix for it in community.
I don't see in the actions link above that there were some special windows configurations to reproduce that fail?

@pvchupin
Copy link
Contributor

@zahiraam, I'm getting the same crash locally. I'm using MSVC2022 if it helps.
Would you like me to revert the patch?

@pvchupin
Copy link
Contributor

pvchupin commented Sep 30, 2022

@zahiraam, here is the backtrace from debug version:

Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
invalid argumentPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: d:\\iusers\\pvchupin\\pvchupin-llvm\\build\\bin\\clang.exe -cc1 -internal-isystem d:\\iusers\\pvchupin\\pvchupin-llvm\\build\\lib\\clang\\16.0.0\\include -nostdsysteminc -triple x86_64-unknown-linux-gnu -fsycl-is-host -include D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.header.h -dependency-filter D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.header.h -main-file-name D:\\iusers\\pvchupin\\pvchupin-llvm\\clang\\test\\CodeGenSYCL/Inputs/checksum.cpp -fsycl-use-main-file-name -full-main-file-name D:\\iusers\\pvchupin\\pvchupin-llvm\\clang\\test\\CodeGenSYCL/Inputs/checksum.cpp -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.checksum.cpp
1.      <eof> parser at end of file
2.      D:iuserspvchupinpvchupin-llvmclang      estCodeGenSYCL/Inputs/checksum.cpp:1:5: LLVM IR generation of declaration 'main'
3.      D:iuserspvchupinpvchupin-llvmclang      estCodeGenSYCL/Inputs/checksum.cpp:1:5: Generating code for declaration 'main'
Exception Code: 0x80000003
 #0 0x00007ff709281c9c HandleAbort D:\iusers\pvchupin\pvchupin-llvm\llvm\lib\Support\Windows\Signals.inc:414:0
 #1 0x00007ffa6f848e05 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa8e05)
 #2 0x00007ffa6f84ab29 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaab29)
 #3 0x00007ff709a1dd35 llvm::Expected<class clang::FileEntryRef>::fatalUncheckedExpected(void) const D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:708:0
 #4 0x00007ff709a1cfd8 llvm::Expected<class clang::FileEntryRef>::assertIsChecked(void) const D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:716:0
 #5 0x00007ff709a1a794 llvm::Expected<class clang::FileEntryRef>::~Expected<class clang::FileEntryRef>(void) D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:552:0
 #6 0x00007ff709b962b7 ComputeValidFileID(class clang::SourceManager &, class llvm::StringRef) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:389:0
 #7 0x00007ff709b8e3e0 clang::CodeGen::CGDebugInfo::getOrCreateFile(class clang::SourceLocation) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:429:0
 #8 0x00007ff709b813cc clang::CodeGen::CGDebugInfo::emitFunctionStart(class clang::GlobalDecl, class clang::SourceLocation, class clang::SourceLocation, class clang::QualType, class llvm::Function *, bool) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:4088:0
 #9 0x00007ff70a1f57b6 clang::CodeGen::CodeGenFunction::StartFunction(class clang::GlobalDecl, class clang::QualType, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &, class clang::CodeGen::FunctionArgList const &, class clang::SourceLocation, class clang::SourceLocation) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenFunction.cpp:1226:0
#10 0x00007ff70a1ecc56 clang::CodeGen::CodeGenFunction::GenerateCode(class clang::GlobalDecl, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenFunction.cpp:1615:0
#11 0x00007ff709d6b887 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:5814:0
#12 0x00007ff709d6b526 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:3906:0
#13 0x00007ff709d61c27 clang::CodeGen::CodeGenModule::EmitGlobal(class clang::GlobalDecl) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:3647:0
#14 0x00007ff709d594dc clang::CodeGen::CodeGenModule::EmitTopLevelDecl(class clang::Decl *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:6676:0
#15 0x00007ff712cf40d3 `anonymous namespace'::CodeGeneratorImpl::HandleTopLevelDecl D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\ModuleBuilder.cpp:189:0
#16 0x00007ff712ced0f2 clang::BackendConsumer::HandleTopLevelDecl(class clang::DeclGroupRef) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenAction.cpp:236:0
#17 0x00007ff70e9728d4 clang::ParseAST(class clang::Sema &, bool, bool) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Parse\ParseAST.cpp:166:0
#18 0x00007ff70aeb7aca clang::ASTFrontendAction::ExecuteAction(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\FrontendAction.cpp:1154:0
#19 0x00007ff712cdfd7d clang::CodeGenAction::ExecuteAction(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenAction.cpp:1191:0
#20 0x00007ff70aeb73be clang::FrontendAction::Execute(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\FrontendAction.cpp:1049:0
#21 0x00007ff70ae2fc4c clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\CompilerInstance.cpp:1042:0
#22 0x00007ff70b103c60 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:266:0
#23 0x00007ff706603154 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\cc1_main.cpp:250:0
#24 0x00007ff7065eaf79 ExecuteCC1Tool D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\driver.cpp:317:0
#25 0x00007ff7065eb9e4 clang_main(int, char **) D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\driver.cpp:388:0
#26 0x00007ff70663006c main D:\iusers\pvchupin\pvchupin-llvm\build\tools\clang\tools\driver\clang-driver.cpp:11:0
#27 0x00007ff71230d079 invoke_main d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#28 0x00007ff71230cf1e __scrt_common_main_seh d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#29 0x00007ff71230cdde __scrt_common_main d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#30 0x00007ff71230d10e mainCRTStartup d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#31 0x00007ffaa6247e94 (C:\WINDOWS\System32\KERNEL32.DLL+0x17e94)
#32 0x00007ffaa8a07ad1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x67ad1)

@zahiraam
Copy link
Contributor Author

@zahiraam, here is the backtrace from debug version:

Expected<T> must be checked before access or destruction.
Unchecked Expected<T> contained error:
invalid argumentPLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.      Program arguments: d:\\iusers\\pvchupin\\pvchupin-llvm\\build\\bin\\clang.exe -cc1 -internal-isystem d:\\iusers\\pvchupin\\pvchupin-llvm\\build\\lib\\clang\\16.0.0\\include -nostdsysteminc -triple x86_64-unknown-linux-gnu -fsycl-is-host -include D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.header.h -dependency-filter D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.header.h -main-file-name D:\\iusers\\pvchupin\\pvchupin-llvm\\clang\\test\\CodeGenSYCL/Inputs/checksum.cpp -fsycl-use-main-file-name -full-main-file-name D:\\iusers\\pvchupin\\pvchupin-llvm\\clang\\test\\CodeGenSYCL/Inputs/checksum.cpp -gcodeview -debug-info-kind=limited -emit-llvm -O0 -o - D:\\iusers\\pvchupin\\pvchupin-llvm\\build\\tools\\clang\\test\\CodeGenSYCL\\Output\\debug-info-file-checksum.cpp.tmp.checksum.cpp
1.      <eof> parser at end of file
2.      D:iuserspvchupinpvchupin-llvmclang      estCodeGenSYCL/Inputs/checksum.cpp:1:5: LLVM IR generation of declaration 'main'
3.      D:iuserspvchupinpvchupin-llvmclang      estCodeGenSYCL/Inputs/checksum.cpp:1:5: Generating code for declaration 'main'
Exception Code: 0x80000003
 #0 0x00007ff709281c9c HandleAbort D:\iusers\pvchupin\pvchupin-llvm\llvm\lib\Support\Windows\Signals.inc:414:0
 #1 0x00007ffa6f848e05 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xa8e05)
 #2 0x00007ffa6f84ab29 (C:\WINDOWS\SYSTEM32\ucrtbased.dll+0xaab29)
 #3 0x00007ff709a1dd35 llvm::Expected<class clang::FileEntryRef>::fatalUncheckedExpected(void) const D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:708:0
 #4 0x00007ff709a1cfd8 llvm::Expected<class clang::FileEntryRef>::assertIsChecked(void) const D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:716:0
 #5 0x00007ff709a1a794 llvm::Expected<class clang::FileEntryRef>::~Expected<class clang::FileEntryRef>(void) D:\iusers\pvchupin\pvchupin-llvm\llvm\include\llvm\Support\Error.h:552:0
 #6 0x00007ff709b962b7 ComputeValidFileID(class clang::SourceManager &, class llvm::StringRef) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:389:0
 #7 0x00007ff709b8e3e0 clang::CodeGen::CGDebugInfo::getOrCreateFile(class clang::SourceLocation) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:429:0
 #8 0x00007ff709b813cc clang::CodeGen::CGDebugInfo::emitFunctionStart(class clang::GlobalDecl, class clang::SourceLocation, class clang::SourceLocation, class clang::QualType, class llvm::Function *, bool) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CGDebugInfo.cpp:4088:0
 #9 0x00007ff70a1f57b6 clang::CodeGen::CodeGenFunction::StartFunction(class clang::GlobalDecl, class clang::QualType, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &, class clang::CodeGen::FunctionArgList const &, class clang::SourceLocation, class clang::SourceLocation) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenFunction.cpp:1226:0
#10 0x00007ff70a1ecc56 clang::CodeGen::CodeGenFunction::GenerateCode(class clang::GlobalDecl, class llvm::Function *, class clang::CodeGen::CGFunctionInfo const &) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenFunction.cpp:1615:0
#11 0x00007ff709d6b887 clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:5814:0
#12 0x00007ff709d6b526 clang::CodeGen::CodeGenModule::EmitGlobalDefinition(class clang::GlobalDecl, class llvm::GlobalValue *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:3906:0
#13 0x00007ff709d61c27 clang::CodeGen::CodeGenModule::EmitGlobal(class clang::GlobalDecl) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:3647:0
#14 0x00007ff709d594dc clang::CodeGen::CodeGenModule::EmitTopLevelDecl(class clang::Decl *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenModule.cpp:6676:0
#15 0x00007ff712cf40d3 `anonymous namespace'::CodeGeneratorImpl::HandleTopLevelDecl D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\ModuleBuilder.cpp:189:0
#16 0x00007ff712ced0f2 clang::BackendConsumer::HandleTopLevelDecl(class clang::DeclGroupRef) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenAction.cpp:236:0
#17 0x00007ff70e9728d4 clang::ParseAST(class clang::Sema &, bool, bool) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Parse\ParseAST.cpp:166:0
#18 0x00007ff70aeb7aca clang::ASTFrontendAction::ExecuteAction(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\FrontendAction.cpp:1154:0
#19 0x00007ff712cdfd7d clang::CodeGenAction::ExecuteAction(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\CodeGen\CodeGenAction.cpp:1191:0
#20 0x00007ff70aeb73be clang::FrontendAction::Execute(void) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\FrontendAction.cpp:1049:0
#21 0x00007ff70ae2fc4c clang::CompilerInstance::ExecuteAction(class clang::FrontendAction &) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\Frontend\CompilerInstance.cpp:1042:0
#22 0x00007ff70b103c60 clang::ExecuteCompilerInvocation(class clang::CompilerInstance *) D:\iusers\pvchupin\pvchupin-llvm\clang\lib\FrontendTool\ExecuteCompilerInvocation.cpp:266:0
#23 0x00007ff706603154 cc1_main(class llvm::ArrayRef<char const *>, char const *, void *) D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\cc1_main.cpp:250:0
#24 0x00007ff7065eaf79 ExecuteCC1Tool D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\driver.cpp:317:0
#25 0x00007ff7065eb9e4 clang_main(int, char **) D:\iusers\pvchupin\pvchupin-llvm\clang\tools\driver\driver.cpp:388:0
#26 0x00007ff70663006c main D:\iusers\pvchupin\pvchupin-llvm\build\tools\clang\tools\driver\clang-driver.cpp:11:0
#27 0x00007ff71230d079 invoke_main d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:79:0
#28 0x00007ff71230cf1e __scrt_common_main_seh d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288:0
#29 0x00007ff71230cdde __scrt_common_main d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:331:0
#30 0x00007ff71230d10e mainCRTStartup d:\a01\_work\20\s\src\vctools\crt\vcstartup\src\startup\exe_main.cpp:17:0
#31 0x00007ffaa6247e94 (C:\WINDOWS\System32\KERNEL32.DLL+0x17e94)
#32 0x00007ffaa8a07ad1 (C:\WINDOWS\SYSTEM32\ntdll.dll+0x67ad1)

Yes I think I understand the issue. The problem is coming from the "append-file" command in the LIT test. The appended file in Linux has this shape:
#line 1 "/export/iusers/zahiraam/IntelLlvm/llvm/clang/test/CodeGenSYCL/Inputs/checksum.cpp"
int main() {
int x = 0;
return x + 1;
}
#include "/export/iusers/zahiraam/IntelLlvm/llvm/build/tools/clang/test/CodeGenSYCL/Output/debug-info-file-checksum.cpp.tmp.footer.h"
We can see that in the first line there is use of forward "/".

On Windows this is the shape of the appended file:
#line 1 "D:\IUSERS\zahiraam\sycl-bp\llvm\clang\test\CodeGenSYCL\Inputs\checksum.cpp"
int main() {
int x = 0;
return x + 1;
}
#include "D:\IUSERS\zahiraam\sycl-bp\llvm\build\tools\clang\test\CodeGenSYCL\Output\debug-info-file-checksum.cpp.tmp.footer.h"

It's using the backward "".

The call here https://github.com/intel/llvm/blob/sycl/clang/lib/CodeGen/CGDebugInfo.cpp#L404 is returning for Linux the correct filename and for Windows it's returning something like this: "D:IUSERSzahiraamsycl-bpllvmclang\testCodeGenSYCLInputschecksum.cpp" . The crash happens because this file is bogus and ExpectedFileRef here https://github.com/intel/llvm/blob/sycl/clang/lib/CodeGen/CGDebugInfo.cpp#L385 returns an error.

The string filenames are computed here: https://github.com/intel/llvm/blob/sycl/clang/lib/Lex/PPDirectives.cpp#L1434
So this is definitely an issue related to escape characters on Windows.
I tried creating an artificial "tmp" file in the Inputs folder instead of creating one using the append-file command but that doesn't really show the issue we are trying to prove , which is that checksum for host and compile files are identical.
So I think the LIT test should stay as is but may the right course here is to find and fix the bug in the literal string parser.
Your thoughts?

@pvchupin
Copy link
Contributor

@zahiraam, sounds good to me. Should I revert this change as a whole to give you more time for analysis? Or you have a workaround? Or should we disable the test if the rest of the compiler is not impacted?
Basically need some patch soon to return post-commit to green.

@zahiraam
Copy link
Contributor Author

@zahiraam, sounds good to me. Should I revert this change as a whole to give you more time for analysis? Or you have a workaround? Or should we disable the test if the rest of the compiler is not impacted? Basically need some patch soon to return post-commit to green.

@pvchupin To fix the literal string parser will take some more analysis and time. I want to try a fix in CGDebugInfo.cpp and see if that doesn't break other tests. But I will do that Monday. If you want post-commit to be green today, you can disable the LIT test and I will work on a fix one way or the other. Thanks.

XinWang10 added a commit that referenced this pull request Dec 14, 2023
We have changed the code in #6774, but
we did wrong resolution recently.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants