[PATCH] D74878: [remark][diagnostics] [codegen] Fix PR44896
Rong Xu via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Feb 19 15:36:15 PST 2020
xur created this revision.
xur added reviewers: tejohnson, jeroen.dobbelaere.
This patch fixes PR44896.
For IR input files, option fdiscard-value-names should be ignored as we need named values in loadModule().
Commit 60d3947922 <https://reviews.llvm.org/rG60d39479221d6bc09060f7816bcd7c54eb286603> sets this option after loadModule() where valued names already created. This creates an inconsistent state in setNameImpl() that leads to a seg fault.
This patch forces fdiscard-value-names to be false for IR input files.
https://reviews.llvm.org/D74878
Files:
clang/lib/CodeGen/CodeGenAction.cpp
clang/test/CodeGen/PR44896.ll
Index: clang/test/CodeGen/PR44896.ll
===================================================================
--- /dev/null
+++ clang/test/CodeGen/PR44896.ll
@@ -0,0 +1,7 @@
+; RUN: %clang_cc1 -triple x86_64-unknown-unknown -O3 -S -emit-llvm %s -discard-value-names -o -
+; PR 44896
+
+define linkonce i8* @b(i8* %a) {
+ ret i8* %a
+}
+
Index: clang/lib/CodeGen/CodeGenAction.cpp
===================================================================
--- clang/lib/CodeGen/CodeGenAction.cpp
+++ clang/lib/CodeGen/CodeGenAction.cpp
@@ -1146,6 +1146,9 @@
CI.getTargetOpts(), CI.getLangOpts(),
CI.getFrontendOpts().ShowTimers,
std::move(LinkModules), *VMContext, nullptr);
+ // PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
+ // true here because the valued names are needed for reading textual IR.
+ Ctx.setDiscardValueNames(false);
Ctx.setDiagnosticHandler(
std::make_unique<ClangDiagnosticHandler>(CodeGenOpts, &Result));
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D74878.245544.patch
Type: text/x-patch
Size: 1049 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200219/06f91584/attachment-0001.bin>
More information about the cfe-commits
mailing list