Commit cdad89b8 authored by Patrick McCormick's avatar Patrick McCormick
Browse files

Updates to update the cilksan passes for the new cilktools runtime target.

Note: TODO - cilk pieces need to be removed entirely from compiler-rt.
parent 10d91924
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -170,10 +170,13 @@ inline CallInst *extractCallocCall(Value *I, const TargetLibraryInfo *TLI) {
bool isLibFreeFunction(const Function *F, const LibFunc TLIFn);

/// isFreeCall - Returns non-null if the value is a call to the builtin free()
const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI);
const CallInst *isFreeCall(const Value *I, const TargetLibraryInfo *TLI,
                           bool IgnoreBuiltinAttr = false);

inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI) {
  return const_cast<CallInst*>(isFreeCall((const Value*)I, TLI));
inline CallInst *isFreeCall(Value *I, const TargetLibraryInfo *TLI,
                            bool IgnoreBuiltinAttr = false) {
  return const_cast<CallInst *>(
      isFreeCall((const Value *)I, TLI, IgnoreBuiltinAttr));
}

//===----------------------------------------------------------------------===//
+26 −17
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ static const char *const CsiDisableInstrumentationName =
using csi_id_t = int64_t;
static const csi_id_t CsiUnknownId = -1;
static const csi_id_t CsiCallsiteUnknownTargetId = CsiUnknownId;
// See llvm/tools/clang/lib/CodeGen/CodeGenModule.h:
// See clang/lib/CodeGen/CodeGenModule.h:
static const int CsiUnitCtorPriority = 0;

/// Maintains a mapping from CSI ID to static data for that ID.
@@ -803,6 +803,7 @@ public:
                        IntegerType::get(C, PropBits.IsConstant),
                        IntegerType::get(C, PropBits.IsOnStack),
                        IntegerType::get(C, PropBits.MayBeCaptured),
                        IntegerType::get(C, PropBits.IsAtomic),
                        IntegerType::get(C, PropBits.LoadReadBeforeWriteInBB),
                        IntegerType::get(C, PropBits.Padding)));
  }
@@ -844,6 +845,8 @@ public:
  void setIsOnStack(bool v) { PropValue.Fields.IsOnStack = v; }
  /// Set the value of the MayBeCaptured property.
  void setMayBeCaptured(bool v) { PropValue.Fields.MayBeCaptured = v; }
  /// Set the value of the IsAtomic property.
  void setIsAtomic(bool v) { PropValue.Fields.IsAtomic = v; }
  /// Set the value of the LoadReadBeforeWriteInBB property.
  void setLoadReadBeforeWriteInBB(bool v) {
    PropValue.Fields.LoadReadBeforeWriteInBB = v;
@@ -858,8 +861,9 @@ private:
      unsigned IsConstant : 1;
      unsigned IsOnStack : 1;
      unsigned MayBeCaptured : 1;
      unsigned IsAtomic : 1;
      unsigned LoadReadBeforeWriteInBB : 1;
      uint64_t Padding : 53;
      uint64_t Padding : 50;
    } Fields;
    uint64_t Bits;
  } Property;
@@ -873,13 +877,14 @@ private:
    int IsConstant;
    int IsOnStack;
    int MayBeCaptured;
    int IsAtomic;
    int LoadReadBeforeWriteInBB;
    int Padding;
  } PropertyBits;

  /// The number of bits representing each property.
  static constexpr PropertyBits PropBits = {
      8, 1, 1, 1, 1, 1, (64 - 8 - 1 - 1 - 1 - 1 - 1)};
      8, 1, 1, 1, 1, 1, 1, (64 - 8 - 1 - 1 - 1 - 1 - 1 - 1)};
};

class CsiAllocaProperty : public CsiProperty {
@@ -1049,18 +1054,6 @@ public:
        Options(Options) {
    loadConfiguration();
  }
  CSIImpl(Module &M, CallGraph *CG,
          function_ref<DominatorTree &(Function &)> GetDomTree,
          function_ref<LoopInfo &(Function &)> GetLoopInfo,
          function_ref<TaskInfo &(Function &)> GetTaskInfo,
          function_ref<TargetLibraryInfo &(Function &)> GetTLI,
          function_ref<ScalarEvolution &(Function &)> GetSE,
          const CSIOptions &Options = CSIOptions())
      : M(M), DL(M.getDataLayout()), CG(CG), GetDomTree(GetDomTree),
        GetLoopInfo(GetLoopInfo), GetTaskInfo(GetTaskInfo), GetTLI(GetTLI), 
        GetScalarEvolution(GetSE), Options(Options) {
    loadConfiguration();
  }

  virtual ~CSIImpl() {}

@@ -1073,7 +1066,7 @@ public:
  static bool isVtableAccess(Instruction *I);
  static bool addrPointsToConstantData(Value *Addr);
  static bool isAtomic(Instruction *I);
  static void getAllocFnArgs(const Instruction *I,
  static bool getAllocFnArgs(const Instruction *I,
                             SmallVectorImpl<Value *> &AllocFnArgs,
                             Type *SizeTy, Type *AddrTy,
                             const TargetLibraryInfo &TLI);
@@ -1095,6 +1088,9 @@ public:

  static bool spawnsTapirLoopBody(DetachInst *DI, LoopInfo &LI, TaskInfo &TI);

  static BasicBlock::iterator
  getFirstInsertionPtInDetachedBlock(BasicBlock *Detached);

protected:
  /// Initialize the CSI pass.
  void initializeCsi();
@@ -1239,6 +1235,9 @@ protected:
    ZnwmSt11align_val_tRKSt9nothrow_t,
    ZnajSt11align_val_tRKSt9nothrow_t,
    ZnamSt11align_val_tRKSt9nothrow_t,
    posix_memalign,
    strdup,
    strndup,
    LAST_ALLOCFNTY
  };

@@ -1250,8 +1249,8 @@ protected:
      return AllocFnTy::malloc;
    case LibFunc_valloc:
      return AllocFnTy::valloc;
      // aligned_alloc(align_val_t, size_t)
    case LibFunc_aligned_alloc:
      // aligned_alloc(align_val_t, size_t)
      return AllocFnTy::aligned_alloc;
    case LibFunc_calloc:
      return AllocFnTy::calloc;
@@ -1331,6 +1330,15 @@ protected:
    case LibFunc_ZnamSt11align_val_tRKSt9nothrow_t:
      // new[](unsigned long, align_val_t, nothrow)
      return AllocFnTy::ZnamSt11align_val_tRKSt9nothrow_t;
    case LibFunc_posix_memalign:
      // posix_memalign(void **, size_t, size_t)
      return AllocFnTy::posix_memalign;
    case LibFunc_strdup:
      // strdup(const char *)
      return AllocFnTy::strdup;
    case LibFunc_strndup:
      // strdup(const char *, size_t)
      return AllocFnTy::strndup;
    }
  }

@@ -1496,6 +1504,7 @@ protected:

  DenseMap<std::pair<BasicBlock *, Function *>,
           SmallVector<PHINode *, 4>> ArgPHIs;
  SmallPtrSet<SyncInst *, 12> SyncsWithUnwinds;
  DenseMap<BasicBlock *, CallInst *> callsAfterSync;
  std::unique_ptr<InstrumentationConfig> Config;

+9 −8
Original line number Diff line number Diff line
@@ -43,6 +43,10 @@ bool isDetachedRethrow(const Instruction *I, const Value *SyncRegion = nullptr);
/// taskframe.resume uses \p TaskFrame.
bool isTaskFrameResume(const Instruction *I, const Value *TaskFrame = nullptr);

/// Returns true if the given basic block \p B is a placeholder successor of a
/// taskframe.resume or detached.rethrow.
bool isTapirPlaceholderSuccessor(const BasicBlock *B);

/// Returns a taskframe.resume that uses the given taskframe, or nullptr if no
/// taskframe.resume uses this taskframe.
InvokeInst *getTaskFrameResume(Value *TaskFrame);
@@ -61,9 +65,10 @@ bool isSyncUnwind(const Instruction *I, const Value *SyncRegion = nullptr);
/// instructions.
bool isPlaceholderSuccessor(const BasicBlock *B);

/// Returns true if the given basic block ends a taskframe, false otherwise.  If
/// \p TaskFrame is specified, then additionally checks that the
/// taskframe.end uses \p TaskFrame.
/// Returns true if the given basic block ends a taskframe, false otherwise.  In
/// particular, this method checks if the penultimate instruction in the basic
/// block is a taskframe.end intrinsic call.  If \p TaskFrame is specified, then
/// additionally checks that the taskframe.end uses \p TaskFrame.
bool endsTaskFrame(const BasicBlock *B, const Value *TaskFrame = nullptr);

/// Returns the spindle containing the taskframe.create used by task \p T, or
@@ -218,7 +223,6 @@ public:
  enum SpawningStrategy {
    ST_SEQ,
    ST_DAC,
    ST_OCL,
    ST_END,
  };

@@ -260,12 +264,9 @@ public:
      return "Spawn iterations sequentially";
    case TapirLoopHints::ST_DAC:
      return "Use divide-and-conquer";
    case TapirLoopHints::ST_OCL:
      return "Use opencl";
    case TapirLoopHints::ST_END:
      return "Unknown";
    }
    return "Unknown";
  }

  TapirLoopHints(const Loop *L)
@@ -310,7 +311,7 @@ public:
  }

  void setAlreadyStripMined() {
    //Grainsize.Value = 1;
    Grainsize.Value = 1;
    Hint Hints[] = {Grainsize};
    writeHintsToMetadata(Hints);
  }
+3 −2
Original line number Diff line number Diff line
@@ -465,11 +465,12 @@ bool llvm::isLibFreeFunction(const Function *F, const LibFunc TLIFn) {
}

/// isFreeCall - Returns non-null if the value is a call to the builtin free()
const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI) {
const CallInst *llvm::isFreeCall(const Value *I, const TargetLibraryInfo *TLI,
                                 bool IgnoreBuiltinAttr) {
  bool IsNoBuiltinCall;
  const Function *Callee =
      getCalledFunction(I, /*LookThroughBitCast=*/false, IsNoBuiltinCall);
  if (Callee == nullptr || IsNoBuiltinCall)
  if (Callee == nullptr || (IsNoBuiltinCall && !IgnoreBuiltinAttr))
    return nullptr;

  StringRef FnName = Callee->getName();
+654 −158

File changed.

Preview size limit exceeded, changes collapsed.

Loading