-
Notifications
You must be signed in to change notification settings - Fork 15.3k
[Clang][LTO] Fix use of funified-lto and save-temps flags together #162763
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
> clang -flto -funified-lto -save-temps test.c
Fails with the following error message:
```bash
module flag identifiers must be unique (or of 'require' type)
!"UnifiedLTO"
fatal error: error in backend: Broken module found, compilation aborted!
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
```
Here is what the driver does when `-save-temps` flag is set:
> clang -flto -funified-lto -save-temps test.c -ccc-print-phases
> +- 0: input, "test.c", c
> +- 1: preprocessor, {0}, cpp-output
> +- 2: compiler, {1}, ir
> +- 3: backend, {2}, lto-bc
> 4: linker, {3}, image
The IR output of "compiler" step has "UnifiedLTO" module flag. "backend"
step adds another module flag with "UnifiedLTO" identifier, which
invalidates the LLVM IR module.
|
@llvm/pr-subscribers-clang @llvm/pr-subscribers-clang-codegen Author: Alexey Bader (bader) Changes> clang -flto -funified-lto -save-temps test.c Fails with the following error message: module flag identifiers must be unique (or of 'require' type)
!"UnifiedLTO"
fatal error: error in backend: Broken module found, compilation aborted!
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)Here is what the driver does when > clang -flto -funified-lto -save-temps test.c -ccc-print-phases The IR output of "compiler" step has "UnifiedLTO" module flag. "backend" Full diff: https://github.com/llvm/llvm-project/pull/162763.diff 1 Files Affected:
diff --git a/clang/lib/CodeGen/BackendUtil.cpp b/clang/lib/CodeGen/BackendUtil.cpp
index 2d959827d6972..d28d886b3551e 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -1199,7 +1199,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
}
}
- if (shouldEmitUnifiedLTOModueFlag())
+ if (shouldEmitUnifiedLTOModueFlag() &&
+ !TheModule->getModuleFlag("UnifiedLTO"))
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
}
|
|
The fix is similar to 53adfa8. |
|
@david-greene-cb, GitHub account seems to be inactive. |
ilovepi
left a comment
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.
Fails with the following error message:
Here is what the driver does when
-save-tempsflag is set:The IR output of "compiler" step has "UnifiedLTO" module flag. "backend"
step adds another module flag with "UnifiedLTO" identifier, which
invalidates the LLVM IR module.