[clang] f46fa4d - Revert "[clang][debug] port clang-cl /JMC flag to ELF"

Yuanfang Chen via cfe-commits cfe-commits at lists.llvm.org
Mon Mar 7 12:40:55 PST 2022


Author: Yuanfang Chen
Date: 2022-03-07T12:40:43-08:00
New Revision: f46fa4de4a95329b74ba0bb4ce9623b64ad84876

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

LOG: Revert "[clang][debug] port clang-cl /JMC flag to ELF"

This reverts commit 731347431976509823e38329a96fcbc69fe98cd2.

Break bots:
http://45.33.8.238/win/54551/step_7.txt
http://45.33.8.238/macm1/29590/step_7.txt

Added: 
    

Modified: 
    clang/include/clang/Basic/DiagnosticDriverKinds.td
    clang/include/clang/Driver/Options.td
    clang/lib/Driver/ToolChains/Clang.cpp
    clang/test/Driver/cl-options.c
    clang/test/Driver/clang_f_opts.c
    llvm/lib/CodeGen/JMCInstrumenter.cpp
    llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
    llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll

Removed: 
    llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll


################################################################################
diff  --git a/clang/include/clang/Basic/DiagnosticDriverKinds.td b/clang/include/clang/Basic/DiagnosticDriverKinds.td
index 65b6d606a9dd0..1ac5bf844efe6 100644
--- a/clang/include/clang/Basic/DiagnosticDriverKinds.td
+++ b/clang/include/clang/Basic/DiagnosticDriverKinds.td
@@ -634,8 +634,7 @@ def err_drv_cuda_offload_only_emit_bc : Error<
   "CUDA offload target is supported only along with --emit-llvm">;
 
 def warn_drv_jmc_requires_debuginfo : Warning<
-  "%0 requires debug info. Use %1 or debug options that enable debugger's "
-  "stepping function; option ignored">,
+  "/JMC requires debug info. Use '/Zi', '/Z7' or other debug options; option ignored">,
   InGroup<OptionIgnored>;
 
 def err_drv_target_variant_invalid : Error<

diff  --git a/clang/include/clang/Driver/Options.td b/clang/include/clang/Driver/Options.td
index 351eb674a109b..24e2069711be5 100644
--- a/clang/include/clang/Driver/Options.td
+++ b/clang/include/clang/Driver/Options.td
@@ -1462,7 +1462,6 @@ def feliminate_unused_debug_symbols : Flag<["-"], "feliminate-unused-debug-symbo
 def fjmc : Flag<["-"], "fjmc">, Group<f_Group>,Flags<[CC1Option]>,
     HelpText<"Enable just-my-code debugging">,
     MarshallingInfoFlag<CodeGenOpts<"JMCInstrument">>;
-def fno_jmc : Flag<["-"], "fno-jmc">, Group<f_Group>, Flags<[CC1Option]>;
 defm eliminate_unused_debug_types : OptOutCC1FFlag<"eliminate-unused-debug-types",
   "Do not emit ", "Emit ", " debug info for defined but unused types">;
 def femit_all_decls : Flag<["-"], "femit-all-decls">, Group<f_Group>, Flags<[CC1Option]>,

diff  --git a/clang/lib/Driver/ToolChains/Clang.cpp b/clang/lib/Driver/ToolChains/Clang.cpp
index 92da7a748ea8c..7cb8df6e44c04 100644
--- a/clang/lib/Driver/ToolChains/Clang.cpp
+++ b/clang/lib/Driver/ToolChains/Clang.cpp
@@ -5392,16 +5392,6 @@ void Clang::ConstructJob(Compilation &C, const JobAction &JA,
                      types::isLLVMIR(InputType), CmdArgs, DebugInfoKind,
                      DwarfFission);
 
-  // This controls whether or not we perform JustMyCode instrumentation.
-  if (TC.getTriple().isOSBinFormatELF() &&
-      Args.hasFlag(options::OPT_fjmc, options::OPT_fno_jmc, false)) {
-    if (DebugInfoKind >= codegenoptions::DebugInfoConstructor)
-      CmdArgs.push_back("-fjmc");
-    else
-      D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "-fjmc"
-                                                           << "-g";
-  }
-
   // Add the split debug info name to the command lines here so we
   // can propagate it to the backend.
   bool SplitDWARF = (DwarfFission != DwarfFissionKind::None) &&
@@ -7543,8 +7533,7 @@ void Clang::AddClangCLArgs(const ArgList &Args, types::ID InputType,
     if (*EmitCodeView && *DebugInfoKind >= codegenoptions::DebugInfoConstructor)
       CmdArgs.push_back("-fjmc");
     else
-      D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo) << "/JMC"
-                                                           << "'/Zi', '/Z7'";
+      D.Diag(clang::diag::warn_drv_jmc_requires_debuginfo);
   }
 
   EHFlags EH = parseClangCLEHFlags(D, Args);

diff  --git a/clang/test/Driver/cl-options.c b/clang/test/Driver/cl-options.c
index f332cd83b26e4..4a8a1b3c5ac4e 100644
--- a/clang/test/Driver/cl-options.c
+++ b/clang/test/Driver/cl-options.c
@@ -779,7 +779,7 @@
 // TARGET: "-triple" "i686-pc-windows-msvc19.14.0"
 
 // RUN: %clang_cl /JMC /c -### -- %s 2>&1 | FileCheck %s --check-prefix JMCWARN
-// JMCWARN: /JMC requires debug info. Use '/Zi', '/Z7' or debug options that enable debugger's stepping function; option ignored
+// JMCWARN: /JMC requires debug info. Use '/Zi', '/Z7' or other debug options; option ignored
 
 // RUN: %clang_cl /JMC /c -### -- %s 2>&1 | FileCheck %s --check-prefix NOJMC
 // RUN: %clang_cl /JMC /Z7 /JMC- /c -### -- %s 2>&1 | FileCheck %s --check-prefix NOJMC

diff  --git a/clang/test/Driver/clang_f_opts.c b/clang/test/Driver/clang_f_opts.c
index dca7d8c9e83ba..4b0159b80f739 100644
--- a/clang/test/Driver/clang_f_opts.c
+++ b/clang/test/Driver/clang_f_opts.c
@@ -597,10 +597,3 @@
 // RUN: %clang -### -xobjective-c %s 2>&1 | FileCheck -check-prefix=CHECK_NO_DISABLE_DIRECT %s
 // CHECK_DISABLE_DIRECT: -fobjc-disable-direct-methods-for-testing
 // CHECK_NO_DISABLE_DIRECT-NOT: -fobjc-disable-direct-methods-for-testing
-
-// RUN: %clang -### -S -fjmc %s 2>&1 | FileCheck -check-prefixes=CHECK_JMC_WARN,CHECK_NOJMC %s
-// RUN: %clang -### -S -fjmc -g %s 2>&1 | FileCheck -check-prefix=CHECK_JMC %s
-// RUN: %clang -### -S -fjmc -g -fno-jmc %s 2>&1 | FileCheck -check-prefix=CHECK_NOJMC %s
-// CHECK_JMC_WARN: -fjmc requires debug info. Use -g or debug options that enable debugger's stepping function; option ignored
-// CHECK_NOJMC-NOT: -fjmc
-// CHECK_JMC: -fjmc

diff  --git a/llvm/lib/CodeGen/JMCInstrumenter.cpp b/llvm/lib/CodeGen/JMCInstrumenter.cpp
index 69967d02550ab..b9f686f0782eb 100644
--- a/llvm/lib/CodeGen/JMCInstrumenter.cpp
+++ b/llvm/lib/CodeGen/JMCInstrumenter.cpp
@@ -7,17 +7,14 @@
 //===----------------------------------------------------------------------===//
 //
 // JMCInstrumenter pass:
+// - add "/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default" to
+//   "llvm.linker.options"
+// - create the dummy COMDAT function __JustMyCode_Default
 // - instrument each function with a call to __CheckForDebuggerJustMyCode. The
 //   sole argument should be defined in .msvcjmc. Each flag is 1 byte initilized
 //   to 1.
-// - create the dummy COMDAT function __JustMyCode_Default to prevent linking
-//   error if __CheckForDebuggerJustMyCode is not available.
-// - For MSVC:
-//   add "/alternatename:__CheckForDebuggerJustMyCode=__JustMyCode_Default" to
-//   "llvm.linker.options"
-//   For ELF:
-//   Rename __JustMyCode_Default to __CheckForDebuggerJustMyCode and mark it as
-//   weak symbol.
+// - (TODO) currently targeting MSVC, adds ELF debuggers support
+//
 //===----------------------------------------------------------------------===//
 
 #include "llvm/ADT/SmallString.h"
@@ -113,7 +110,7 @@ FunctionType *getCheckFunctionType(LLVMContext &Ctx) {
   return FunctionType::get(VoidTy, VoidPtrTy, false);
 }
 
-Function *createDefaultCheckFunction(Module &M, bool UseX86FastCall) {
+void createDefaultCheckFunction(Module &M, bool UseX86FastCall) {
   LLVMContext &Ctx = M.getContext();
   const char *DefaultCheckFunctionName =
       UseX86FastCall ? "_JustMyCode_Default" : "__JustMyCode_Default";
@@ -125,10 +122,21 @@ Function *createDefaultCheckFunction(Module &M, bool UseX86FastCall) {
   DefaultCheckFunc->addParamAttr(0, Attribute::NoUndef);
   if (UseX86FastCall)
     DefaultCheckFunc->addParamAttr(0, Attribute::InReg);
-
+  appendToUsed(M, {DefaultCheckFunc});
+  Comdat *C = M.getOrInsertComdat(DefaultCheckFunctionName);
+  C->setSelectionKind(Comdat::Any);
+  DefaultCheckFunc->setComdat(C);
   BasicBlock *EntryBB = BasicBlock::Create(Ctx, "", DefaultCheckFunc);
   ReturnInst::Create(Ctx, EntryBB);
-  return DefaultCheckFunc;
+
+  // Add a linker option /alternatename to set the default implementation for
+  // the check function.
+  // https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024
+  std::string AltOption = std::string("/alternatename:") + CheckFunctionName +
+                          "=" + DefaultCheckFunctionName;
+  llvm::Metadata *Ops[] = {llvm::MDString::get(Ctx, AltOption)};
+  MDTuple *N = MDNode::get(Ctx, Ops);
+  M.getOrInsertNamedMetadata("llvm.linker.options")->addOperand(N);
 }
 } // namespace
 
@@ -136,13 +144,10 @@ bool JMCInstrumenter::runOnModule(Module &M) {
   bool Changed = false;
   LLVMContext &Ctx = M.getContext();
   Triple ModuleTriple(M.getTargetTriple());
-  bool IsMSVC = ModuleTriple.isKnownWindowsMSVCEnvironment();
-  bool IsELF = ModuleTriple.isOSBinFormatELF();
-  assert((IsELF || IsMSVC) && "Unsupported triple for JMC");
-  bool UseX86FastCall = IsMSVC && ModuleTriple.getArch() == Triple::x86;
-  const char *const FlagSymbolSection = IsELF ? ".just.my.code" : ".msvcjmc";
+  bool UseX86FastCall =
+      ModuleTriple.isOSWindows() && ModuleTriple.getArch() == Triple::x86;
 
-  GlobalValue *CheckFunction = nullptr;
+  Function *CheckFunction = nullptr;
   DenseMap<DISubprogram *, Constant *> SavedFlags(8);
   for (auto &F : M) {
     if (F.isDeclaration())
@@ -161,7 +166,7 @@ bool JMCInstrumenter::runOnModule(Module &M) {
         GlobalVariable *GV = new GlobalVariable(
             M, FlagTy, /*isConstant=*/false, GlobalValue::InternalLinkage,
             ConstantInt::get(FlagTy, 1), FlagName);
-        GV->setSection(FlagSymbolSection);
+        GV->setSection(".msvcjmc");
         GV->setAlignment(Align(1));
         GV->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
         attachDebugInfo(*GV, *SP);
@@ -170,46 +175,22 @@ bool JMCInstrumenter::runOnModule(Module &M) {
     }
 
     if (!CheckFunction) {
-      Function *DefaultCheckFunc =
-          createDefaultCheckFunction(M, UseX86FastCall);
-      if (IsELF) {
-        DefaultCheckFunc->setName(CheckFunctionName);
-        DefaultCheckFunc->setLinkage(GlobalValue::WeakAnyLinkage);
-        CheckFunction = DefaultCheckFunc;
-      } else {
-        assert(!M.getFunction(CheckFunctionName) &&
-               "JMC instrument more than once?");
-        auto *CheckFunc = cast<Function>(
-            M.getOrInsertFunction(CheckFunctionName, getCheckFunctionType(Ctx))
-                .getCallee());
-        CheckFunc->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
-        CheckFunc->addParamAttr(0, Attribute::NoUndef);
-        if (UseX86FastCall) {
-          CheckFunc->setCallingConv(CallingConv::X86_FastCall);
-          CheckFunc->addParamAttr(0, Attribute::InReg);
-        }
-        CheckFunction = CheckFunc;
-
-        StringRef DefaultCheckFunctionName = DefaultCheckFunc->getName();
-        appendToUsed(M, {DefaultCheckFunc});
-        Comdat *C = M.getOrInsertComdat(DefaultCheckFunctionName);
-        C->setSelectionKind(Comdat::Any);
-        DefaultCheckFunc->setComdat(C);
-        // Add a linker option /alternatename to set the default implementation
-        // for the check function.
-        // https://devblogs.microsoft.com/oldnewthing/20200731-00/?p=104024
-        std::string AltOption = std::string("/alternatename:") +
-                                CheckFunctionName + "=" +
-                                DefaultCheckFunctionName.str();
-        llvm::Metadata *Ops[] = {llvm::MDString::get(Ctx, AltOption)};
-        MDTuple *N = MDNode::get(Ctx, Ops);
-        M.getOrInsertNamedMetadata("llvm.linker.options")->addOperand(N);
+      assert(!M.getFunction(CheckFunctionName) &&
+             "JMC instrument more than once?");
+      CheckFunction = cast<Function>(
+          M.getOrInsertFunction(CheckFunctionName, getCheckFunctionType(Ctx))
+              .getCallee());
+      CheckFunction->setUnnamedAddr(GlobalValue::UnnamedAddr::Global);
+      CheckFunction->addParamAttr(0, Attribute::NoUndef);
+      if (UseX86FastCall) {
+        CheckFunction->setCallingConv(CallingConv::X86_FastCall);
+        CheckFunction->addParamAttr(0, Attribute::InReg);
       }
     }
     // FIXME: it would be nice to make CI scheduling boundary, although in
     //        practice it does not matter much.
-    auto *CI = CallInst::Create(getCheckFunctionType(Ctx), CheckFunction,
-                                {Flag}, "", &*F.begin()->getFirstInsertionPt());
+    auto *CI = CallInst::Create(CheckFunction, {Flag}, "",
+                                &*F.begin()->getFirstInsertionPt());
     CI->addParamAttr(0, Attribute::NoUndef);
     if (UseX86FastCall) {
       CI->setCallingConv(CallingConv::X86_FastCall);
@@ -218,5 +199,9 @@ bool JMCInstrumenter::runOnModule(Module &M) {
 
     Changed = true;
   }
-  return Changed;
+  if (!Changed)
+    return false;
+
+  createDefaultCheckFunction(M, UseX86FastCall);
+  return true;
 }

diff  --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
deleted file mode 100644
index 7ee2df759c6bd..0000000000000
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-elf.ll
+++ /dev/null
@@ -1,115 +0,0 @@
-; REQUIRES: system-linux
-; RUN: opt -jmc-instrument -mtriple=x86_64-unknown-linux-gnu  -S < %s | FileCheck %s
-
-; CHECK: @"__7DF23CF5_x at c" = internal unnamed_addr global i8 1, section ".just.my.code", align 1, !dbg !0
-; CHECK: @"__A85D9D03_x at c" = internal unnamed_addr global i8 1, section ".just.my.code", align 1, !dbg !5
-
-; CHECK: define void @l1() !dbg !12 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define void @l2() !dbg !16 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__7DF23CF5_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define void @w1() !dbg !18 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define void @w2() !dbg !19 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define void @w3() !dbg !21 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define void @w4() !dbg !23 {
-; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__A85D9D03_x at c")
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: define weak void @__CheckForDebuggerJustMyCode(i8* noundef %0) unnamed_addr {
-; CHECK:   ret void
-; CHECK: }
-
-; CHECK: !llvm.dbg.cu = !{!2}
-; CHECK: !llvm.module.flags = !{!9, !10}
-; CHECK: !llvm.ident = !{!11}
-
-; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
-; CHECK: !1 = distinct !DIGlobalVariable(name: "__7DF23CF5_x at c", scope: !2, file: !3, type: !8, isLocal: true, isDefinition: true)
-; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)
-; CHECK: !3 = !DIFile(filename: "a/x.c", directory: "/tmp")
-; CHECK: !4 = !{!0, !5}
-; CHECK: !5 = !DIGlobalVariableExpression(var: !6, expr: !DIExpression())
-; CHECK: !6 = distinct !DIGlobalVariable(name: "__A85D9D03_x at c", scope: !2, file: !7, type: !8, isLocal: true, isDefinition: true)
-; CHECK: !7 = !DIFile(filename: "./x.c", directory: "C:\\\\a\\\\b\\\\")
-; CHECK: !8 = !DIBasicType(name: "unsigned char", size: 8, encoding: DW_ATE_unsigned_char, flags: DIFlagArtificial)
-; CHECK: !9 = !{i32 2, !"CodeView", i32 1}
-; CHECK: !10 = !{i32 2, !"Debug Info Version", i32 3}
-; CHECK: !11 = !{!"clang"}
-; CHECK: !12 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !13 = !DISubroutineType(types: !14)
-; CHECK: !14 = !{null}
-; CHECK: !15 = !{}
-; CHECK: !16 = distinct !DISubprogram(name: "f", scope: !17, file: !17, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !17 = !DIFile(filename: "x.c", directory: "/tmp/a")
-; CHECK: !18 = distinct !DISubprogram(name: "f", scope: !7, file: !7, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !19 = distinct !DISubprogram(name: "f", scope: !20, file: !20, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !20 = !DIFile(filename: "./b\\x.c", directory: "C:\\\\a\\\\")
-; CHECK: !21 = distinct !DISubprogram(name: "f", scope: !22, file: !22, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !22 = !DIFile(filename: "./b/x.c", directory: "C:\\\\a\\\\")
-; CHECK: !23 = distinct !DISubprogram(name: "f", scope: !24, file: !24, line: 1, type: !13, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !2, retainedNodes: !15)
-; CHECK: !24 = !DIFile(filename: "./b/./../b/x.c", directory: "C:\\\\a")
-
-; All use the same flag
-define void @l1() !dbg !10 {
-  ret void
-}
-define void @l2() !dbg !11 {
-  ret void
-}
-
-; All use the same flag
-define void @w1() !dbg !12 {
-  ret void
-}
-define void @w2() !dbg !13 {
-  ret void
-}
-define void @w3() !dbg !14 {
-  ret void
-}
-define void @w4() !dbg !15 {
-  ret void
-}
-
-!llvm.dbg.cu = !{!0}
-!llvm.module.flags = !{!7, !8}
-!llvm.ident = !{!9}
-
-!0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, splitDebugInlining: false, nameTableKind: None)
-!1 = !DIFile(filename: "a/x.c", directory: "/tmp")
-!2 = !DIFile(filename: "x.c", directory: "/tmp/a")
-!3 = !DIFile(filename: "./x.c", directory: "C:\\\\a\\\\b\\\\")
-!4 = !DIFile(filename: "./b\\x.c", directory: "C:\\\\a\\\\")
-!5 = !DIFile(filename: "./b/x.c", directory: "C:\\\\a\\\\")
-!6 = !DIFile(filename: "./b/./../b/x.c", directory: "C:\\\\a")
-!7 = !{i32 2, !"CodeView", i32 1}
-!8 = !{i32 2, !"Debug Info Version", i32 3}
-!9 = !{!"clang"}
-!10 = distinct !DISubprogram(name: "f", scope: !1, file: !1, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!11 = distinct !DISubprogram(name: "f", scope: !2, file: !2, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!12 = distinct !DISubprogram(name: "f", scope: !3, file: !3, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!13 = distinct !DISubprogram(name: "f", scope: !4, file: !4, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!14 = distinct !DISubprogram(name: "f", scope: !5, file: !5, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!15 = distinct !DISubprogram(name: "f", scope: !6, file: !6, line: 1, type: !31, scopeLine: 1, spFlags: DISPFlagDefinition, unit: !0, retainedNodes: !33)
-!31 = !DISubroutineType(types: !32)
-!32 = !{null}
-!33 = !{}

diff  --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
index 3a6fa528a6bac..b864c4b7df63c 100644
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
+++ b/llvm/test/Instrumentation/JustMyCode/jmc-instrument-x86.ll
@@ -11,12 +11,12 @@
 ; CHECK:   ret void
 ; CHECK: }
 
+; CHECK: declare x86_fastcallcc void @__CheckForDebuggerJustMyCode(i8* inreg noundef) unnamed_addr
+
 ; CHECK: define void @_JustMyCode_Default(i8* inreg noundef %0) unnamed_addr comdat {
 ; CHECK:   ret void
 ; CHECK: }
 
-; CHECK: declare x86_fastcallcc void @__CheckForDebuggerJustMyCode(i8* inreg noundef) unnamed_addr
-
 ; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())
 ; CHECK: !1 = distinct !DIGlobalVariable(name: "_A8764FDD_x at c", scope: !2, file: !3, type: !5, isLocal: true, isDefinition: true)
 ; CHECK: !2 = distinct !DICompileUnit(language: DW_LANG_C99, file: !3, producer: "clang", isOptimized: false, runtimeVersion: 0, emissionKind: FullDebug, globals: !4, splitDebugInlining: false, nameTableKind: None)

diff  --git a/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll b/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
index a9444808f199b..61c03fa40a37e 100644
--- a/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
+++ b/llvm/test/Instrumentation/JustMyCode/jmc-instrument.ll
@@ -6,8 +6,8 @@
 ; CHECK: $__JustMyCode_Default = comdat any
 
 ; CHECK: @"__E6EA670F_x at c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !0
-; CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
 ; CHECK: @"__A8764FDD_x at c" = internal unnamed_addr global i8 1, section ".msvcjmc", align 1, !dbg !5
+; CHECK: @llvm.used = appending global [1 x i8*] [i8* bitcast (void (i8*)* @__JustMyCode_Default to i8*)], section "llvm.metadata"
 
 ; CHECK: define void @l1() !dbg !13 {
 ; CHECK:   call void @__CheckForDebuggerJustMyCode(i8* noundef @"__E6EA670F_x at c")
@@ -39,12 +39,12 @@
 ; CHECK:   ret void
 ; CHECK: }
 
+; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
+
 ; CHECK: define void @__JustMyCode_Default(i8* noundef %0) unnamed_addr comdat {
 ; CHECK:   ret void
 ; CHECK: }
 
-; CHECK: declare void @__CheckForDebuggerJustMyCode(i8* noundef) unnamed_addr
-
 ; CHECK: !llvm.linker.options = !{!12}
 
 ; CHECK: !0 = !DIGlobalVariableExpression(var: !1, expr: !DIExpression())


        


More information about the cfe-commits mailing list