[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Arthur Eubanks via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG71d0a2b8a313: [DFSan][NewPM] Port DataFlowSanitizer to NewPM 
(authored by aeubanks).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -dfsan -S | FileCheck %s
+; RUN: opt < %s -passes=dfsan -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -119,7 +119,7 @@
   initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerPass(Registry);
+  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -46,6 +46,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
@@ -78,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -292,7 +294,7 @@
   llvm::makeArrayRef(ArgumentAttributes));
 }
 
-class DataFlowSanitizer : public ModulePass {
+class DataFlowSanitizer {
   friend struct DFSanFunction;
   friend class DFSanVisitor;
 
@@ -390,14 +392,12 @@
   void initializeCallbackFunctions(Module );
   void initializeRuntimeFunctions(Module );
 
-public:
-  static char ID;
+  bool init(Module );
 
-  DataFlowSanitizer(const std::vector  =
-std::vector());
+public:
+  DataFlowSanitizer(const std::vector );
 
-  bool doInitialization(Module ) override;
-  bool runOnModule(Module ) override;
+  bool runImpl(Module );
 };
 
 struct DFSanFunction {
@@ -482,19 +482,8 @@
 
 } // end anonymous namespace
 
-char DataFlowSanitizer::ID;
-
-INITIALIZE_PASS(DataFlowSanitizer, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerPass(
-const std::vector ) {
-  return new DataFlowSanitizer(ABIListFiles);
-}
-
 DataFlowSanitizer::DataFlowSanitizer(
-const std::vector )
-: ModulePass(ID) {
+const std::vector ) {
   std::vector AllABIListFiles(std::move(ABIListFiles));
   AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
  ClABIListFiles.end());
@@ -559,7 +548,7 @@
   ArgumentIndexMapping);
 }
 
-bool DataFlowSanitizer::doInitialization(Module ) {
+bool DataFlowSanitizer::init(Module ) {
   Triple TargetTriple(M.getTargetTriple());
   bool IsX86_64 = TargetTriple.getArch() == Triple::x86_64;
   bool IsMIPS64 = TargetTriple.isMIPS64();
@@ -785,7 +774,9 @@
 DFSanLoadStoreCmpCallbackFnTy);
 }
 
-bool DataFlowSanitizer::runOnModule(Module ) {
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+
   if (ABIList.isIn(M, "skip"))
 return false;
 
@@ -1817,3 +1808,37 @@
   DFSF.PHIFixups.push_back(std::make_pair(, ShadowPN));
   DFSF.setShadow(, ShadowPN);
 }
+
+class DataFlowSanitizerLegacyPass : public ModulePass {
+private:
+  std::vector ABIListFiles;
+
+public:
+  static char ID;
+
+  DataFlowSanitizerLegacyPass(
+  const std::vector  = std::vector())
+  : ModulePass(ID), 

[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse accepted this revision.
morehouse added a comment.

LGTM


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks added inline comments.



Comment at: llvm/lib/Passes/PassRegistry.def:92
 MODULE_PASS("verify", VerifierPass())
+MODULE_PASS("dfsan", DataFlowSanitizerPass())
 MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, 
false, true, false))

morehouse wrote:
> Nit:  maybe "dfsan-module" for consistency?
Almost all of the others have both a module and function pass, so the "-module" 
is to distinguish between those. I think sancov-module is the only one that 
doesn't fit that, and I actually did want to rename it to sancov.

I'd like to keep the name the same as the legacy pass for migration reasons 
(basically so I don't have to touch every dfsan test).



Comment at: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:778
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+

morehouse wrote:
> Do we need a bool to avoid calling `init` more than once?
A new `DataFlowSanitizer` is constructed for each `run`/`runOnModule` so that 
shouldn't be necessary.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-29 Thread Matt Morehouse via Phabricator via cfe-commits
morehouse added inline comments.



Comment at: llvm/lib/Passes/PassRegistry.def:92
 MODULE_PASS("verify", VerifierPass())
+MODULE_PASS("dfsan", DataFlowSanitizerPass())
 MODULE_PASS("asan-module", ModuleAddressSanitizerPass(/*CompileKernel=*/false, 
false, true, false))

Nit:  maybe "dfsan-module" for consistency?



Comment at: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp:778
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+

Do we need a bool to avoid calling `init` more than once?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks marked an inline comment as done.
aeubanks added inline comments.



Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:11
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"

ychen wrote:
> Is Function.h needed?
Nope, removed.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks updated this revision to Diff 281109.
aeubanks added a comment.

Address review comments


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -dfsan -S | FileCheck %s
+; RUN: opt < %s -passes=dfsan -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -119,7 +119,7 @@
   initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerPass(Registry);
+  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -46,6 +46,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
@@ -78,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -292,7 +294,7 @@
   llvm::makeArrayRef(ArgumentAttributes));
 }
 
-class DataFlowSanitizer : public ModulePass {
+class DataFlowSanitizer {
   friend struct DFSanFunction;
   friend class DFSanVisitor;
 
@@ -390,14 +392,12 @@
   void initializeCallbackFunctions(Module );
   void initializeRuntimeFunctions(Module );
 
-public:
-  static char ID;
+  bool init(Module );
 
-  DataFlowSanitizer(const std::vector  =
-std::vector());
+public:
+  DataFlowSanitizer(const std::vector );
 
-  bool doInitialization(Module ) override;
-  bool runOnModule(Module ) override;
+  bool runImpl(Module );
 };
 
 struct DFSanFunction {
@@ -482,19 +482,8 @@
 
 } // end anonymous namespace
 
-char DataFlowSanitizer::ID;
-
-INITIALIZE_PASS(DataFlowSanitizer, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerPass(
-const std::vector ) {
-  return new DataFlowSanitizer(ABIListFiles);
-}
-
 DataFlowSanitizer::DataFlowSanitizer(
-const std::vector )
-: ModulePass(ID) {
+const std::vector ) {
   std::vector AllABIListFiles(std::move(ABIListFiles));
   AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
  ClABIListFiles.end());
@@ -559,7 +548,7 @@
   ArgumentIndexMapping);
 }
 
-bool DataFlowSanitizer::doInitialization(Module ) {
+bool DataFlowSanitizer::init(Module ) {
   Triple TargetTriple(M.getTargetTriple());
   bool IsX86_64 = TargetTriple.getArch() == Triple::x86_64;
   bool IsMIPS64 = TargetTriple.isMIPS64();
@@ -785,7 +774,9 @@
 DFSanLoadStoreCmpCallbackFnTy);
 }
 
-bool DataFlowSanitizer::runOnModule(Module ) {
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+
   if (ABIList.isIn(M, "skip"))
 return false;
 
@@ -1817,3 +1808,37 @@
   DFSF.PHIFixups.push_back(std::make_pair(, ShadowPN));
   DFSF.setShadow(, ShadowPN);
 }
+
+class DataFlowSanitizerLegacyPass : public ModulePass {
+private:
+  std::vector ABIListFiles;
+
+public:
+  static char ID;
+
+  DataFlowSanitizerLegacyPass(
+  const std::vector  = std::vector())
+  : ModulePass(ID), ABIListFiles(ABIListFiles) {}
+
+  bool runOnModule(Module ) override {
+return DataFlowSanitizer(ABIListFiles).runImpl(M);
+  }
+};
+
+char 

[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Yuanfang Chen via Phabricator via cfe-commits
ychen accepted this revision.
ychen added a comment.
This revision is now accepted and ready to land.

LGTM with two nits. Please wait one day or two in case other reviewers want to 
have a look.




Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:8
+//===--===//
+#ifndef LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H
+#define LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZERPASS_H

LLVM_TRANSFORMS_INSTRUMENTATION_DATAFLOWSANITIZER_H



Comment at: llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h:11
+
+#include "llvm/IR/Function.h"
+#include "llvm/IR/Module.h"

Is Function.h needed?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D84707/new/

https://reviews.llvm.org/D84707



___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D84707: [DFSan][NewPM] Port DataFlowSanitizer to NewPM

2020-07-27 Thread Arthur Eubanks via Phabricator via cfe-commits
aeubanks created this revision.
Herald added subscribers: llvm-commits, cfe-commits, aaron.ballman, hiraditya.
Herald added projects: clang, LLVM.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D84707

Files:
  clang/lib/CodeGen/BackendUtil.cpp
  llvm/bindings/go/llvm/InstrumentationBindings.cpp
  llvm/include/llvm/InitializePasses.h
  llvm/include/llvm/Transforms/Instrumentation.h
  llvm/include/llvm/Transforms/Instrumentation/DataFlowSanitizer.h
  llvm/lib/Passes/PassBuilder.cpp
  llvm/lib/Passes/PassRegistry.def
  llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
  llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
  llvm/test/Instrumentation/DataFlowSanitizer/call.ll

Index: llvm/test/Instrumentation/DataFlowSanitizer/call.ll
===
--- llvm/test/Instrumentation/DataFlowSanitizer/call.ll
+++ llvm/test/Instrumentation/DataFlowSanitizer/call.ll
@@ -1,4 +1,5 @@
 ; RUN: opt < %s -dfsan -S | FileCheck %s
+; RUN: opt < %s -passes=dfsan -S | FileCheck %s
 target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64-S128"
 target triple = "x86_64-unknown-linux-gnu"
 
Index: llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
===
--- llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
+++ llvm/lib/Transforms/Instrumentation/Instrumentation.cpp
@@ -119,7 +119,7 @@
   initializeHWAddressSanitizerLegacyPassPass(Registry);
   initializeThreadSanitizerLegacyPassPass(Registry);
   initializeModuleSanitizerCoverageLegacyPassPass(Registry);
-  initializeDataFlowSanitizerPass(Registry);
+  initializeDataFlowSanitizerLegacyPassPass(Registry);
 }
 
 /// LLVMInitializeInstrumentation - C binding for
Index: llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
===
--- llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/DataFlowSanitizer.cpp
@@ -46,6 +46,7 @@
 //
 //===--===//
 
+#include "llvm/Transforms/Instrumentation/DataFlowSanitizer.h"
 #include "llvm/ADT/DenseMap.h"
 #include "llvm/ADT/DenseSet.h"
 #include "llvm/ADT/DepthFirstIterator.h"
@@ -78,6 +79,7 @@
 #include "llvm/IR/LLVMContext.h"
 #include "llvm/IR/MDBuilder.h"
 #include "llvm/IR/Module.h"
+#include "llvm/IR/PassManager.h"
 #include "llvm/IR/Type.h"
 #include "llvm/IR/User.h"
 #include "llvm/IR/Value.h"
@@ -292,7 +294,7 @@
   llvm::makeArrayRef(ArgumentAttributes));
 }
 
-class DataFlowSanitizer : public ModulePass {
+class DataFlowSanitizer {
   friend struct DFSanFunction;
   friend class DFSanVisitor;
 
@@ -390,14 +392,12 @@
   void initializeCallbackFunctions(Module );
   void initializeRuntimeFunctions(Module );
 
-public:
-  static char ID;
+  bool init(Module );
 
-  DataFlowSanitizer(const std::vector  =
-std::vector());
+public:
+  DataFlowSanitizer(const std::vector );
 
-  bool doInitialization(Module ) override;
-  bool runOnModule(Module ) override;
+  bool runImpl(Module );
 };
 
 struct DFSanFunction {
@@ -482,19 +482,8 @@
 
 } // end anonymous namespace
 
-char DataFlowSanitizer::ID;
-
-INITIALIZE_PASS(DataFlowSanitizer, "dfsan",
-"DataFlowSanitizer: dynamic data flow analysis.", false, false)
-
-ModulePass *llvm::createDataFlowSanitizerPass(
-const std::vector ) {
-  return new DataFlowSanitizer(ABIListFiles);
-}
-
 DataFlowSanitizer::DataFlowSanitizer(
-const std::vector )
-: ModulePass(ID) {
+const std::vector ) {
   std::vector AllABIListFiles(std::move(ABIListFiles));
   AllABIListFiles.insert(AllABIListFiles.end(), ClABIListFiles.begin(),
  ClABIListFiles.end());
@@ -559,7 +548,7 @@
   ArgumentIndexMapping);
 }
 
-bool DataFlowSanitizer::doInitialization(Module ) {
+bool DataFlowSanitizer::init(Module ) {
   Triple TargetTriple(M.getTargetTriple());
   bool IsX86_64 = TargetTriple.getArch() == Triple::x86_64;
   bool IsMIPS64 = TargetTriple.isMIPS64();
@@ -785,7 +774,9 @@
 DFSanLoadStoreCmpCallbackFnTy);
 }
 
-bool DataFlowSanitizer::runOnModule(Module ) {
+bool DataFlowSanitizer::runImpl(Module ) {
+  init(M);
+
   if (ABIList.isIn(M, "skip"))
 return false;
 
@@ -1817,3 +1808,37 @@
   DFSF.PHIFixups.push_back(std::make_pair(, ShadowPN));
   DFSF.setShadow(, ShadowPN);
 }
+
+class DataFlowSanitizerLegacyPass : public ModulePass {
+private:
+  std::vector ABIListFiles;
+
+public:
+  static char ID;
+
+  DataFlowSanitizerLegacyPass(
+  const std::vector  = std::vector())
+  : ModulePass(ID), ABIListFiles(ABIListFiles) {}
+
+  bool runOnModule(Module ) override {
+return DataFlowSanitizer(ABIListFiles).runImpl(M);
+  }
+};
+
+char