[llvm-bugs] [Bug 44560] New: OpenMP IRBuilder passes invalid DISubprogram to CodeExtractor
via llvm-bugs
llvm-bugs at lists.llvm.org
Wed Jan 15 10:59:55 PST 2020
https://bugs.llvm.org/show_bug.cgi?id=44560
Bug ID: 44560
Summary: OpenMP IRBuilder passes invalid DISubprogram to
CodeExtractor
Product: OpenMP
Version: unspecified
Hardware: PC
OS: All
Status: NEW
Severity: normal
Priority: P
Component: Clang Compiler Support
Assignee: unassignedclangbugs at nondot.org
Reporter: vsk at apple.com
CC: llvm-bugs at lists.llvm.org
OpenMP passes a function with an invalid DISubprogram to CodeExtractor.
(I noticed this while working on a patch that teaches CodeExtractor to transfer
debug info into extracted functions.)
Steps to reproduce:
1) Add the following verification step to CodeExtractor::extractCodeRegion:
```
--- a/llvm/lib/Transforms/Utils/CodeExtractor.cpp
+++ b/llvm/lib/Transforms/Utils/CodeExtractor.cpp
@@ -1520,10 +1520,15 @@ CodeExtractor::extractCodeRegion(const
CodeExtractorAnalysisCache &CEAC) {
// Assumption: this is a single-entry code region, and the header is the
first
// block in the region.
BasicBlock *header = *Blocks.begin();
Function *oldFunction = header->getParent();
+ if (verifyFunction(*oldFunction, &errs())) {
+ oldFunction->dump();
+ report_fatal_error("verification of oldFunction failed!");
+ }
+
```
2) Run the clang/test/OpenMP/parallel_codegen.cpp test.
As an alternative to step (1), just add "-mllvm -debug-only=code-extractor" to
the clang invocations in clang/test/OpenMP/parallel_codegen.cpp.
Results:
The IR is invalid before it gets to CodeExtractor (which hasn't
touched/modified it):
```
Expected no forward declarations!
!10 = <temporary!> !{}
```
The problem is that the "retainedNodes" field of a DISubprogram is a temporary
metadata node. This suggests that `DIBuilder::finalizeSubprogram()` has not
been called.
Backtrace:
```
* frame #0: 0x0000000101ec3730 clang`llvm::report_fatal_error(char const*,
bool)
frame #1: 0x0000000101fa32c7
clang`llvm::CodeExtractor::extractCodeRegion(this=0x00007ffeefbfa150,
CEAC=0x00007ffeefbfa1e0) at CodeExtractor.cpp:1527:5
frame #2: 0x0000000103cf1562
clang`llvm::OpenMPIRBuilder::CreateParallel(llvm::OpenMPIRBuilder::LocationDescription
const&, llvm::function_ref<void (llvm::IRBuilderBase::InsertPoint,
llvm::IRBuilderBase::InsertPoint, llvm::BasicBlock&)>,
llvm::function_ref<llvm::IRBuilderBase::InsertPoint (llvm::IRBuilderBase::In
sertPoint, llvm::IRBuilderBase::InsertPoint, llvm::Value&, llvm::Value*&)>,
std::__1::function<void (llvm::IRBuilderBase::InsertPoint)>, llvm::Value*,
llvm::Value*, llvm::omp::ProcBindKind, bool) + 5730
frame #3: 0x000000010249b44d
clang`clang::CodeGen::CodeGenFunction::EmitOMPParallelDirective(clang::OMPParallelDirective
const&) + 653
frame #4: 0x0000000102483a25
clang`clang::CodeGen::CodeGenFunction::EmitStmt(clang::Stmt const*,
llvm::ArrayRef<clang::Attr const*>) + 1093
frame #5: 0x000000010248da51
clang`clang::CodeGen::CodeGenFunction::EmitCompoundStmtWithoutScope(clang::CompoundStmt
const&, bool, clang::CodeGen::AggValueSlot) + 609
frame #6: 0x00000001024d8bdd
clang`clang::CodeGen::CodeGenFunction::GenerateCode(clang::GlobalDecl,
llvm::Function*, clang::CodeGen::CGFunctionInfo const&) + 1661
frame #7: 0x00000001024f617e
clang`clang::CodeGen::CodeGenModule::EmitGlobalFunctionDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 574
frame #8: 0x00000001024eebd7
clang`clang::CodeGen::CodeGenModule::EmitGlobalDefinition(clang::GlobalDecl,
llvm::GlobalValue*) + 423
frame #9: 0x00000001024fa0b6
clang`clang::CodeGen::CodeGenModule::EmitTopLevelDecl(clang::Decl*) + 150
frame #10: 0x0000000102583120 clang`(anonymous
namespace)::CodeGeneratorImpl::HandleTopLevelDecl(clang::DeclGroupRef) + 160
frame #11: 0x00000001024ce1fa
clang`clang::BackendConsumer::HandleTopLevelDecl(clang::DeclGroupRef) + 186
frame #12: 0x0000000102927cb9
clang`clang::ASTReader::PassInterestingDeclsToConsumer() + 297
frame #13: 0x00000001028bbfef clang`non-virtual thunk to
clang::ASTReader::StartTranslationUnit(clang::ASTConsumer*) + 31
frame #14: 0x0000000102f7f6a2 clang`clang::ParseAST(clang::Sema&, bool,
bool) + 386
frame #15: 0x00000001027f5443 clang`clang::FrontendAction::Execute() + 163
frame #16: 0x00000001027823e3
clang`clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 1683
frame #17: 0x000000010286eaa2
clang`clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 1458
frame #18: 0x0000000100008044 clang`cc1_main(llvm::ArrayRef<char const*>,
char const*, void*) + 2436
frame #19: 0x0000000100005a8c clang`main + 11964
```
--
You are receiving this mail because:
You are on the CC list for the bug.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-bugs/attachments/20200115/32253d61/attachment-0001.html>
More information about the llvm-bugs
mailing list