@@ -397,40 +397,18 @@ std::optional<StringRef> CGDebugInfo::getSource(const SourceManager &SM,
397397 return Source;
398398}
399399
400- // Compute valid FID for FileName.
401- FileID ComputeValidFileID (SourceManager &SM, StringRef FileName) {
402- FileID MainFileID = SM.getMainFileID ();
403- // Find the filename FileName and load it.
404- llvm::Expected<FileEntryRef> ExpectedFileRef =
405- SM.getFileManager ().getFileRef (FileName);
406- if (ExpectedFileRef) {
407- MainFileID = SM.getOrCreateFileID (ExpectedFileRef.get (),
408- SrcMgr::CharacteristicKind::C_User);
409- }
410- return MainFileID;
411- }
412-
413400llvm::DIFile *CGDebugInfo::getOrCreateFile (SourceLocation Loc) {
414401 SourceManager &SM = CGM.getContext ().getSourceManager ();
415402 StringRef FileName;
416403 FileID FID;
417404 std::optional<llvm::DIFile::ChecksumInfo<StringRef>> CSInfo;
418405
419406 if (Loc.isInvalid ()) {
420- if (CGM.getCodeGenOpts ().SYCLUseMainFileName &&
421- CGM.getLangOpts ().MacroPrefixMap .size () > 0 ) {
422- // When fmacro-prefix-map is used, the original source file
423- // file name is indicated by FullMainFileName instead of the CU.
424- auto &CGO = CGM.getCodeGenOpts ();
425- FileName = CGO.FullMainFileName ;
426- FID = ComputeValidFileID (SM, CGO.FullMainFileName );
427- } else {
428- // The DIFile used by the CU is distinct from the main source file. Call
429- // createFile() below for canonicalization if the source file was specified
430- // with an absolute path.
431- FileName = TheCU->getFile ()->getFilename ();
432- CSInfo = TheCU->getFile ()->getChecksum ();
433- }
407+ // The DIFile used by the CU is distinct from the main source file. Call
408+ // createFile() below for canonicalization if the source file was specified
409+ // with an absolute path.
410+ FileName = TheCU->getFile ()->getFilename ();
411+ CSInfo = TheCU->getFile ()->getChecksum ();
434412 } else {
435413 PresumedLoc PLoc = SM.getPresumedLoc (Loc);
436414 FileName = PLoc.getFilename ();
@@ -449,13 +427,6 @@ llvm::DIFile *CGDebugInfo::getOrCreateFile(SourceLocation Loc) {
449427 return cast<llvm::DIFile>(V);
450428 }
451429
452- if (SM.getFileEntryForID (SM.getMainFileID ()) &&
453- CGM.getCodeGenOpts ().SYCLUseMainFileName && FID.isInvalid ())
454- // When an integration footer is involved, the main file is a temporary
455- // file generated by the compiler. FileName is pointing to original user
456- // source file. We use it here to properly calculate its checksum.
457- FID = ComputeValidFileID (SM, FileName);
458-
459430 // Put Checksum at a scope where it will persist past the createFile call.
460431 SmallString<64 > Checksum;
461432 if (!CSInfo) {
@@ -565,25 +536,18 @@ void CGDebugInfo::CreateCompileUnit() {
565536 auto &CGO = CGM.getCodeGenOpts ();
566537 const LangOptions &LO = CGM.getLangOpts ();
567538 std::string MainFileName = CGO.MainFileName ;
568- std::string FullMainFileName = CGO.FullMainFileName ;
569539 if (MainFileName.empty ())
570540 MainFileName = " <stdin>" ;
571541
572542 // The main file name provided via the "-main-file-name" option contains just
573543 // the file name itself with no path information. This file name may have had
574544 // a relative path, so we look into the actual file entry for the main
575545 // file to determine the real absolute path for the file.
576- // An exception here is workflow when integration footer is involved: in that
577- // case driver passes an absolute path to the original user-provided source
578- // file, whilst main file corresponds to a temporary file generated by the
579- // compiler.
580546 std::string MainFileDir;
581547 if (OptionalFileEntryRef MainFile =
582548 SM.getFileEntryRefForID (SM.getMainFileID ())) {
583549 MainFileDir = std::string (MainFile->getDir ().getName ());
584- FileID MainFileID = SM.getMainFileID ();
585- if (!llvm::sys::path::is_absolute (MainFileName) &&
586- !CGM.getCodeGenOpts ().SYCLUseMainFileName ) {
550+ if (!llvm::sys::path::is_absolute (MainFileName)) {
587551 llvm::SmallString<1024 > MainFileDirSS (MainFileDir);
588552 llvm::sys::path::Style Style =
589553 LO.UseTargetPathSeparator
@@ -594,14 +558,6 @@ void CGDebugInfo::CreateCompileUnit() {
594558 llvm::sys::path::append (MainFileDirSS, Style, MainFileName);
595559 MainFileName = std::string (
596560 llvm::sys::path::remove_leading_dotslash (MainFileDirSS, Style));
597- } else if (CGM.getCodeGenOpts ().SYCLUseMainFileName ) {
598- // When an integration footer is involved, the main file is a temporary
599- // file generated by the compiler. FullMainFileName is pointing to
600- // original user source file. We use it here to properly calculate its
601- // checksum.
602- MainFileID = ComputeValidFileID (SM, FullMainFileName);
603- // Make sure the filename points to the original user source filename.
604- MainFileName = FullMainFileName;
605561 }
606562 // If the main file name provided is identical to the input file name, and
607563 // if the input file is a preprocessed source, use the module name for
@@ -614,7 +570,7 @@ void CGDebugInfo::CreateCompileUnit() {
614570 .isPreprocessed ()) {
615571 MainFileName = CGM.getModule ().getName ().str ();
616572 } else {
617- CSKind = computeChecksum (MainFileID , Checksum);
573+ CSKind = computeChecksum (SM. getMainFileID () , Checksum);
618574 }
619575 }
620576
0 commit comments