Skip to content

Commit

Permalink
Merged master:4934127e627d into amd-gfx:6bd5a7369e20
Browse files Browse the repository at this point in the history
Local branch amd-gfx 6bd5a73 Merged master:54fcea86b165 into amd-gfx:6b0cdcb65a4f
Remote branch master 4934127 Diable sanitizer options for amdgpu
  • Loading branch information
Sw authored and Sw committed Sep 10, 2020
2 parents 6bd5a73 + 4934127 commit 3105747
Show file tree
Hide file tree
Showing 16 changed files with 147 additions and 33 deletions.
8 changes: 4 additions & 4 deletions clang/lib/Driver/SanitizerArgs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -929,10 +929,10 @@ static bool hasTargetFeatureMTE(const llvm::opt::ArgStringList &CmdArgs) {
void SanitizerArgs::addArgs(const ToolChain &TC, const llvm::opt::ArgList &Args,
llvm::opt::ArgStringList &CmdArgs,
types::ID InputType) const {
// NVPTX doesn't currently support sanitizers. Bailing out here means that
// e.g. -fsanitize=address applies only to host code, which is what we want
// for now.
if (TC.getTriple().isNVPTX())
// NVPTX/AMDGPU doesn't currently support sanitizers. Bailing out here means
// that e.g. -fsanitize=address applies only to host code, which is what we
// want for now.
if (TC.getTriple().isNVPTX() || TC.getTriple().isAMDGPU())
return;

// Translate available CoverageFeatures to corresponding clang-cc1 flags.
Expand Down
9 changes: 9 additions & 0 deletions clang/test/Driver/hip-sanitize-options.hip
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// REQUIRES: clang-driver, x86-registered-target, amdgpu-registered-target

// RUN: %clang -### -target x86_64-unknown-linux-gnu --offload-arch=gfx906 \
// RUN: -fsanitize=address \
// RUN: -nogpuinc -nogpulib \
// RUN: %s 2>&1 | FileCheck %s

// CHECK-NOT: {{"[^"]*clang[^"]*".* "-fcuda-is-device".* "-fsanitize=address"}}
// CHECK: {{"[^"]*clang[^"]*".* "-triple" "x86_64-unknown-linux-gnu".* "-fsanitize=address"}}
2 changes: 0 additions & 2 deletions libc/src/string/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ add_entrypoint_object(
strcmp.cpp
HDRS
strcmp.h
DEPENDS
libc.include.string
)

add_entrypoint_object(
Expand Down
14 changes: 7 additions & 7 deletions llvm/include/llvm/Analysis/VectorUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -544,20 +544,20 @@ createSequentialMask(unsigned Start, unsigned NumInts, unsigned NumUndefs);
/// elements, it will be padded with undefs.
Value *concatenateVectors(IRBuilderBase &Builder, ArrayRef<Value *> Vecs);

/// Given a mask vector of the form <Y x i1>, Return true if all of the
/// elements of this predicate mask are false or undef. That is, return true
/// if all lanes can be assumed inactive.
/// Given a mask vector of i1, Return true if all of the elements of this
/// predicate mask are known to be false or undef. That is, return true if all
/// lanes can be assumed inactive.
bool maskIsAllZeroOrUndef(Value *Mask);

/// Given a mask vector of the form <Y x i1>, Return true if all of the
/// elements of this predicate mask are true or undef. That is, return true
/// if all lanes can be assumed active.
/// Given a mask vector of i1, Return true if all of the elements of this
/// predicate mask are known to be true or undef. That is, return true if all
/// lanes can be assumed active.
bool maskIsAllOneOrUndef(Value *Mask);

/// Given a mask vector of the form <Y x i1>, return an APInt (of bitwidth Y)
/// for each lane which may be active.
APInt possiblyDemandedEltsInMask(Value *Mask);

/// The group of interleaved loads/stores sharing the same stride and
/// close to each other.
///
Expand Down
21 changes: 21 additions & 0 deletions llvm/lib/Analysis/VectorUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -863,11 +863,19 @@ Value *llvm::concatenateVectors(IRBuilderBase &Builder,
}

bool llvm::maskIsAllZeroOrUndef(Value *Mask) {
assert(isa<VectorType>(Mask->getType()) &&
isa<IntegerType>(Mask->getType()->getScalarType()) &&
cast<IntegerType>(Mask->getType()->getScalarType())->getBitWidth() ==
1 &&
"Mask must be a vector of i1");

auto *ConstMask = dyn_cast<Constant>(Mask);
if (!ConstMask)
return false;
if (ConstMask->isNullValue() || isa<UndefValue>(ConstMask))
return true;
if (isa<ScalableVectorType>(ConstMask->getType()))
return false;
for (unsigned
I = 0,
E = cast<FixedVectorType>(ConstMask->getType())->getNumElements();
Expand All @@ -882,11 +890,19 @@ bool llvm::maskIsAllZeroOrUndef(Value *Mask) {


bool llvm::maskIsAllOneOrUndef(Value *Mask) {
assert(isa<VectorType>(Mask->getType()) &&
isa<IntegerType>(Mask->getType()->getScalarType()) &&
cast<IntegerType>(Mask->getType()->getScalarType())->getBitWidth() ==
1 &&
"Mask must be a vector of i1");

auto *ConstMask = dyn_cast<Constant>(Mask);
if (!ConstMask)
return false;
if (ConstMask->isAllOnesValue() || isa<UndefValue>(ConstMask))
return true;
if (isa<ScalableVectorType>(ConstMask->getType()))
return false;
for (unsigned
I = 0,
E = cast<FixedVectorType>(ConstMask->getType())->getNumElements();
Expand All @@ -902,6 +918,11 @@ bool llvm::maskIsAllOneOrUndef(Value *Mask) {
/// TODO: This is a lot like known bits, but for
/// vectors. Is there something we can common this with?
APInt llvm::possiblyDemandedEltsInMask(Value *Mask) {
assert(isa<FixedVectorType>(Mask->getType()) &&
isa<IntegerType>(Mask->getType()->getScalarType()) &&
cast<IntegerType>(Mask->getType()->getScalarType())->getBitWidth() ==
1 &&
"Mask must be a fixed width vector of i1");

const unsigned VWidth =
cast<FixedVectorType>(Mask->getType())->getNumElements();
Expand Down
13 changes: 5 additions & 8 deletions llvm/lib/CodeGen/ImplicitNullChecks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,13 +204,12 @@ class ImplicitNullChecks : public MachineFunctionPass {
/// if it was hoisted to the NullCheck block. This is used by caller
/// canHoistInst to decide if DependenceMI can be hoisted safely.
bool canDependenceHoistingClobberLiveIns(MachineInstr *DependenceMI,
MachineBasicBlock *NullSucc,
unsigned PointerReg);
MachineBasicBlock *NullSucc);

/// Return true if \p FaultingMI can be hoisted from after the
/// instructions in \p InstsSeenSoFar to before them. Set \p Dependence to a
/// non-null value if we also need to (and legally can) hoist a depedency.
bool canHoistInst(MachineInstr *FaultingMI, unsigned PointerReg,
bool canHoistInst(MachineInstr *FaultingMI,
ArrayRef<MachineInstr *> InstsSeenSoFar,
MachineBasicBlock *NullSucc, MachineInstr *&Dependence);

Expand Down Expand Up @@ -409,8 +408,7 @@ ImplicitNullChecks::isSuitableMemoryOp(const MachineInstr &MI,
}

bool ImplicitNullChecks::canDependenceHoistingClobberLiveIns(
MachineInstr *DependenceMI, MachineBasicBlock *NullSucc,
unsigned PointerReg) {
MachineInstr *DependenceMI, MachineBasicBlock *NullSucc) {
for (auto &DependenceMO : DependenceMI->operands()) {
if (!(DependenceMO.isReg() && DependenceMO.getReg()))
continue;
Expand Down Expand Up @@ -442,7 +440,6 @@ bool ImplicitNullChecks::canDependenceHoistingClobberLiveIns(
}

bool ImplicitNullChecks::canHoistInst(MachineInstr *FaultingMI,
unsigned PointerReg,
ArrayRef<MachineInstr *> InstsSeenSoFar,
MachineBasicBlock *NullSucc,
MachineInstr *&Dependence) {
Expand All @@ -467,7 +464,7 @@ bool ImplicitNullChecks::canHoistInst(MachineInstr *FaultingMI,
if (DependenceMI->mayLoadOrStore())
return false;

if (canDependenceHoistingClobberLiveIns(DependenceMI, NullSucc, PointerReg))
if (canDependenceHoistingClobberLiveIns(DependenceMI, NullSucc))
return false;

auto DepDepResult =
Expand Down Expand Up @@ -616,7 +613,7 @@ bool ImplicitNullChecks::analyzeBlockForNullChecks(
if (SR == SR_Impossible)
return false;
if (SR == SR_Suitable &&
canHoistInst(&MI, PointerReg, InstsSeenSoFar, NullSucc, Dependence)) {
canHoistInst(&MI, InstsSeenSoFar, NullSucc, Dependence)) {
NullCheckList.emplace_back(&MI, MBP.ConditionDef, &MBB, NotNullSucc,
NullSucc, Dependence);
return true;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/Hexagon/HexagonISelLoweringHVX.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1985,6 +1985,8 @@ HexagonTargetLowering::LowerHvxOperation(SDValue Op, SelectionDAG &DAG) const {
break;
case ISD::LOAD:
case ISD::STORE:
case ISD::MLOAD:
case ISD::MSTORE:
return SplitHvxMemOp(Op, DAG);
case ISD::CTPOP:
case ISD::CTLZ:
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/WebAssembly/WebAssemblyInstrControl.td
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ defm FALLTHROUGH_RETURN : I<(outs), (ins variable_ops), (outs), (ins), []>;

} // isReturn = 1

let isTrap = 1 in
let IsCanonical = 1, isTrap = 1 in
defm UNREACHABLE : NRI<(outs), (ins), [(trap)], "unreachable", 0x00>;

} // isTerminator = 1
Expand Down
18 changes: 12 additions & 6 deletions llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,11 +319,14 @@ Instruction *InstCombinerImpl::simplifyMaskedStore(IntrinsicInst &II) {
return new StoreInst(II.getArgOperand(0), StorePtr, false, Alignment);
}

if (isa<ScalableVectorType>(ConstMask->getType()))
return nullptr;

// Use masked off lanes to simplify operands via SimplifyDemandedVectorElts
APInt DemandedElts = possiblyDemandedEltsInMask(ConstMask);
APInt UndefElts(DemandedElts.getBitWidth(), 0);
if (Value *V = SimplifyDemandedVectorElts(II.getOperand(0),
DemandedElts, UndefElts))
if (Value *V =
SimplifyDemandedVectorElts(II.getOperand(0), DemandedElts, UndefElts))
return replaceOperand(II, 0, V);

return nullptr;
Expand Down Expand Up @@ -355,14 +358,17 @@ Instruction *InstCombinerImpl::simplifyMaskedScatter(IntrinsicInst &II) {
if (ConstMask->isNullValue())
return eraseInstFromFunction(II);

if (isa<ScalableVectorType>(ConstMask->getType()))
return nullptr;

// Use masked off lanes to simplify operands via SimplifyDemandedVectorElts
APInt DemandedElts = possiblyDemandedEltsInMask(ConstMask);
APInt UndefElts(DemandedElts.getBitWidth(), 0);
if (Value *V = SimplifyDemandedVectorElts(II.getOperand(0),
DemandedElts, UndefElts))
if (Value *V =
SimplifyDemandedVectorElts(II.getOperand(0), DemandedElts, UndefElts))
return replaceOperand(II, 0, V);
if (Value *V = SimplifyDemandedVectorElts(II.getOperand(1),
DemandedElts, UndefElts))
if (Value *V =
SimplifyDemandedVectorElts(II.getOperand(1), DemandedElts, UndefElts))
return replaceOperand(II, 1, V);

return nullptr;
Expand Down
32 changes: 32 additions & 0 deletions llvm/test/CodeGen/Hexagon/autohvx/isel-split-masked.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
; RUN: llc -march=hexagon < %s | FileCheck %s

; Check that this compiles successfully.
; CHECK: vmem

target datalayout = "e-m:e-p:32:32:32-a:0-n16:32-i64:64:64-i32:32:32-i16:16:16-i1:8:8-f32:32:32-f64:64:64-v32:32:32-v64:64:64-v512:512:512-v1024:1024:1024-v2048:2048:2048"
target triple = "hexagon"

define void @f0() #0 {
b0:
%v0 = call <64 x i32> @llvm.masked.load.v64i32.p0v64i32(<64 x i32>* nonnull undef, i32 4, <64 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>, <64 x i32> undef)
%v1 = icmp sgt <64 x i32> %v0, zeroinitializer
%v2 = sext <64 x i1> %v1 to <64 x i32>
%v3 = add nsw <64 x i32> zeroinitializer, %v2
%v4 = add nsw <64 x i32> %v3, zeroinitializer
%v5 = icmp sgt <64 x i32> %v4, zeroinitializer
%v6 = select <64 x i1> %v5, <64 x i32> %v4, <64 x i32> zeroinitializer
%v7 = select <64 x i1> zeroinitializer, <64 x i32> undef, <64 x i32> %v6
%v8 = trunc <64 x i32> %v7 to <64 x i16>
call void @llvm.masked.store.v64i16.p0v64i16(<64 x i16> %v8, <64 x i16>* undef, i32 2, <64 x i1> <i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 true, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false, i1 false>)
ret void
}

; Function Attrs: argmemonly nounwind readonly willreturn
declare <64 x i32> @llvm.masked.load.v64i32.p0v64i32(<64 x i32>*, i32 immarg, <64 x i1>, <64 x i32>) #1

; Function Attrs: argmemonly nounwind willreturn
declare void @llvm.masked.store.v64i16.p0v64i16(<64 x i16>, <64 x i16>*, i32 immarg, <64 x i1>) #2

attributes #0 = { "target-features"="+hvx-length128b,+hvxv67,+v67,-long-calls" }
attributes #1 = { argmemonly nounwind readonly willreturn }
attributes #2 = { argmemonly nounwind willreturn }
21 changes: 21 additions & 0 deletions llvm/test/Transforms/InstCombine/AArch64/VectorUtils_heuristics.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
; RUN: opt -S -instcombine < %s | FileCheck %s

target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-gnu"

; This test checks that instcombine does not crash while invoking
; maskIsAllOneOrUndef, maskIsAllZeroOrUndef, or possiblyDemandedEltsInMask.

; CHECK-LABEL: novel_algorithm
; CHECK: unreachable
define void @novel_algorithm() {
entry:
%a = call <vscale x 16 x i8> @llvm.masked.load.nxv16i8.p0nxv16i8(<vscale x 16 x i8>* undef, i32 1, <vscale x 16 x i1> shufflevector (<vscale x 16 x i1> insertelement (<vscale x 16 x i1> undef, i1 true, i32 0), <vscale x 16 x i1> undef, <vscale x 16 x i32> zeroinitializer), <vscale x 16 x i8> undef)
%b = add <vscale x 16 x i8> undef, %a
call void @llvm.masked.store.nxv16i8.p0nxv16i8(<vscale x 16 x i8> %b, <vscale x 16 x i8>* undef, i32 1, <vscale x 16 x i1> shufflevector (<vscale x 16 x i1> insertelement (<vscale x 16 x i1> undef, i1 true, i32 0), <vscale x 16 x i1> undef, <vscale x 16 x i32> zeroinitializer))
unreachable
}

declare <vscale x 16 x i8> @llvm.masked.load.nxv16i8.p0nxv16i8(<vscale x 16 x i8>*, i32 immarg, <vscale x 16 x i1>, <vscale x 16 x i8>)

declare void @llvm.masked.store.nxv16i8.p0nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>*, i32 immarg, <vscale x 16 x i1>)
19 changes: 19 additions & 0 deletions llvm/utils/gn/secondary/llvm/lib/Target/PowerPC/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,32 @@ tablegen("PPCGenFastISel") {
td_file = "PPC.td"
}

tablegen("PPCGenGlobalISel") {
visibility = [ ":LLVMPowerPCCodeGen" ]
args = [ "-gen-global-isel" ]
td_file = "PPC.td"
}

tablegen("PPCGenRegisterBank") {
visibility = [ ":LLVMPowerPCCodeGen" ]
args = [ "-gen-register-bank" ]
td_file = "PPC.td"
}

static_library("LLVMPowerPCCodeGen") {
deps = [
":PPCGenCallingConv",
":PPCGenDAGISel",
":PPCGenFastISel",
":PPCGenGlobalISel",
":PPCGenRegisterBank",
"MCTargetDesc",
"TargetInfo",
"//llvm/include/llvm/Config:llvm-config",
"//llvm/lib/Analysis",
"//llvm/lib/CodeGen",
"//llvm/lib/CodeGen/AsmPrinter",
"//llvm/lib/CodeGen/GlobalISel",
"//llvm/lib/CodeGen/SelectionDAG",
"//llvm/lib/IR",
"//llvm/lib/MC",
Expand All @@ -38,6 +53,10 @@ static_library("LLVMPowerPCCodeGen") {
]
include_dirs = [ "." ]
sources = [
"GISel/PPCCallLowering.cpp",
"GISel/PPCInstructionSelector.cpp",
"GISel/PPCLegalizerInfo.cpp",
"GISel/PPCRegisterBankInfo.cpp",
"PPCAsmPrinter.cpp",
"PPCBoolRetToInt.cpp",
"PPCBranchCoalescing.cpp",
Expand Down
4 changes: 2 additions & 2 deletions mlir/include/mlir/IR/OpBase.td
Original file line number Diff line number Diff line change
Expand Up @@ -1443,7 +1443,7 @@ class StructFieldAttr<string thisName, Attr thisType> {
// Structured attribute that wraps a DictionaryAttr and provides both a
// validation method and set of accessors for a fixed set of fields. This is
// useful when representing data that would normally be in a structure.
class StructAttr<string name, Dialect dialect,
class StructAttr<string name, Dialect d,
list<StructFieldAttr> attributes> :
DictionaryAttrBase<CPred<"$_self.isa<" # name # ">()">,
"DictionaryAttr with field(s): " #
Expand All @@ -1459,7 +1459,7 @@ class StructAttr<string name, Dialect dialect,
let storageType = name;

// The dialect this StructAttr belongs to.
Dialect structDialect = dialect;
Dialect dialect = d;

// List of fields that the StructAttr contains.
list<StructFieldAttr> fields = attributes;
Expand Down
4 changes: 3 additions & 1 deletion mlir/include/mlir/TableGen/Dialect.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,13 @@ class Dialect {
// underlying record.
bool operator==(const Dialect &other) const;

bool operator!=(const Dialect &other) const { return !(*this == other); }

// Compares two dialects by comparing the names of the dialects.
bool operator<(const Dialect &other) const;

// Returns whether the dialect is defined.
operator bool() const { return def != nullptr; }
explicit operator bool() const { return def != nullptr; }

private:
const llvm::Record *def;
Expand Down
9 changes: 7 additions & 2 deletions mlir/lib/TableGen/Attribute.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,12 @@ StringRef Attribute::getDerivedCodeBody() const {
}

Dialect Attribute::getDialect() const {
return Dialect(def->getValueAsDef("dialect"));
const llvm::RecordVal *record = def->getValue("dialect");
if (record && record->getValue()) {
if (DefInit *init = dyn_cast<DefInit>(record->getValue()))
return Dialect(init->getDef());
}
return Dialect(nullptr);
}

ConstantAttr::ConstantAttr(const DefInit *init) : def(init->getDef()) {
Expand Down Expand Up @@ -255,7 +260,7 @@ StringRef StructAttr::getStructClassName() const {
}

StringRef StructAttr::getCppNamespace() const {
Dialect dialect(def->getValueAsDef("structDialect"));
Dialect dialect(def->getValueAsDef("dialect"));
return dialect.getCppNamespace();
}

Expand Down
2 changes: 2 additions & 0 deletions mlir/lib/TableGen/Dialect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
using namespace mlir;
using namespace mlir::tblgen;
Dialect::Dialect(const llvm::Record *def) : def(def) {
if (def == nullptr)
return;
for (StringRef dialect : def->getValueAsListOfStrings("dependentDialects"))
dependentDialects.push_back(dialect);
}
Expand Down

0 comments on commit 3105747

Please sign in to comment.