-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Add debug options to clang-linker-wrapper #101008
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -581,8 +581,16 @@ Expected<StringRef> clang(ArrayRef<StringRef> InputFiles, const ArgList &Args) { | |
if (SaveTemps) | ||
CmdArgs.push_back("-save-temps"); | ||
|
||
if (SaveTemps && linkerSupportsLTO(Args)) | ||
CmdArgs.push_back("-Wl,--save-temps"); | ||
if (linkerSupportsLTO(Args)) { | ||
if (SaveTemps) | ||
CmdArgs.push_back("-Wl,--save-temps"); | ||
if (Args.hasArg(OPT_lto_debug_pass_manager)) | ||
CmdArgs.push_back("-Wl,--lto-debug-pass-manager"); | ||
for (const opt::Arg *Arg : Args.filtered(OPT_offload_opt_eq_minus)) { | ||
CmdArgs.push_back( | ||
Args.MakeArgString("-Wl,--mllvm=" + StringRef(Arg->getValue()))); | ||
Comment on lines
+589
to
+591
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This should already be handled elsewhere. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'll remove the commit that added this. I think I wrote it before 97c62b8f75 was merged. |
||
} | ||
} | ||
|
||
if (Args.hasArg(OPT_embed_bitcode)) | ||
CmdArgs.push_back("-Wl,--lto-emit-llvm"); | ||
|
@@ -767,6 +775,8 @@ std::unique_ptr<lto::LTO> createLTO( | |
// TODO: Handle remark files | ||
Conf.HasWholeProgramVisibility = Args.hasArg(OPT_whole_program); | ||
|
||
Conf.DebugPassManager = Args.hasArg(OPT_lto_debug_pass_manager); | ||
|
||
return std::make_unique<lto::LTO>(std::move(Conf), Backend); | ||
} | ||
|
||
|
@@ -781,6 +791,8 @@ bool isValidCIdentifier(StringRef S) { | |
Error linkBitcodeFiles(SmallVectorImpl<OffloadFile> &InputFiles, | ||
SmallVectorImpl<StringRef> &OutputFiles, | ||
const ArgList &Args) { | ||
if (Verbose) | ||
llvm::errs() << "Linking bitcode files\n"; | ||
Comment on lines
+794
to
+795
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Verbose mode just wants to print information from the tools generally. I think if we want tracing we already have the time-trace scope. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Time-trace seems to be focused more on profiling than just tracing. It writes json to a file. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That sounds more like debugging than verbose output, we could add something for it but in general I don't think it adds too much, since this path isn't really used anymore. |
||
llvm::TimeTraceScope TimeScope("Link bitcode files"); | ||
const llvm::Triple Triple(Args.getLastArgValue(OPT_triple_EQ)); | ||
StringRef Arch = Args.getLastArgValue(OPT_arch_EQ); | ||
|
@@ -1017,6 +1029,8 @@ Expected<StringRef> writeOffloadFile(const OffloadFile &File) { | |
// Compile the module to an object file using the appropriate target machine for | ||
// the host triple. | ||
Expected<StringRef> compileModule(Module &M, OffloadKind Kind) { | ||
if (Verbose) | ||
llvm::errs() << "Compiling module\n"; | ||
llvm::TimeTraceScope TimeScope("Compile module"); | ||
std::string Msg; | ||
const Target *T = TargetRegistry::lookupTarget(M.getTargetTriple(), Msg); | ||
|
@@ -1197,7 +1211,8 @@ bundleLinkedOutput(ArrayRef<OffloadingImage> Images, const ArgList &Args, | |
} | ||
} | ||
|
||
/// Returns a new ArgList containg arguments used for the device linking phase. | ||
/// Returns a new ArgList containing arguments used for the device linking | ||
/// phase. | ||
DerivedArgList getLinkerArgs(ArrayRef<OffloadFile> Input, | ||
const InputArgList &Args) { | ||
DerivedArgList DAL = DerivedArgList(DerivedArgList(Args)); | ||
|
@@ -1309,7 +1324,7 @@ Expected<SmallVector<StringRef>> linkAndWrapDeviceFiles( | |
// First link and remove all the input files containing bitcode if | ||
// the target linker does not support it natively. | ||
SmallVector<StringRef> InputFiles; | ||
if (!linkerSupportsLTO(LinkerArgs)) | ||
if (!linkerSupportsLTO(LinkerArgs) || Args.hasArg(OPT_lto_in_process)) | ||
if (Error Err = linkBitcodeFiles(Input, InputFiles, LinkerArgs)) | ||
return Err; | ||
|
||
|
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
--save-temps
thing is kind of special, I'm thining for stuff like this it's better suited for-Xoffload-linker --lto-debug-pass-manager
once I merge #101032.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.
Verified that
--device-linker=--lto-debug-pass-manager
works.I am going to close this PR since most of the functionality is redundant or now available by other means.