llvmbot wrote:

<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-clang-codegen

Author: Alexey Bader (bader)

<details>
<summary>Changes</summary>

&gt; 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:

&gt; clang -flto -funified-lto -save-temps test.c -ccc-print-phases
&gt;          +- 0: input, "test.c", c
&gt;       +- 1: preprocessor, {0}, cpp-output
&gt;    +- 2: compiler, {1}, ir
&gt; +- 3: backend, {2}, lto-bc
&gt; 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.

---
Full diff: https://github.com/llvm/llvm-project/pull/162763.diff


1 Files Affected:

- (modified) clang/lib/CodeGen/BackendUtil.cpp (+2-1) 


``````````diff
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));
   }
 

``````````

</details>


https://github.com/llvm/llvm-project/pull/162763
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to