Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pull] master from llvm:master #50

Merged
merged 7 commits into from
Aug 29, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions clang/include/clang/Basic/FileManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,6 @@ class FileManager : public RefCountedBase<FileManager> {
std::error_code getNoncachedStatValue(StringRef Path,
llvm::vfs::Status &Result);

/// Remove the real file \p Entry from the cache.
void invalidateCache(const FileEntry *Entry);

/// If path is not absolute and FileSystemOptions set the working
/// directory, the path is modified to be relative to the given
/// working directory.
Expand Down
4 changes: 4 additions & 0 deletions clang/lib/AST/JSONNodeDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ void JSONNodeDumper::Visit(const Stmt *S) {

void JSONNodeDumper::Visit(const Type *T) {
JOS.attribute("id", createPointerRepresentation(T));

if (!T)
return;

JOS.attribute("kind", (llvm::Twine(T->getTypeClassName()) + "Type").str());
JOS.attribute("type", createQualType(QualType(T, 0), /*Desugar*/ false));
attributeOnlyIfTrue("isDependent", T->isDependentType());
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Analysis/CFG.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2994,9 +2994,8 @@ CFGBlock *CFGBuilder::VisitReturnStmt(Stmt *S) {

// Visit children
if (ReturnStmt *RS = dyn_cast<ReturnStmt>(S)) {
Expr *O = RS->getRetValue();
if (O)
Visit(O, AddStmtChoice::AlwaysAdd, /*ExternallyDestructed=*/true);
if (Expr *O = RS->getRetValue())
return Visit(O, AddStmtChoice::AlwaysAdd, /*ExternallyDestructed=*/true);
return Block;
} else { // co_return
return VisitChildren(S);
Expand Down
14 changes: 0 additions & 14 deletions clang/lib/Basic/FileManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -498,20 +498,6 @@ FileManager::getNoncachedStatValue(StringRef Path,
return std::error_code();
}

void FileManager::invalidateCache(const FileEntry *Entry) {
assert(Entry && "Cannot invalidate a NULL FileEntry");

SeenFileEntries.erase(Entry->getName());

// FileEntry invalidation should not block future optimizations in the file
// caches. Possible alternatives are cache truncation (invalidate last N) or
// invalidation of the whole cache.
//
// FIXME: This is broken. We sometimes have the same FileEntry* shared
// between multiple SeenFileEntries, so this can leave dangling pointers.
UniqueRealFiles.erase(Entry->getUniqueID());
}

void FileManager::GetUniqueIDMapping(
SmallVectorImpl<const FileEntry *> &UIDToFiles) const {
UIDToFiles.clear();
Expand Down
77 changes: 77 additions & 0 deletions clang/test/AST/ast-dump-types-json.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,11 @@ typedef int T::*TestMemberDataPointerType;

typedef int TestQualTypePrinting(const char* c);

typedef int TestUsingShadowDeclType;
namespace TestNamespaceWithUsingShadowType {
using ::TestUsingShadowDeclType;
}

// NOTE: CHECK lines have been autogenerated by gen_ast_dump_json_test.py


Expand Down Expand Up @@ -422,3 +427,75 @@ typedef int TestQualTypePrinting(const char* c);
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }

// CHECK: "kind": "NamespaceDecl",
// CHECK-NEXT: "loc": {
// CHECK-NEXT: "file": "{{.*}}",
// CHECK-NEXT: "line": 24,
// CHECK-NEXT: "col": 11,
// CHECK-NEXT: "tokLen": 32
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {
// CHECK-NEXT: "col": 1,
// CHECK-NEXT: "tokLen": 9
// CHECK-NEXT: },
// CHECK-NEXT: "end": {
// CHECK-NEXT: "line": 26,
// CHECK-NEXT: "col": 1,
// CHECK-NEXT: "tokLen": 1
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "name": "TestNamespaceWithUsingShadowType",
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "UsingDecl",
// CHECK-NEXT: "loc": {
// CHECK-NEXT: "line": 25,
// CHECK-NEXT: "col": 9,
// CHECK-NEXT: "tokLen": 23
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {
// CHECK-NEXT: "col": 1,
// CHECK-NEXT: "tokLen": 5
// CHECK-NEXT: },
// CHECK-NEXT: "end": {
// CHECK-NEXT: "col": 9,
// CHECK-NEXT: "tokLen": 23
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "name": "::TestUsingShadowDeclType"
// CHECK-NEXT: },
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "UsingShadowDecl",
// CHECK-NEXT: "loc": {
// CHECK-NEXT: "col": 9,
// CHECK-NEXT: "tokLen": 23
// CHECK-NEXT: },
// CHECK-NEXT: "range": {
// CHECK-NEXT: "begin": {
// CHECK-NEXT: "col": 9,
// CHECK-NEXT: "tokLen": 23
// CHECK-NEXT: },
// CHECK-NEXT: "end": {
// CHECK-NEXT: "col": 9,
// CHECK-NEXT: "tokLen": 23
// CHECK-NEXT: }
// CHECK-NEXT: },
// CHECK-NEXT: "isImplicit": true,
// CHECK-NEXT: "target": {
// CHECK-NEXT: "id": "0x{{.*}}",
// CHECK-NEXT: "kind": "TypedefDecl",
// CHECK-NEXT: "name": "TestUsingShadowDeclType"
// CHECK-NEXT: },
// CHECK-NEXT: "inner": [
// CHECK-NEXT: {
// CHECK-NEXT: "id": "0x0"
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
// CHECK-NEXT: ]
// CHECK-NEXT: }
2 changes: 1 addition & 1 deletion clang/test/AST/gen_ast_dump_json_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def normalize(dict_var):
normalize(e)
elif type(v) is unicode:
st = v.encode('utf-8')
if re.match(r"0x[0-9A-Fa-f]+", v):
if v != "0x0" and re.match(r"0x[0-9A-Fa-f]+", v):
dict_var[k] = u'0x{{.*}}'
elif os.path.isfile(v):
dict_var[k] = u'{{.*}}'
Expand Down
49 changes: 48 additions & 1 deletion clang/test/Analysis/cfg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -499,6 +499,54 @@ void foo() {
} // end namespace pr37688_deleted_union_destructor


namespace return_statement_expression {
int unknown();

// CHECK-LABEL: int foo()
// CHECK: [B6 (ENTRY)]
// CHECK-NEXT: Succs (1): B5
// CHECK: [B1]
// CHECK-NEXT: 1: 0
// CHECK-NEXT: 2: return [B1.1];
// CHECK-NEXT: Preds (1): B5
// CHECK-NEXT: Succs (1): B0
// CHECK: [B2]
// CHECK-NEXT: 1: 0
// CHECK-NEXT: 2: ({ ... ; [B2.1] })
// CHECK-NEXT: 3: return [B2.2];
// CHECK-NEXT: Preds (1): B4
// CHECK-NEXT: Succs (1): B0
// FIXME: Why do we have [B3] at all?
// CHECK: [B3]
// CHECK-NEXT: Succs (1): B4
// CHECK: [B4]
// CHECK-NEXT: 1: 0
// CHECK-NEXT: 2: [B4.1] (ImplicitCastExpr, IntegralToBoolean, _Bool)
// CHECK-NEXT: T: while [B4.2]
// CHECK-NEXT: Preds (2): B3 B5
// CHECK-NEXT: Succs (2): NULL B2
// CHECK: [B5]
// CHECK-NEXT: 1: unknown
// CHECK-NEXT: 2: [B5.1] (ImplicitCastExpr, FunctionToPointerDecay, int (*)(void))
// CHECK-NEXT: 3: [B5.2]()
// CHECK-NEXT: 4: [B5.3] (ImplicitCastExpr, IntegralToBoolean, _Bool)
// CHECK-NEXT: T: if [B5.4]
// CHECK-NEXT: Preds (1): B6
// CHECK-NEXT: Succs (2): B4 B1
// CHECK: [B0 (EXIT)]
// CHECK-NEXT: Preds (2): B1 B2
int foo() {
if (unknown())
return ({
while (0)
;
0;
});
else
return 0;
}
} // namespace statement_expression_in_return

// CHECK-LABEL: template<> int *PR18472<int>()
// CHECK: [B2 (ENTRY)]
// CHECK-NEXT: Succs (1): B1
Expand All @@ -522,4 +570,3 @@ template <class T> T *PR18472() {
void PR18472_helper() {
PR18472<int>();
}

11 changes: 11 additions & 0 deletions clang/test/Sema/return.c
Original file line number Diff line number Diff line change
Expand Up @@ -328,3 +328,14 @@ int sizeof_long() {
if (sizeof(long) == 8)
return 2;
} // no-warning

int return_statement_expression() {
if (unknown())
return ({
while (0)
;
0;
});
else
return 0;
} // no-warning (used to be "control may reach end of non-void function")
48 changes: 48 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
/// \todo This should be generated by TableGen.
//===----------------------------------------------------------------------===//

#if defined(_MSC_VER) || defined(__MINGW32__)
// According to Microsoft, one must set _USE_MATH_DEFINES in order to get M_PI
// from the Visual C++ cmath / math.h headers:
// https://docs.microsoft.com/en-us/cpp/c-runtime-library/math-constants?view=vs-2019
#define _USE_MATH_DEFINES
#endif

#include "AMDGPU.h"
#include "AMDGPULegalizerInfo.h"
#include "AMDGPUTargetMachine.h"
Expand Down Expand Up @@ -275,12 +282,16 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,
auto &FPOpActions = getActionDefinitionsBuilder(
{ G_FADD, G_FMUL, G_FNEG, G_FABS, G_FMA, G_FCANONICALIZE})
.legalFor({S32, S64});
auto &TrigActions = getActionDefinitionsBuilder({G_FSIN, G_FCOS})
.customFor({S32, S64});

if (ST.has16BitInsts()) {
if (ST.hasVOP3PInsts())
FPOpActions.legalFor({S16, V2S16});
else
FPOpActions.legalFor({S16});

TrigActions.customFor({S16});
}

auto &MinNumMaxNum = getActionDefinitionsBuilder({
Expand All @@ -306,10 +317,15 @@ AMDGPULegalizerInfo::AMDGPULegalizerInfo(const GCNSubtarget &ST_,

if (ST.hasVOP3PInsts())
FPOpActions.clampMaxNumElements(0, S16, 2);

FPOpActions
.scalarize(0)
.clampScalar(0, ST.has16BitInsts() ? S16 : S32, S64);

TrigActions
.scalarize(0)
.clampScalar(0, ST.has16BitInsts() ? S16 : S32, S64);

if (ST.has16BitInsts()) {
getActionDefinitionsBuilder(G_FSQRT)
.legalFor({S32, S64, S16})
Expand Down Expand Up @@ -816,6 +832,9 @@ bool AMDGPULegalizerInfo::legalizeCustom(MachineInstr &MI,
return legalizeExtractVectorElt(MI, MRI, MIRBuilder);
case TargetOpcode::G_INSERT_VECTOR_ELT:
return legalizeInsertVectorElt(MI, MRI, MIRBuilder);
case TargetOpcode::G_FSIN:
case TargetOpcode::G_FCOS:
return legalizeSinCos(MI, MRI, MIRBuilder);
default:
return false;
}
Expand Down Expand Up @@ -1231,6 +1250,35 @@ bool AMDGPULegalizerInfo::legalizeInsertVectorElt(
return true;
}

bool AMDGPULegalizerInfo::legalizeSinCos(
MachineInstr &MI, MachineRegisterInfo &MRI,
MachineIRBuilder &B) const {
B.setInstr(MI);

Register DstReg = MI.getOperand(0).getReg();
Register SrcReg = MI.getOperand(1).getReg();
LLT Ty = MRI.getType(DstReg);
unsigned Flags = MI.getFlags();

Register TrigVal;
auto OneOver2Pi = B.buildFConstant(Ty, 0.5 / M_PI);
if (ST.hasTrigReducedRange()) {
auto MulVal = B.buildFMul(Ty, SrcReg, OneOver2Pi, Flags);
TrigVal = B.buildIntrinsic(Intrinsic::amdgcn_fract, {Ty}, false)
.addUse(MulVal.getReg(0))
.setMIFlags(Flags).getReg(0);
} else
TrigVal = B.buildFMul(Ty, SrcReg, OneOver2Pi, Flags).getReg(0);

Intrinsic::ID TrigIntrin = MI.getOpcode() == AMDGPU::G_FSIN ?
Intrinsic::amdgcn_sin : Intrinsic::amdgcn_cos;
B.buildIntrinsic(TrigIntrin, makeArrayRef<Register>(DstReg), false)
.addUse(TrigVal)
.setMIFlags(Flags);
MI.eraseFromParent();
return true;
}

// Return the use branch instruction, otherwise null if the usage is invalid.
static MachineInstr *verifyCFIntrinsic(MachineInstr &MI,
MachineRegisterInfo &MRI) {
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Target/AMDGPU/AMDGPULegalizerInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ class AMDGPULegalizerInfo : public LegalizerInfo {
MachineIRBuilder &MIRBuilder) const;
bool legalizeInsertVectorElt(MachineInstr &MI, MachineRegisterInfo &MRI,
MachineIRBuilder &MIRBuilder) const;
bool legalizeSinCos(MachineInstr &MI, MachineRegisterInfo &MRI,
MachineIRBuilder &MIRBuilder) const;

Register getLiveInRegister(MachineRegisterInfo &MRI,
Register Reg, LLT Ty) const;
Expand Down
8 changes: 5 additions & 3 deletions llvm/lib/Target/X86/X86ISelLowering.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -44660,7 +44660,8 @@ static SDValue combineScalarToVector(SDNode *N, SelectionDAG &DAG) {

// Simplify PMULDQ and PMULUDQ operations.
static SDValue combinePMULDQ(SDNode *N, SelectionDAG &DAG,
TargetLowering::DAGCombinerInfo &DCI) {
TargetLowering::DAGCombinerInfo &DCI,
const X86Subtarget &Subtarget) {
SDValue LHS = N->getOperand(0);
SDValue RHS = N->getOperand(1);

Expand All @@ -44670,8 +44671,9 @@ static SDValue combinePMULDQ(SDNode *N, SelectionDAG &DAG,
return DAG.getNode(N->getOpcode(), SDLoc(N), N->getValueType(0), RHS, LHS);

// Multiply by zero.
// Don't return RHS as it may contain UNDEFs.
if (ISD::isBuildVectorAllZeros(RHS.getNode()))
return RHS;
return getZeroVector(N->getSimpleValueType(0), Subtarget, DAG, SDLoc(N));

// PMULDQ/PMULUDQ only uses lower 32 bits from each vector element.
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
Expand Down Expand Up @@ -44896,7 +44898,7 @@ SDValue X86TargetLowering::PerformDAGCombine(SDNode *N,
case X86ISD::PCMPEQ:
case X86ISD::PCMPGT: return combineVectorCompare(N, DAG, Subtarget);
case X86ISD::PMULDQ:
case X86ISD::PMULUDQ: return combinePMULDQ(N, DAG, DCI);
case X86ISD::PMULUDQ: return combinePMULDQ(N, DAG, DCI, Subtarget);
}

return SDValue();
Expand Down
Loading