[llvm-branch-commits] [llvm] 8c4e557 - [docs][unittest][Go][StackProtector] Migrate deprecated DebugInfo::get to DILocation::get

Fangrui Song via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Tue Dec 15 14:22:04 PST 2020


Author: Fangrui Song
Date: 2020-12-15T14:17:04-08:00
New Revision: 8c4e55762d8b7a07546a5db18e33ccc6a9d97002

URL: https://github.com/llvm/llvm-project/commit/8c4e55762d8b7a07546a5db18e33ccc6a9d97002
DIFF: https://github.com/llvm/llvm-project/commit/8c4e55762d8b7a07546a5db18e33ccc6a9d97002.diff

LOG: [docs][unittest][Go][StackProtector] Migrate deprecated DebugInfo::get to DILocation::get

Added: 
    

Modified: 
    llvm/bindings/go/llvm/IRBindings.cpp
    llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
    llvm/lib/CodeGen/StackProtector.cpp
    llvm/unittests/CodeGen/LexicalScopesTest.cpp
    llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
    llvm/unittests/IR/IRBuilderTest.cpp
    llvm/unittests/Transforms/Utils/CloningTest.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/bindings/go/llvm/IRBindings.cpp b/llvm/bindings/go/llvm/IRBindings.cpp
index 5b84f482b16b..5ee841c5fa9b 100644
--- a/llvm/bindings/go/llvm/IRBindings.cpp
+++ b/llvm/bindings/go/llvm/IRBindings.cpp
@@ -53,9 +53,12 @@ void LLVMSetMetadata2(LLVMValueRef Inst, unsigned KindID, LLVMMetadataRef MD) {
 void LLVMGoSetCurrentDebugLocation(LLVMBuilderRef Bref, unsigned Line,
                                   unsigned Col, LLVMMetadataRef Scope,
                                   LLVMMetadataRef InlinedAt) {
-  unwrap(Bref)->SetCurrentDebugLocation(
-      DebugLoc::get(Line, Col, Scope ? unwrap<MDNode>(Scope) : nullptr,
-                    InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr));
+  if (!Scope)
+    unwrap(Bref)->SetCurrentDebugLocation(DebugLoc());
+  else
+    unwrap(Bref)->SetCurrentDebugLocation(
+        DILocation::get(Scope->getContext(), Line, Col, unwrap<MDNode>(Scope),
+                        InlinedAt ? unwrap<MDNode>(InlinedAt) : nullptr));
 }
 
 LLVMDebugLocMetadata LLVMGoGetCurrentDebugLocation(LLVMBuilderRef Bref) {

diff  --git a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
index 0304c8ec813f..c641999b226b 100644
--- a/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
+++ b/llvm/docs/tutorial/MyFirstLanguageFrontend/LangImpl09.rst
@@ -341,7 +341,7 @@ We use a small helper function for this:
     else
       Scope = LexicalBlocks.back();
     Builder.SetCurrentDebugLocation(
-        DebugLoc::get(AST->getLine(), AST->getCol(), Scope));
+        DILocation::get(Scope->getContext(), AST->getLine(), AST->getCol(), Scope));
   }
 
 This both tells the main ``IRBuilder`` where we are, but also what scope
@@ -400,7 +400,7 @@ argument allocas in ``FunctionAST::codegen``.
           true);
 
       DBuilder->insertDeclare(Alloca, D, DBuilder->createExpression(),
-                              DebugLoc::get(LineNo, 0, SP),
+                              DILocation::get(SP->getContext(), LineNo, 0, SP),
                               Builder.GetInsertBlock());
 
       // Store the initial value into the alloca.

diff  --git a/llvm/lib/CodeGen/StackProtector.cpp b/llvm/lib/CodeGen/StackProtector.cpp
index 9e1a29e61a12..0411faabbcc3 100644
--- a/llvm/lib/CodeGen/StackProtector.cpp
+++ b/llvm/lib/CodeGen/StackProtector.cpp
@@ -556,7 +556,9 @@ BasicBlock *StackProtector::CreateFailBB() {
   LLVMContext &Context = F->getContext();
   BasicBlock *FailBB = BasicBlock::Create(Context, "CallStackCheckFailBlk", F);
   IRBuilder<> B(FailBB);
-  B.SetCurrentDebugLocation(DebugLoc::get(0, 0, F->getSubprogram()));
+  if (F->getSubprogram())
+    B.SetCurrentDebugLocation(
+        DILocation::get(Context, 0, 0, F->getSubprogram()));
   if (Trip.isOSOpenBSD()) {
     FunctionCallee StackChkFail = M->getOrInsertFunction(
         "__stack_smash_handler", Type::getVoidTy(Context),

diff  --git a/llvm/unittests/CodeGen/LexicalScopesTest.cpp b/llvm/unittests/CodeGen/LexicalScopesTest.cpp
index 20975a775bf7..14f43bb39430 100644
--- a/llvm/unittests/CodeGen/LexicalScopesTest.cpp
+++ b/llvm/unittests/CodeGen/LexicalScopesTest.cpp
@@ -112,12 +112,12 @@ class LexicalScopesTest : public testing::Test {
                            DINode::FlagZero, DISubprogram::SPFlagDefinition);
 
     // Make some nested scopes.
-    OutermostLoc = DebugLoc::get(3, 1, OurFunc);
-    InBlockLoc = DebugLoc::get(4, 1, OurBlock);
-    InlinedLoc = DebugLoc::get(10, 1, ToInlineFunc, InBlockLoc.get());
+    OutermostLoc = DILocation::get(Ctx, 3, 1, OurFunc);
+    InBlockLoc = DILocation::get(Ctx, 4, 1, OurBlock);
+    InlinedLoc = DILocation::get(Ctx, 10, 1, ToInlineFunc, InBlockLoc.get());
 
     // Make a scope that isn't nested within the others.
-    NotNestedBlockLoc = DebugLoc::get(4, 1, AnotherBlock);
+    NotNestedBlockLoc = DILocation::get(Ctx, 4, 1, AnotherBlock);
 
     DIB.finalize();
   }

diff  --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index ad58fb837006..508c274b9b65 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -45,7 +45,7 @@ class OpenMPIRBuilderTest : public testing::Test {
     F->setSubprogram(SP);
     auto Scope = DIB.createLexicalBlockFile(SP, File, 0);
     DIB.finalize();
-    DL = DebugLoc::get(3, 7, Scope);
+    DL = DILocation::get(Ctx, 3, 7, Scope);
   }
 
   void TearDown() override {

diff  --git a/llvm/unittests/IR/IRBuilderTest.cpp b/llvm/unittests/IR/IRBuilderTest.cpp
index 204e476b8632..4a00d5658d82 100644
--- a/llvm/unittests/IR/IRBuilderTest.cpp
+++ b/llvm/unittests/IR/IRBuilderTest.cpp
@@ -770,7 +770,7 @@ TEST_F(IRBuilderTest, DIBuilder) {
       CU, "bar", "", File, 1, Type, 1, DINode::FlagZero,
       DISubprogram::SPFlagDefinition | DISubprogram::SPFlagOptimized);
   auto BadScope = DIB.createLexicalBlockFile(BarSP, File, 0);
-  I->setDebugLoc(DebugLoc::get(2, 0, BadScope));
+  I->setDebugLoc(DILocation::get(Ctx, 2, 0, BadScope));
   DIB.finalize();
   EXPECT_TRUE(verifyModule(*M));
 }
@@ -792,8 +792,8 @@ TEST_F(IRBuilderTest, createArtificialSubprogram) {
   F->setSubprogram(SP);
   AllocaInst *I = Builder.CreateAlloca(Builder.getInt8Ty());
   ReturnInst *R = Builder.CreateRetVoid();
-  I->setDebugLoc(DebugLoc::get(3, 2, SP));
-  R->setDebugLoc(DebugLoc::get(4, 2, SP));
+  I->setDebugLoc(DILocation::get(Ctx, 3, 2, SP));
+  R->setDebugLoc(DILocation::get(Ctx, 4, 2, SP));
   DIB.finalize();
   EXPECT_FALSE(verifyModule(*M));
 
@@ -821,7 +821,8 @@ TEST_F(IRBuilderTest, createArtificialSubprogram) {
   DebugLoc DL = I->getDebugLoc();
   DenseMap<const MDNode *, MDNode *> IANodes;
   auto IA = DebugLoc::appendInlinedAt(DL, InlinedAtNode, Ctx, IANodes);
-  auto NewDL = DebugLoc::get(DL.getLine(), DL.getCol(), DL.getScope(), IA);
+  auto NewDL =
+      DILocation::get(Ctx, DL.getLine(), DL.getCol(), DL.getScope(), IA);
   I->setDebugLoc(NewDL);
   EXPECT_FALSE(verifyModule(*M));
 

diff  --git a/llvm/unittests/Transforms/Utils/CloningTest.cpp b/llvm/unittests/Transforms/Utils/CloningTest.cpp
index 86b5e4f41cb2..016e772c2257 100644
--- a/llvm/unittests/Transforms/Utils/CloningTest.cpp
+++ b/llvm/unittests/Transforms/Utils/CloningTest.cpp
@@ -486,13 +486,15 @@ class CloneFunc : public ::testing::Test {
     // Function body
     BasicBlock* Entry = BasicBlock::Create(C, "", OldFunc);
     IBuilder.SetInsertPoint(Entry);
-    DebugLoc Loc = DebugLoc::get(3, 2, Subprogram);
+    DebugLoc Loc = DILocation::get(Subprogram->getContext(), 3, 2, Subprogram);
     IBuilder.SetCurrentDebugLocation(Loc);
     AllocaInst* Alloca = IBuilder.CreateAlloca(IntegerType::getInt32Ty(C));
-    IBuilder.SetCurrentDebugLocation(DebugLoc::get(4, 2, Subprogram));
+    IBuilder.SetCurrentDebugLocation(
+        DILocation::get(Subprogram->getContext(), 4, 2, Subprogram));
     Value* AllocaContent = IBuilder.getInt32(1);
     Instruction* Store = IBuilder.CreateStore(AllocaContent, Alloca);
-    IBuilder.SetCurrentDebugLocation(DebugLoc::get(5, 2, Subprogram));
+    IBuilder.SetCurrentDebugLocation(
+        DILocation::get(Subprogram->getContext(), 5, 2, Subprogram));
 
     // Create a local variable around the alloca
     auto *IntType = DBuilder.createBasicType("int", 32, dwarf::DW_ATE_signed);
@@ -515,8 +517,9 @@ class CloneFunc : public ::testing::Test {
         DBuilder.createAutoVariable(InlinedSP, "inlined", File, 5, StructType, true);
     auto *Scope = DBuilder.createLexicalBlock(
         DBuilder.createLexicalBlockFile(InlinedSP, File), File, 1, 1);
-    auto InlinedDL =
-        DebugLoc::get(9, 4, Scope, DebugLoc::get(5, 2, Subprogram));
+    auto InlinedDL = DILocation::get(
+        Subprogram->getContext(), 9, 4, Scope,
+        DILocation::get(Subprogram->getContext(), 5, 2, Subprogram));
     IBuilder.SetCurrentDebugLocation(InlinedDL);
     DBuilder.insertDeclare(Alloca, InlinedVar, E, InlinedDL, Store);
     IBuilder.CreateStore(IBuilder.getInt32(2), Alloca);


        


More information about the llvm-branch-commits mailing list