diff options
author | Hans Wennborg <hans@hanshq.net> | 2017-05-09 14:44:15 +0000 |
---|---|---|
committer | Hans Wennborg <hans@hanshq.net> | 2017-05-09 14:44:15 +0000 |
commit | 1f81185df2789f29dd36dbbecbd4c5e4e583b85a (patch) | |
tree | e1cec802edebc74652da8ec1664ff83be4808db4 /unittests/Transforms/Utils | |
parent | 1fbed43c3e96fbe22c1b4cf1f2aa6b2cd018c672 (diff) |
Revert r302469 "Make it illegal for two Functions to point to the same DISubprogram"
This caused PR32977.
Original commit message:
> Make it illegal for two Functions to point to the same DISubprogram
>
> As recently discussed on llvm-dev [1], this patch makes it illegal for
> two Functions to point to the same DISubprogram and updates
> FunctionCloner to also clone the debug info of a function to conform
> to the new requirement. To simplify the implementation it also factors
> out the creation of inlineAt locations from the Inliner into a
> general-purpose utility in DILocation.
>
> [1] http://lists.llvm.org/pipermail/llvm-dev/2017-May/112661.html
> <rdar://problem/31926379>
>
> Differential Revision: https://reviews.llvm.org/D32975
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302533 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Transforms/Utils')
-rw-r--r-- | unittests/Transforms/Utils/Cloning.cpp | 65 |
1 files changed, 28 insertions, 37 deletions
diff --git a/unittests/Transforms/Utils/Cloning.cpp b/unittests/Transforms/Utils/Cloning.cpp index 83f146dca70..2f4ee863653 100644 --- a/unittests/Transforms/Utils/Cloning.cpp +++ b/unittests/Transforms/Utils/Cloning.cpp @@ -296,6 +296,7 @@ protected: Value* AllocaContent = IBuilder.getInt32(1); Instruction* Store = IBuilder.CreateStore(AllocaContent, Alloca); IBuilder.SetCurrentDebugLocation(DebugLoc::get(5, 2, Subprogram)); + Instruction* Terminator = IBuilder.CreateRetVoid(); // Create a local variable around the alloca auto *IntType = DBuilder.createBasicType("int", 32, dwarf::DW_ATE_signed); @@ -305,25 +306,12 @@ protected: auto *DL = DILocation::get(Subprogram->getContext(), 5, 0, Subprogram); DBuilder.insertDeclare(Alloca, Variable, E, DL, Store); DBuilder.insertDbgValueIntrinsic(AllocaContent, 0, Variable, E, DL, - Entry); - // Also create an inlined variable. - auto *InlinedSP = - DBuilder.createFunction(CU, "inlined", "inlined", File, 8, FuncType, - true, true, 9, DINode::FlagZero, false); - auto *InlinedVar = - DBuilder.createAutoVariable(InlinedSP, "inlined", File, 5, IntType, true); - auto *Scope = DBuilder.createLexicalBlock( - DBuilder.createLexicalBlockFile(InlinedSP, File), File, 1, 1); - auto InlinedDL = - DebugLoc::get(9, 4, Scope, DebugLoc::get(5, 2, Subprogram)); - IBuilder.SetCurrentDebugLocation(InlinedDL); - DBuilder.insertDeclare(Alloca, InlinedVar, E, InlinedDL, Store); - IBuilder.CreateStore(IBuilder.getInt32(2), Alloca); - // Finalize the debug info. + Terminator); + // Finalize the debug info DBuilder.finalize(); - IBuilder.CreateRetVoid(); - // Create another, empty, compile unit. + + // Create another, empty, compile unit DIBuilder DBuilder2(*M); DBuilder2.createCompileUnit(dwarf::DW_LANG_C99, DBuilder.createFile("extra.c", "/file/dir"), @@ -357,8 +345,15 @@ TEST_F(CloneFunc, NewFunctionCreated) { // function, while the original subprogram still points to the old one. TEST_F(CloneFunc, Subprogram) { EXPECT_FALSE(verifyModule(*M)); - EXPECT_EQ(3U, Finder->subprogram_count()); - EXPECT_NE(NewFunc->getSubprogram(), OldFunc->getSubprogram()); + + unsigned SubprogramCount = Finder->subprogram_count(); + EXPECT_EQ(1U, SubprogramCount); + + auto Iter = Finder->subprograms().begin(); + auto *Sub = cast<DISubprogram>(*Iter); + + EXPECT_TRUE(Sub == OldFunc->getSubprogram()); + EXPECT_TRUE(Sub == NewFunc->getSubprogram()); } // Test that instructions in the old function still belong to it in the @@ -385,8 +380,8 @@ TEST_F(CloneFunc, InstructionOwnership) { EXPECT_EQ(OldDL.getCol(), NewDL.getCol()); // But that they belong to different functions - auto *OldSubprogram = cast<DISubprogram>(OldDL.getInlinedAtScope()); - auto *NewSubprogram = cast<DISubprogram>(NewDL.getInlinedAtScope()); + auto *OldSubprogram = cast<DISubprogram>(OldDL.getScope()); + auto *NewSubprogram = cast<DISubprogram>(NewDL.getScope()); EXPECT_EQ(OldFunc->getSubprogram(), OldSubprogram); EXPECT_EQ(NewFunc->getSubprogram(), NewSubprogram); } @@ -421,26 +416,22 @@ TEST_F(CloneFunc, DebugIntrinsics) { EXPECT_EQ(NewFunc, cast<AllocaInst>(NewIntrin->getAddress())-> getParent()->getParent()); - if (!OldIntrin->getDebugLoc()->getInlinedAt()) { - // Old variable must belong to the old function. - EXPECT_EQ(OldFunc->getSubprogram(), - cast<DISubprogram>(OldIntrin->getVariable()->getScope())); - // New variable must belong to the new function. - EXPECT_EQ(NewFunc->getSubprogram(), - cast<DISubprogram>(NewIntrin->getVariable()->getScope())); - } + // Old variable must belong to the old function + EXPECT_EQ(OldFunc->getSubprogram(), + cast<DISubprogram>(OldIntrin->getVariable()->getScope())); + // New variable must belong to the New function + EXPECT_EQ(NewFunc->getSubprogram(), + cast<DISubprogram>(NewIntrin->getVariable()->getScope())); } else if (DbgValueInst* OldIntrin = dyn_cast<DbgValueInst>(&OldI)) { DbgValueInst* NewIntrin = dyn_cast<DbgValueInst>(&NewI); EXPECT_TRUE(NewIntrin); - if (!OldIntrin->getDebugLoc()->getInlinedAt()) { - // Old variable must belong to the old function. - EXPECT_EQ(OldFunc->getSubprogram(), - cast<DISubprogram>(OldIntrin->getVariable()->getScope())); - // New variable must belong to the new function. - EXPECT_EQ(NewFunc->getSubprogram(), - cast<DISubprogram>(NewIntrin->getVariable()->getScope())); - } + // Old variable must belong to the old function + EXPECT_EQ(OldFunc->getSubprogram(), + cast<DISubprogram>(OldIntrin->getVariable()->getScope())); + // New variable must belong to the New function + EXPECT_EQ(NewFunc->getSubprogram(), + cast<DISubprogram>(NewIntrin->getVariable()->getScope())); } ++OldIter; |