9 changes: 0 additions & 9 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -259,10 +259,6 @@ Changes in existing checks
- Improved :doc:`google-runtime-int <clang-tidy/checks/google/runtime-int>`
check performance through optimizations.

- Improved :doc:`hicpp-signed-bitwise <clang-tidy/checks/hicpp/signed-bitwise>`
check by ignoring false positives involving positive integer literals behind
implicit casts when `IgnorePositiveIntegerLiterals` is enabled.

- Improved :doc:`hicpp-ignored-remove-result <clang-tidy/checks/hicpp/ignored-remove-result>`
check by ignoring other functions with same prefixes as the target specific
functions.
Expand Down Expand Up @@ -352,11 +348,6 @@ Changes in existing checks
<clang-tidy/checks/readability/redundant-inline-specifier>` check to properly
emit warnings for static data member with an in-class initializer.

- Improved :doc:`readability-static-accessed-through-instance
<clang-tidy/checks/readability/static-accessed-through-instance>` check to
support calls to overloaded operators as base expression and provide fixes to
expressions with side-effects.

- Improved :doc:`readability-static-definition-in-anonymous-namespace
<clang-tidy/checks/readability/static-definition-in-anonymous-namespace>`
check by resolving fix-it overlaps in template code by disregarding implicit
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,3 @@ is changed to:
C::E1;
C::E2;
The `--fix` commandline option provides default support for safe fixes, whereas
`--fix-notes` enables fixes that may replace expressions with side effects,
potentially altering the program's behavior.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ void examples() {
// CHECK-MESSAGES: :[[@LINE-1]]:19: warning: use of a signed integer operand with a binary bitwise operator

unsigned URes2 = URes << 1; //Ok
unsigned URes3 = URes & 1; //Ok

int IResult;
IResult = 10 & 2; //Ok
Expand All @@ -22,8 +21,6 @@ void examples() {
IResult = Int << 1;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator
IResult = ~0; //Ok
IResult = -1 & 1;
// CHECK-MESSAGES: :[[@LINE-1]]:13: warning: use of a signed integer operand with a binary bitwise operator [hicpp-signed-bitwise]
}

enum EnumConstruction {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %check_clang_tidy %s readability-static-accessed-through-instance %t -- --fix-notes -- -isystem %S/Inputs/static-accessed-through-instance
// RUN: %check_clang_tidy %s readability-static-accessed-through-instance %t -- -- -isystem %S/Inputs/static-accessed-through-instance
#include <__clang_cuda_builtin_vars.h>

enum OutEnum {
Expand Down Expand Up @@ -47,8 +47,7 @@ C &f(int, int, int, int);
void g() {
f(1, 2, 3, 4).x;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
// CHECK-MESSAGES: :[[@LINE-2]]:3: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} C::x;{{$}}
// CHECK-FIXES: {{^}} f(1, 2, 3, 4).x;{{$}}
}

int i(int &);
Expand All @@ -60,23 +59,20 @@ int k(bool);
void f(C c) {
j(i(h().x));
// CHECK-MESSAGES: :[[@LINE-1]]:7: warning: static member
// CHECK-MESSAGES: :[[@LINE-2]]:7: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} j(i(C::x));{{$}}
// CHECK-FIXES: {{^}} j(i(h().x));{{$}}

// The execution of h() depends on the return value of a().
j(k(a() && h().x));
// CHECK-MESSAGES: :[[@LINE-1]]:14: warning: static member
// CHECK-MESSAGES: :[[@LINE-2]]:14: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} j(k(a() && C::x));{{$}}
// CHECK-FIXES: {{^}} j(k(a() && h().x));{{$}}

if ([c]() {
c.ns();
return c;
}().x == 15)
;
// CHECK-MESSAGES: :[[@LINE-5]]:7: warning: static member
// CHECK-MESSAGES: :[[@LINE-6]]:7: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} if (C::x == 15){{$}}
// CHECK-FIXES: {{^}} if ([c]() {{{$}}
}

// Nested specifiers
Expand Down Expand Up @@ -265,11 +261,8 @@ struct Qptr {
};

int func(Qptr qp) {
qp->y = 10;
qp->K = 10;
// CHECK-MESSAGES: :[[@LINE-1]]:3: warning: static member accessed through instance [readability-static-accessed-through-instance]
// CHECK-MESSAGES: :[[@LINE-2]]:3: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} Q::K = 10;
qp->y = 10; // OK, the overloaded operator might have side-effects.
qp->K = 10; //
}

namespace {
Expand Down Expand Up @@ -387,20 +380,3 @@ namespace PR51861 {
// CHECK-FIXES: {{^}} PR51861::Foo::getBar();{{$}}
}
}

namespace PR75163 {
struct Static {
static void call();
};

struct Ptr {
Static* operator->();
};

void test(Ptr& ptr) {
ptr->call();
// CHECK-MESSAGES: :[[@LINE-1]]:5: warning: static member accessed through instance [readability-static-accessed-through-instance]
// CHECK-MESSAGES: :[[@LINE-2]]:5: note: member base expression may carry some side effects
// CHECK-FIXES: {{^}} PR75163::Static::call();{{$}}
}
}
2 changes: 0 additions & 2 deletions clang/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -523,8 +523,6 @@ endif()


if( CLANG_INCLUDE_TESTS )
find_package(Perl)

add_subdirectory(unittests)
list(APPEND CLANG_TEST_DEPS ClangUnitTests)
list(APPEND CLANG_TEST_PARAMS
Expand Down
1 change: 0 additions & 1 deletion clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -798,7 +798,6 @@ CUDA/HIP Language Changes

CUDA Support
^^^^^^^^^^^^
- Clang now supports CUDA SDK up to 12.4

AIX Support
^^^^^^^^^^^
Expand Down
1,215 changes: 611 additions & 604 deletions clang/docs/StandardCPlusPlusModules.rst

Large diffs are not rendered by default.

3 changes: 1 addition & 2 deletions clang/docs/tools/clang-formatted-files.txt
Original file line number Diff line number Diff line change
Expand Up @@ -632,12 +632,11 @@ clang/unittests/Analysis/FlowSensitive/MapLatticeTest.cpp
clang/unittests/Analysis/FlowSensitive/MatchSwitchTest.cpp
clang/unittests/Analysis/FlowSensitive/MultiVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/SingleVarConstantPropagationTest.cpp
clang/unittests/Analysis/FlowSensitive/SolverTest.h
clang/unittests/Analysis/FlowSensitive/SolverTest.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.cpp
clang/unittests/Analysis/FlowSensitive/TestingSupport.h
clang/unittests/Analysis/FlowSensitive/TestingSupportTest.cpp
clang/unittests/Analysis/FlowSensitive/TypeErasedDataflowAnalysisTest.cpp
clang/unittests/Analysis/FlowSensitive/WatchedLiteralsSolverTest.cpp
clang/unittests/AST/ASTImporterFixtures.cpp
clang/unittests/AST/ASTImporterFixtures.h
clang/unittests/AST/ASTImporterObjCTest.cpp
Expand Down
5 changes: 1 addition & 4 deletions clang/include/clang/Basic/BuiltinsNVPTX.def
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,7 @@
#pragma push_macro("PTX81")
#pragma push_macro("PTX82")
#pragma push_macro("PTX83")
#pragma push_macro("PTX84")
#define PTX84 "ptx84"
#define PTX83 "ptx83|" PTX84
#define PTX83 "ptx83"
#define PTX82 "ptx82|" PTX83
#define PTX81 "ptx81|" PTX82
#define PTX80 "ptx80|" PTX81
Expand Down Expand Up @@ -1093,4 +1091,3 @@ TARGET_BUILTIN(__nvvm_getctarank_shared_cluster, "iv*3", "", AND(SM_90,PTX78))
#pragma pop_macro("PTX81")
#pragma pop_macro("PTX82")
#pragma pop_macro("PTX83")
#pragma pop_macro("PTX84")
1 change: 0 additions & 1 deletion clang/include/clang/Basic/CodeGenOptions.def
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,6 @@ CODEGENOPT(UnrollLoops , 1, 0) ///< Control whether loops are unrolled.
CODEGENOPT(RerollLoops , 1, 0) ///< Control whether loops are rerolled.
CODEGENOPT(NoUseJumpTables , 1, 0) ///< Set when -fno-jump-tables is enabled.
VALUE_CODEGENOPT(UnwindTables, 2, 0) ///< Unwind tables (1) or asynchronous unwind tables (2)
CODEGENOPT(LinkBitcodePostopt, 1, 0) ///< Link builtin bitcodes after optimization pipeline.
CODEGENOPT(VectorizeLoop , 1, 0) ///< Run loop vectorizer.
CODEGENOPT(VectorizeSLP , 1, 0) ///< Run SLP vectorizer.
CODEGENOPT(ProfileSampleAccurate, 1, 0) ///< Sample profile is accurate.
Expand Down
3 changes: 1 addition & 2 deletions clang/include/clang/Basic/Cuda.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,9 @@ enum class CudaVersion {
CUDA_121,
CUDA_122,
CUDA_123,
CUDA_124,
FULLY_SUPPORTED = CUDA_123,
PARTIALLY_SUPPORTED =
CUDA_124, // Partially supported. Proceed with a warning.
CUDA_123, // Partially supported. Proceed with a warning.
NEW = 10000, // Too new. Issue a warning, but allow using it.
};
const char *CudaVersionToString(CudaVersion V);
Expand Down
5 changes: 5 additions & 0 deletions clang/include/clang/Basic/DiagnosticParseKinds.td
Original file line number Diff line number Diff line change
Expand Up @@ -1438,13 +1438,18 @@ def err_omp_decl_in_declare_simd_variant : Error<
def err_omp_sink_and_source_iteration_not_allowd: Error<" '%0 %select{sink:|source:}1' must be with '%select{omp_cur_iteration - 1|omp_cur_iteration}1'">;
def err_omp_unknown_map_type : Error<
"incorrect map type, expected one of 'to', 'from', 'tofrom', 'alloc', 'release', or 'delete'">;
def err_omp_more_one_map_type : Error<"map type is already specified">;
def note_previous_map_type_specified_here
: Note<"map type '%0' is previous specified here">;
def err_omp_unknown_map_type_modifier : Error<
"incorrect map type modifier, expected one of: 'always', 'close', 'mapper'"
"%select{|, 'present'|, 'present', 'iterator'}0%select{|, 'ompx_hold'}1">;
def err_omp_map_type_missing : Error<
"missing map type">;
def err_omp_map_type_modifier_missing : Error<
"missing map type modifier">;
def err_omp_map_modifier_specification_list : Error<
"empty modifier-specification-list is not allowed">;
def err_omp_declare_simd_inbranch_notinbranch : Error<
"unexpected '%0' clause, '%1' is specified already">;
def err_omp_expected_clause_argument
Expand Down
15 changes: 5 additions & 10 deletions clang/include/clang/Driver/Options.td
Original file line number Diff line number Diff line change
Expand Up @@ -5077,10 +5077,6 @@ def maix_small_local_dynamic_tls : Flag<["-"], "maix-small-local-dynamic-tls">,
"where the offset from the TLS base is encoded as an "
"immediate operand (AIX 64-bit only). "
"This access sequence is not used for variables larger than 32KB.">;
def maix_shared_lib_tls_model_opt : Flag<["-"], "maix-shared-lib-tls-model-opt">,
Group<m_ppc_Features_Group>,
HelpText<"For shared library loaded with the main program, change local-dynamic access(es) "
"to initial-exec access(es) at the function level (AIX 64-bit only).">;
def maix_struct_return : Flag<["-"], "maix-struct-return">,
Group<m_Group>, Visibility<[ClangOption, CC1Option]>,
HelpText<"Return all structs in memory (PPC32 only)">,
Expand Down Expand Up @@ -5449,6 +5445,10 @@ def pg : Flag<["-"], "pg">, HelpText<"Enable mcount instrumentation">,
MarshallingInfoFlag<CodeGenOpts<"InstrumentForProfiling">>;
def pipe : Flag<["-", "--"], "pipe">,
HelpText<"Use pipes between commands, when possible">;
// Facebook T92898286
def post_link_optimize : Flag<["--"], "post-link-optimize">,
HelpText<"Apply post-link optimizations using BOLT">;
// End Facebook T92898286
def prebind__all__twolevel__modules : Flag<["-"], "prebind_all_twolevel_modules">;
def prebind : Flag<["-"], "prebind">;
def preload : Flag<["-"], "preload">;
Expand Down Expand Up @@ -5707,7 +5707,7 @@ def whatsloaded : Flag<["-"], "whatsloaded">;
def why_load : Flag<["-"], "why_load">;
def whyload : Flag<["-"], "whyload">, Alias<why_load>;
def w : Flag<["-"], "w">, HelpText<"Suppress all warnings">,
Visibility<[ClangOption, CC1Option, FlangOption, FC1Option]>,
Visibility<[ClangOption, CC1Option]>,
MarshallingInfoFlag<DiagnosticOpts<"IgnoreWarnings">>;
def x : JoinedOrSeparate<["-"], "x">,
Flags<[NoXarchOption]>,
Expand Down Expand Up @@ -7096,11 +7096,6 @@ def mlink_bitcode_file : Separate<["-"], "mlink-bitcode-file">,
def mlink_builtin_bitcode : Separate<["-"], "mlink-builtin-bitcode">,
HelpText<"Link and internalize needed symbols from the given bitcode file "
"before performing optimizations.">;
defm link_builtin_bitcode_postopt: BoolMOption<"link-builtin-bitcode-postopt",
CodeGenOpts<"LinkBitcodePostopt">, DefaultFalse,
PosFlag<SetTrue, [], [ClangOption], "Link builtin bitcodes after the "
"optimization pipeline">,
NegFlag<SetFalse, [], [ClangOption]>>;
def vectorize_loops : Flag<["-"], "vectorize-loops">,
HelpText<"Run the Loop vectorization passes">,
MarshallingInfoFlag<CodeGenOpts<"VectorizeLoop">>;
Expand Down
5 changes: 2 additions & 3 deletions clang/lib/Basic/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ struct CudaVersionMapEntry {
};
#define CUDA_ENTRY(major, minor) \
{ \
#major "." #minor, CudaVersion::CUDA_##major##minor, \
#major "." #minor, CudaVersion::CUDA_##major##minor, \
llvm::VersionTuple(major, minor) \
}

Expand All @@ -41,7 +41,6 @@ static const CudaVersionMapEntry CudaNameVersionMap[] = {
CUDA_ENTRY(12, 1),
CUDA_ENTRY(12, 2),
CUDA_ENTRY(12, 3),
CUDA_ENTRY(12, 4),
{"", CudaVersion::NEW, llvm::VersionTuple(std::numeric_limits<int>::max())},
{"unknown", CudaVersion::UNKNOWN, {}} // End of list tombstone.
};
Expand Down Expand Up @@ -242,7 +241,7 @@ CudaVersion MaxVersionForCudaArch(CudaArch A) {
}
}

bool CudaFeatureEnabled(llvm::VersionTuple Version, CudaFeature Feature) {
bool CudaFeatureEnabled(llvm::VersionTuple Version, CudaFeature Feature) {
return CudaFeatureEnabled(ToCudaVersion(Version), Feature);
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Basic/Targets.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -760,7 +760,7 @@ using namespace clang::targets;
TargetInfo *
TargetInfo::CreateTargetInfo(DiagnosticsEngine &Diags,
const std::shared_ptr<TargetOptions> &Opts) {
llvm::Triple Triple(llvm::Triple::normalize(Opts->Triple));
llvm::Triple Triple(Opts->Triple);

// Construct the target
std::unique_ptr<TargetInfo> Target = AllocateTarget(Triple, *Opts);
Expand Down
6 changes: 0 additions & 6 deletions clang/lib/Basic/Targets/PPC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ bool PPCTargetInfo::handleTargetFeatures(std::vector<std::string> &Features,
IsISA3_1 = true;
} else if (Feature == "+quadword-atomics") {
HasQuadwordAtomics = true;
} else if (Feature == "+aix-shared-lib-tls-model-opt") {
HasAIXShLibTLSModelOpt = true;
}
// TODO: Finish this list and add an assert that we've handled them
// all.
Expand Down Expand Up @@ -582,9 +580,6 @@ bool PPCTargetInfo::initFeatureMap(
Features["aix-small-local-exec-tls"] = false;
Features["aix-small-local-dynamic-tls"] = false;

// Turn off TLS model opt by default.
Features["aix-shared-lib-tls-model-opt"] = false;

Features["spe"] = llvm::StringSwitch<bool>(CPU)
.Case("8548", true)
.Case("e500", true)
Expand Down Expand Up @@ -727,7 +722,6 @@ bool PPCTargetInfo::hasFeature(StringRef Feature) const {
.Case("isa-v30-instructions", IsISA3_0)
.Case("isa-v31-instructions", IsISA3_1)
.Case("quadword-atomics", HasQuadwordAtomics)
.Case("aix-shared-lib-tls-model-opt", HasAIXShLibTLSModelOpt)
.Default(false);
}

Expand Down
1 change: 0 additions & 1 deletion clang/lib/Basic/Targets/PPC.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@ class LLVM_LIBRARY_VISIBILITY PPCTargetInfo : public TargetInfo {
bool IsISA3_0 = false;
bool IsISA3_1 = false;
bool HasQuadwordAtomics = false;
bool HasAIXShLibTLSModelOpt = false;

protected:
std::string ABI;
Expand Down
11 changes: 8 additions & 3 deletions clang/lib/CodeGen/BackendConsumer.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class BackendConsumer : public ASTConsumer {
const CodeGenOptions &CodeGenOpts;
const TargetOptions &TargetOpts;
const LangOptions &LangOpts;
const FileManager &FileMgr;
std::unique_ptr<raw_pwrite_stream> AsmOutStream;
ASTContext *Context;
IntrusiveRefCntPtr<llvm::vfs::FileSystem> FS;
Expand Down Expand Up @@ -75,7 +76,7 @@ class BackendConsumer : public ASTConsumer {
const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts, const LangOptions &LangOpts,
const std::string &InFile,
const FileManager &FileMgr, const std::string &InFile,
SmallVector<LinkModule, 4> LinkModules,
std::unique_ptr<raw_pwrite_stream> OS, llvm::LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr);
Expand All @@ -89,8 +90,8 @@ class BackendConsumer : public ASTConsumer {
const PreprocessorOptions &PPOpts,
const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts, const LangOptions &LangOpts,
llvm::Module *Module, SmallVector<LinkModule, 4> LinkModules,
llvm::LLVMContext &C,
const FileManager &FileMgr, llvm::Module *Module,
SmallVector<LinkModule, 4> LinkModules, llvm::LLVMContext &C,
CoverageSourceInfo *CoverageInfo = nullptr);

llvm::Module *getModule() const;
Expand All @@ -114,6 +115,10 @@ class BackendConsumer : public ASTConsumer {
// Links each entry in LinkModules into our module. Returns true on error.
bool LinkInModules(llvm::Module *M, bool ShouldLinkFiles = true);

// Load a bitcode module from -mlink-builtin-bitcode option using
// methods from a BackendConsumer instead of CompilerInstance
bool ReloadModules(llvm::Module *M);

/// Get the best possible source location to represent a diagnostic that
/// may have associated debug info.
const FullSourceLoc getBestLocationFromDebugLoc(
Expand Down
12 changes: 10 additions & 2 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,11 @@ static cl::opt<PGOOptions::ColdFuncOpt> ClPGOColdFuncAttr(
"Mark cold functions with optnone.")));

extern cl::opt<InstrProfCorrelator::ProfCorrelatorKind> ProfileCorrelate;

// Re-link builtin bitcodes after optimization
cl::opt<bool> ClRelinkBuiltinBitcodePostop(
"relink-builtin-bitcode-postop", cl::Optional,
cl::desc("Re-link builtin bitcodes after optimization."));
} // namespace llvm

namespace {
Expand Down Expand Up @@ -1050,8 +1055,11 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
}
}

// Link against bitcodes supplied via the -mlink-builtin-bitcode option
if (CodeGenOpts.LinkBitcodePostopt)
// Re-link against any bitcodes supplied via the -mlink-builtin-bitcode option
// Some optimizations may generate new function calls that would not have
// been linked pre-optimization (i.e. fused sincos calls generated by
// AMDGPULibCalls::fold_sincos.)
if (ClRelinkBuiltinBitcodePostop)
MPM.addPass(LinkInModulesPass(BC, false));

// Add a verifier pass if requested. We don't have to do this if the action
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/CodeGen/CGExprAgg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1736,7 +1736,7 @@ void AggExprEmitter::VisitCXXParenListOrInitListExpr(
for (const auto *Field : record->fields())
assert(
(Field->isUnnamedBitField() || Field->isAnonymousStructOrUnion()) &&
"Only unnamed bitfields or anonymous class allowed");
"Only unnamed bitfields or ananymous class allowed");
#endif
return;
}
Expand Down
56 changes: 46 additions & 10 deletions clang/lib/CodeGen/CodeGenAction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ using namespace llvm;

#define DEBUG_TYPE "codegenaction"

namespace llvm {
extern cl::opt<bool> ClRelinkBuiltinBitcodePostop;
}

namespace clang {
class BackendConsumer;
class ClangDiagnosticHandler final : public DiagnosticHandler {
Expand Down Expand Up @@ -114,12 +118,13 @@ BackendConsumer::BackendConsumer(
const HeaderSearchOptions &HeaderSearchOpts,
const PreprocessorOptions &PPOpts, const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts, const LangOptions &LangOpts,
const std::string &InFile, SmallVector<LinkModule, 4> LinkModules,
const FileManager &FileMgr, const std::string &InFile,
SmallVector<LinkModule, 4> LinkModules,
std::unique_ptr<raw_pwrite_stream> OS, LLVMContext &C,
CoverageSourceInfo *CoverageInfo)
: Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
AsmOutStream(std::move(OS)), Context(nullptr), FS(VFS),
FileMgr(FileMgr), AsmOutStream(std::move(OS)), Context(nullptr), FS(VFS),
LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
LLVMIRGenerationRefCount(0),
Gen(CreateLLVMCodeGen(Diags, InFile, std::move(VFS), HeaderSearchOpts,
Expand All @@ -139,11 +144,12 @@ BackendConsumer::BackendConsumer(
const HeaderSearchOptions &HeaderSearchOpts,
const PreprocessorOptions &PPOpts, const CodeGenOptions &CodeGenOpts,
const TargetOptions &TargetOpts, const LangOptions &LangOpts,
llvm::Module *Module, SmallVector<LinkModule, 4> LinkModules,
LLVMContext &C, CoverageSourceInfo *CoverageInfo)
const FileManager &FileMgr, llvm::Module *Module,
SmallVector<LinkModule, 4> LinkModules, LLVMContext &C,
CoverageSourceInfo *CoverageInfo)
: Diags(Diags), Action(Action), HeaderSearchOpts(HeaderSearchOpts),
CodeGenOpts(CodeGenOpts), TargetOpts(TargetOpts), LangOpts(LangOpts),
Context(nullptr), FS(VFS),
FileMgr(FileMgr), Context(nullptr), FS(VFS),
LLVMIRGeneration("irgen", "LLVM IR Generation Time"),
LLVMIRGenerationRefCount(0),
Gen(CreateLLVMCodeGen(Diags, "", std::move(VFS), HeaderSearchOpts, PPOpts,
Expand Down Expand Up @@ -226,6 +232,35 @@ void BackendConsumer::HandleInterestingDecl(DeclGroupRef D) {
HandleTopLevelDecl(D);
}

bool BackendConsumer::ReloadModules(llvm::Module *M) {
for (const CodeGenOptions::BitcodeFileToLink &F :
CodeGenOpts.LinkBitcodeFiles) {
auto BCBuf = FileMgr.getBufferForFile(F.Filename);
if (!BCBuf) {
Diags.Report(diag::err_cannot_open_file)
<< F.Filename << BCBuf.getError().message();
LinkModules.clear();
return true;
}

LLVMContext &Ctx = getModule()->getContext();
Expected<std::unique_ptr<llvm::Module>> ModuleOrErr =
getOwningLazyBitcodeModule(std::move(*BCBuf), Ctx);

if (!ModuleOrErr) {
handleAllErrors(ModuleOrErr.takeError(), [&](ErrorInfoBase &EIB) {
Diags.Report(diag::err_cannot_open_file) << F.Filename << EIB.message();
});
LinkModules.clear();
return true;
}
LinkModules.push_back({std::move(ModuleOrErr.get()), F.PropagateAttrs,
F.Internalize, F.LinkFlags});
}

return false; // success
}

// Links each entry in LinkModules into our module. Returns true on error.
bool BackendConsumer::LinkInModules(llvm::Module *M, bool ShouldLinkFiles) {
for (auto &LM : LinkModules) {
Expand Down Expand Up @@ -327,7 +362,7 @@ void BackendConsumer::HandleTranslationUnit(ASTContext &C) {
}

// Link each LinkModule into our module.
if (!CodeGenOpts.LinkBitcodePostopt && LinkInModules(getModule()))
if (LinkInModules(getModule()))
return;

for (auto &F : getModule()->functions()) {
Expand Down Expand Up @@ -1020,8 +1055,9 @@ CodeGenAction::CreateASTConsumer(CompilerInstance &CI, StringRef InFile) {
std::unique_ptr<BackendConsumer> Result(new BackendConsumer(
BA, CI.getDiagnostics(), &CI.getVirtualFileSystem(),
CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(), CI.getCodeGenOpts(),
CI.getTargetOpts(), CI.getLangOpts(), std::string(InFile),
std::move(LinkModules), std::move(OS), *VMContext, CoverageInfo));
CI.getTargetOpts(), CI.getLangOpts(), CI.getFileManager(),
std::string(InFile), std::move(LinkModules), std::move(OS), *VMContext,
CoverageInfo));
BEConsumer = Result.get();

// Enable generating macro debug info only when debug info is not disabled and
Expand Down Expand Up @@ -1192,11 +1228,11 @@ void CodeGenAction::ExecuteAction() {
BackendConsumer Result(BA, CI.getDiagnostics(), &CI.getVirtualFileSystem(),
CI.getHeaderSearchOpts(), CI.getPreprocessorOpts(),
CI.getCodeGenOpts(), CI.getTargetOpts(),
CI.getLangOpts(), TheModule.get(),
CI.getLangOpts(), CI.getFileManager(), TheModule.get(),
std::move(LinkModules), *VMContext, nullptr);

// Link in each pending link module.
if (!CodeGenOpts.LinkBitcodePostopt && Result.LinkInModules(&*TheModule))
if (Result.LinkInModules(&*TheModule))
return;

// PR44896: Force DiscardValueNames as false. DiscardValueNames cannot be
Expand Down
8 changes: 6 additions & 2 deletions clang/lib/CodeGen/LinkInModulesPass.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,12 @@ PreservedAnalyses LinkInModulesPass::run(Module &M, ModuleAnalysisManager &AM) {
if (!BC)
return PreservedAnalyses::all();

// Re-load bitcode modules from files
if (BC->ReloadModules(&M))
report_fatal_error("Bitcode module re-loading failed, aborted!");

if (BC->LinkInModules(&M, ShouldLinkFiles))
report_fatal_error("Bitcode module postopt linking failed, aborted!");
report_fatal_error("Bitcode module re-linking failed, aborted!");

return PreservedAnalyses::none();
return PreservedAnalyses::all();
}
3 changes: 0 additions & 3 deletions clang/lib/Driver/ToolChains/Cuda.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ CudaVersion getCudaVersion(uint32_t raw_version) {
return CudaVersion::CUDA_122;
if (raw_version < 12040)
return CudaVersion::CUDA_123;
if (raw_version < 12050)
return CudaVersion::CUDA_124;
return CudaVersion::NEW;
}

Expand Down Expand Up @@ -690,7 +688,6 @@ void NVPTX::getNVPTXTargetFeatures(const Driver &D, const llvm::Triple &Triple,
case CudaVersion::CUDA_##CUDA_VER: \
PtxFeature = "+ptx" #PTX_VER; \
break;
CASE_CUDA_VERSION(124, 84);
CASE_CUDA_VERSION(123, 83);
CASE_CUDA_VERSION(122, 82);
CASE_CUDA_VERSION(121, 81);
Expand Down
4 changes: 0 additions & 4 deletions clang/lib/Driver/ToolChains/Flang.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -748,10 +748,6 @@ void Flang::ConstructJob(Compilation &C, const JobAction &JA,
// Add other compile options
addOtherOptions(Args, CmdArgs);

// Disable all warnings
// TODO: Handle interactions between -w, -pedantic, -Wall, -WOption
Args.AddLastArg(CmdArgs, options::OPT_w);

// Forward flags for OpenMP. We don't do this if the current action is an
// device offloading action other than OpenMP.
if (Args.hasFlag(options::OPT_fopenmp, options::OPT_fopenmp_EQ,
Expand Down
29 changes: 29 additions & 0 deletions clang/lib/Driver/ToolChains/Gnu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -672,12 +672,41 @@ void tools::gnutools::Linker::ConstructJob(Compilation &C, const JobAction &JA,
}
}

// Facebook T92898286
if (Args.hasArg(options::OPT_post_link_optimize))
CmdArgs.push_back("-q");
// End Facebook T92898286

Args.AddAllArgs(CmdArgs, options::OPT_T);

const char *Exec = Args.MakeArgString(ToolChain.GetLinkerPath());
C.addCommand(std::make_unique<Command>(JA, *this,
ResponseFileSupport::AtFileCurCP(),
Exec, CmdArgs, Inputs, Output));
// Facebook T92898286
if (!Args.hasArg(options::OPT_post_link_optimize) || !Output.isFilename())
return;

const char *MvExec = Args.MakeArgString(ToolChain.GetProgramPath("mv"));
ArgStringList MoveCmdArgs;
MoveCmdArgs.push_back(Output.getFilename());
const char *PreBoltBin =
Args.MakeArgString(Twine(Output.getFilename()) + ".pre-bolt");
MoveCmdArgs.push_back(PreBoltBin);
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
MvExec, MoveCmdArgs, std::nullopt));

ArgStringList BoltCmdArgs;
const char *BoltExec =
Args.MakeArgString(ToolChain.GetProgramPath("llvm-bolt"));
BoltCmdArgs.push_back(PreBoltBin);
BoltCmdArgs.push_back("-reorder-blocks=reverse");
BoltCmdArgs.push_back("-update-debug-sections");
BoltCmdArgs.push_back("-o");
BoltCmdArgs.push_back(Output.getFilename());
C.addCommand(std::make_unique<Command>(JA, *this, ResponseFileSupport::None(),
BoltExec, BoltCmdArgs, std::nullopt));
// End Facebook T92898286
}

void tools::gnutools::Assembler::ConstructJob(Compilation &C,
Expand Down
44 changes: 2 additions & 42 deletions clang/lib/Driver/ToolChains/HLSL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,49 +98,9 @@ std::optional<std::string> tryParseProfile(StringRef Profile) {
else if (llvm::getAsUnsignedInteger(Parts[2], 0, Minor))
return std::nullopt;

// Determine DXIL version using the minor version number of Shader
// Model version specified in target profile. Prior to decoupling DXIL version
// numbering from that of Shader Model DXIL version 1.Y corresponds to SM 6.Y.
// E.g., dxilv1.Y-unknown-shadermodelX.Y-hull
// dxil-unknown-shadermodel-hull
llvm::Triple T;
Triple::SubArchType SubArch = llvm::Triple::NoSubArch;
switch (Minor) {
case 0:
SubArch = llvm::Triple::DXILSubArch_v1_0;
break;
case 1:
SubArch = llvm::Triple::DXILSubArch_v1_1;
break;
case 2:
SubArch = llvm::Triple::DXILSubArch_v1_2;
break;
case 3:
SubArch = llvm::Triple::DXILSubArch_v1_3;
break;
case 4:
SubArch = llvm::Triple::DXILSubArch_v1_4;
break;
case 5:
SubArch = llvm::Triple::DXILSubArch_v1_5;
break;
case 6:
SubArch = llvm::Triple::DXILSubArch_v1_6;
break;
case 7:
SubArch = llvm::Triple::DXILSubArch_v1_7;
break;
case 8:
SubArch = llvm::Triple::DXILSubArch_v1_8;
break;
case OfflineLibMinor:
// Always consider minor version x as the latest supported DXIL version
SubArch = llvm::Triple::LatestDXILSubArch;
break;
default:
// No DXIL Version corresponding to specified Shader Model version found
return std::nullopt;
}
T.setArch(Triple::ArchType::dxil, SubArch);
T.setArch(Triple::ArchType::dxil);
T.setOSName(Triple::getOSTypeName(Triple::OSType::ShaderModel).str() +
VersionTuple(Major, Minor).getAsString());
T.setEnvironment(Kind);
Expand Down
51 changes: 43 additions & 8 deletions clang/lib/Parse/ParseOpenMP.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4228,13 +4228,20 @@ bool Parser::parseMapperModifier(SemaOpenMP::OpenMPVarListDataTy &Data) {
return T.consumeClose();
}

static OpenMPMapClauseKind isMapType(Parser &P);

/// Parse map-type-modifiers in map clause.
/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] map-type : ] list)
/// map([ [map-type-modifier[,] [map-type-modifier[,] ...] [map-type] : ] list)
/// where, map-type-modifier ::= always | close | mapper(mapper-identifier) |
/// present
/// where, map-type ::= alloc | delete | from | release | to | tofrom
bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
bool HasMapType = false;
SourceLocation PreMapLoc = Tok.getLocation();
StringRef PreMapName = "";
while (getCurToken().isNot(tok::colon)) {
OpenMPMapModifierKind TypeModifier = isMapModifier(*this);
OpenMPMapClauseKind MapKind = isMapType(*this);
if (TypeModifier == OMPC_MAP_MODIFIER_always ||
TypeModifier == OMPC_MAP_MODIFIER_close ||
TypeModifier == OMPC_MAP_MODIFIER_present ||
Expand All @@ -4257,6 +4264,19 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
Diag(Data.MapTypeModifiersLoc.back(), diag::err_omp_missing_comma)
<< "map type modifier";

} else if (getLangOpts().OpenMP >= 60 && MapKind != OMPC_MAP_unknown) {
if (!HasMapType) {
HasMapType = true;
Data.ExtraModifier = MapKind;
MapKind = OMPC_MAP_unknown;
PreMapLoc = Tok.getLocation();
PreMapName = Tok.getIdentifierInfo()->getName();
} else {
Diag(Tok, diag::err_omp_more_one_map_type);
Diag(PreMapLoc, diag::note_previous_map_type_specified_here)
<< PreMapName;
}
ConsumeToken();
} else {
// For the case of unknown map-type-modifier or a map-type.
// Map-type is followed by a colon; the function returns when it
Expand All @@ -4267,8 +4287,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
continue;
}
// Potential map-type token as it is followed by a colon.
if (PP.LookAhead(0).is(tok::colon))
return false;
if (PP.LookAhead(0).is(tok::colon)) {
if (getLangOpts().OpenMP >= 60) {
break;
} else {
return false;
}
}

Diag(Tok, diag::err_omp_unknown_map_type_modifier)
<< (getLangOpts().OpenMP >= 51 ? (getLangOpts().OpenMP >= 52 ? 2 : 1)
: 0)
Expand All @@ -4278,6 +4304,14 @@ bool Parser::parseMapTypeModifiers(SemaOpenMP::OpenMPVarListDataTy &Data) {
if (getCurToken().is(tok::comma))
ConsumeToken();
}
if (getLangOpts().OpenMP >= 60 && !HasMapType) {
if (!Tok.is(tok::colon)) {
Diag(Tok, diag::err_omp_unknown_map_type);
ConsumeToken();
} else {
Data.ExtraModifier = OMPC_MAP_unknown;
}
}
return false;
}

Expand All @@ -4289,13 +4323,12 @@ static OpenMPMapClauseKind isMapType(Parser &P) {
if (!Tok.isOneOf(tok::identifier, tok::kw_delete))
return OMPC_MAP_unknown;
Preprocessor &PP = P.getPreprocessor();
OpenMPMapClauseKind MapType =
static_cast<OpenMPMapClauseKind>(getOpenMPSimpleClauseType(
OMPC_map, PP.getSpelling(Tok), P.getLangOpts()));
unsigned MapType =
getOpenMPSimpleClauseType(OMPC_map, PP.getSpelling(Tok), P.getLangOpts());
if (MapType == OMPC_MAP_to || MapType == OMPC_MAP_from ||
MapType == OMPC_MAP_tofrom || MapType == OMPC_MAP_alloc ||
MapType == OMPC_MAP_delete || MapType == OMPC_MAP_release)
return MapType;
return static_cast<OpenMPMapClauseKind>(MapType);
return OMPC_MAP_unknown;
}

Expand Down Expand Up @@ -4679,8 +4712,10 @@ bool Parser::ParseOpenMPVarList(OpenMPDirectiveKind DKind,
// Only parse map-type-modifier[s] and map-type if a colon is present in
// the map clause.
if (ColonPresent) {
if (getLangOpts().OpenMP >= 60 && getCurToken().is(tok::colon))
Diag(Tok, diag::err_omp_map_modifier_specification_list);
IsInvalidMapperModifier = parseMapTypeModifiers(Data);
if (!IsInvalidMapperModifier)
if (getLangOpts().OpenMP < 60 && !IsInvalidMapperModifier)
parseMapType(*this, Data);
else
SkipUntil(tok::colon, tok::annot_pragma_openmp_end, StopBeforeMatch);
Expand Down
35 changes: 15 additions & 20 deletions clang/lib/Sema/SemaLookup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1267,20 +1267,6 @@ struct FindLocalExternScope {
LookupResult &R;
bool OldFindLocalExtern;
};

/// Returns true if 'operator=' should be treated as a dependent name.
bool isDependentAssignmentOperator(DeclarationName Name,
DeclContext *LookupContext) {
const auto *LookupRecord = dyn_cast_if_present<CXXRecordDecl>(LookupContext);
// If the lookup context is the current instantiation but we are outside a
// complete-class context, we will never find the implicitly declared
// copy/move assignment operators because they are declared at the closing '}'
// of the class specifier. In such cases, we treat 'operator=' like any other
// unqualified name because the results of name lookup in the template
// definition/instantiation context will always be the same.
return Name.getCXXOverloadedOperator() == OO_Equal && LookupRecord &&
!LookupRecord->isBeingDefined() && LookupRecord->isDependentContext();
}
} // end anonymous namespace

bool Sema::CppLookupName(LookupResult &R, Scope *S) {
Expand All @@ -1289,6 +1275,13 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
DeclarationName Name = R.getLookupName();
Sema::LookupNameKind NameKind = R.getLookupKind();

// If this is the name of an implicitly-declared special member function,
// go through the scope stack to implicitly declare
if (isImplicitlyDeclaredMemberFunctionName(Name)) {
for (Scope *PreS = S; PreS; PreS = PreS->getParent())
if (DeclContext *DC = PreS->getEntity())
DeclareImplicitMemberFunctionsWithName(*this, Name, R.getNameLoc(), DC);
}
// C++23 [temp.dep.general]p2:
// The component name of an unqualified-id is dependent if
// - it is a conversion-function-id whose conversion-type-id
Expand All @@ -1306,8 +1299,9 @@ bool Sema::CppLookupName(LookupResult &R, Scope *S) {
if (isImplicitlyDeclaredMemberFunctionName(Name)) {
for (Scope *PreS = S; PreS; PreS = PreS->getParent())
if (DeclContext *DC = PreS->getEntity()) {
if (!R.isTemplateNameLookup() &&
isDependentAssignmentOperator(Name, DC)) {
if (DC->isDependentContext() && isa<CXXRecordDecl>(DC) &&
Name.getCXXOverloadedOperator() == OO_Equal &&
!R.isTemplateNameLookup()) {
R.setNotFoundInCurrentInstantiation();
return false;
}
Expand Down Expand Up @@ -2478,6 +2472,8 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
}
} QL(LookupCtx);

bool TemplateNameLookup = R.isTemplateNameLookup();
CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
if (!InUnqualifiedLookup && !R.isForRedeclaration()) {
// C++23 [temp.dep.type]p5:
// A qualified name is dependent if
Expand All @@ -2490,14 +2486,13 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
if (DeclarationName Name = R.getLookupName();
(Name.getNameKind() == DeclarationName::CXXConversionFunctionName &&
Name.getCXXNameType()->isDependentType()) ||
(!R.isTemplateNameLookup() &&
isDependentAssignmentOperator(Name, LookupCtx))) {
(Name.getCXXOverloadedOperator() == OO_Equal && LookupRec &&
LookupRec->isDependentContext() && !TemplateNameLookup)) {
R.setNotFoundInCurrentInstantiation();
return false;
}
}

CXXRecordDecl *LookupRec = dyn_cast<CXXRecordDecl>(LookupCtx);
if (LookupDirect(*this, R, LookupCtx)) {
R.resolveKind();
if (LookupRec)
Expand Down Expand Up @@ -2609,7 +2604,7 @@ bool Sema::LookupQualifiedName(LookupResult &R, DeclContext *LookupCtx,
// template, and if the name is used as a template-name, the
// reference refers to the class template itself and not a
// specialization thereof, and is not ambiguous.
if (R.isTemplateNameLookup())
if (TemplateNameLookup)
if (auto *TD = getAsTemplateNameDecl(ND))
ND = TD;

Expand Down
7 changes: 5 additions & 2 deletions clang/lib/Sema/SemaTemplate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -726,7 +726,7 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS,
const DeclarationNameInfo &NameInfo,
bool isAddressOfOperand,
const TemplateArgumentListInfo *TemplateArgs) {
QualType ThisType = getCurrentThisType();
DeclContext *DC = getFunctionLevelDeclContext();

// C++11 [expr.prim.general]p12:
// An id-expression that denotes a non-static data member or non-static
Expand All @@ -748,7 +748,10 @@ Sema::ActOnDependentIdExpression(const CXXScopeSpec &SS,
IsEnum = isa_and_nonnull<EnumType>(NNS->getAsType());

if (!MightBeCxx11UnevalField && !isAddressOfOperand && !IsEnum &&
!ThisType.isNull()) {
isa<CXXMethodDecl>(DC) &&
cast<CXXMethodDecl>(DC)->isImplicitObjectMemberFunction()) {
QualType ThisType = cast<CXXMethodDecl>(DC)->getThisType().getNonReferenceType();

// Since the 'this' expression is synthesized, we don't need to
// perform the double-lookup check.
NamedDecl *FirstQualifierInScope = nullptr;
Expand Down
26 changes: 13 additions & 13 deletions clang/lib/StaticAnalyzer/Checkers/MIGChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,13 @@ class MIGChecker : public Checker<check::PostCall, check::PreStmt<ReturnStmt>,
// additionally an argument of a MIG routine, the checker keeps track of that
// information and issues a warning when an error is returned from the
// respective routine.
CallDescriptionMap<unsigned> Deallocators = {
std::vector<std::pair<CallDescription, unsigned>> Deallocators = {
#define CALL(required_args, deallocated_arg, ...) \
{{CDM::SimpleFunc, {__VA_ARGS__}, required_args}, deallocated_arg}
// E.g., if the checker sees a C function 'vm_deallocate' that has
// exactly 3 parameters, it knows that argument #1 (starting from 0, i.e.
// the second argument) is going to be consumed in the sense of the MIG
// consume-on-success convention.
{{{__VA_ARGS__}, required_args}, deallocated_arg}
// E.g., if the checker sees a C function 'vm_deallocate' that is
// defined on class 'IOUserClient' that has exactly 3 parameters, it knows
// that argument #1 (starting from 0, i.e. the second argument) is going
// to be consumed in the sense of the MIG consume-on-success convention.
CALL(3, 1, "vm_deallocate"),
CALL(3, 1, "mach_vm_deallocate"),
CALL(2, 0, "mig_deallocate"),
Expand All @@ -78,9 +78,6 @@ class MIGChecker : public Checker<check::PostCall, check::PreStmt<ReturnStmt>,
CALL(1, 0, "thread_inspect_deallocate"),
CALL(1, 0, "upl_deallocate"),
CALL(1, 0, "vm_map_deallocate"),
#undef CALL
#define CALL(required_args, deallocated_arg, ...) \
{{CDM::CXXMethod, {__VA_ARGS__}, required_args}, deallocated_arg}
// E.g., if the checker sees a method 'releaseAsyncReference64()' that is
// defined on class 'IOUserClient' that takes exactly 1 argument, it knows
// that the argument is going to be consumed in the sense of the MIG
Expand All @@ -90,7 +87,7 @@ class MIGChecker : public Checker<check::PostCall, check::PreStmt<ReturnStmt>,
#undef CALL
};

CallDescription OsRefRetain{CDM::SimpleFunc, {"os_ref_retain"}, 1};
CallDescription OsRefRetain{{"os_ref_retain"}, 1};

void checkReturnAux(const ReturnStmt *RS, CheckerContext &C) const;

Expand Down Expand Up @@ -201,12 +198,15 @@ void MIGChecker::checkPostCall(const CallEvent &Call, CheckerContext &C) const {
if (!isInMIGCall(C))
return;

const unsigned *ArgIdxPtr = Deallocators.lookup(Call);
if (!ArgIdxPtr)
auto I = llvm::find_if(Deallocators,
[&](const std::pair<CallDescription, unsigned> &Item) {
return Item.first.matches(Call);
});
if (I == Deallocators.end())
return;

ProgramStateRef State = C.getState();
unsigned ArgIdx = *ArgIdxPtr;
unsigned ArgIdx = I->second;
SVal Arg = Call.getArgSVal(ArgIdx);
const ParmVarDecl *PVD = getOriginParam(Arg, C);
if (!PVD || State->contains<RefCountedParameters>(PVD))
Expand Down
19 changes: 4 additions & 15 deletions clang/lib/StaticAnalyzer/Checkers/MallocChecker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3451,7 +3451,7 @@ static bool isReferenceCountingPointerDestructor(const CXXDestructorDecl *DD) {
if (N.contains_insensitive("ptr") || N.contains_insensitive("pointer")) {
if (N.contains_insensitive("ref") || N.contains_insensitive("cnt") ||
N.contains_insensitive("intrusive") ||
N.contains_insensitive("shared") || N.ends_with_insensitive("rc")) {
N.contains_insensitive("shared")) {
return true;
}
}
Expand Down Expand Up @@ -3483,24 +3483,13 @@ PathDiagnosticPieceRef MallocBugVisitor::VisitNode(const ExplodedNode *N,
// original reference count is positive, we should not report use-after-frees
// on objects deleted in such destructors. This can probably be improved
// through better shared pointer modeling.
if (ReleaseDestructorLC && (ReleaseDestructorLC == CurrentLC ||
ReleaseDestructorLC->isParentOf(CurrentLC))) {
if (ReleaseDestructorLC) {
if (const auto *AE = dyn_cast<AtomicExpr>(S)) {
// Check for manual use of atomic builtins.
AtomicExpr::AtomicOp Op = AE->getOp();
if (Op == AtomicExpr::AO__c11_atomic_fetch_add ||
Op == AtomicExpr::AO__c11_atomic_fetch_sub) {
BR.markInvalid(getTag(), S);
}
} else if (const auto *CE = dyn_cast<CallExpr>(S)) {
// Check for `std::atomic` and such. This covers both regular method calls
// and operator calls.
if (const auto *MD =
dyn_cast_or_null<CXXMethodDecl>(CE->getDirectCallee())) {
const CXXRecordDecl *RD = MD->getParent();
// A bit wobbly with ".contains()" because it may be like
// "__atomic_base" or something.
if (StringRef(RD->getNameAsString()).contains("atomic")) {
if (ReleaseDestructorLC == CurrentLC ||
ReleaseDestructorLC->isParentOf(CurrentLC)) {
BR.markInvalid(getTag(), S);
}
}
Expand Down
7 changes: 0 additions & 7 deletions clang/test/Analysis/Inputs/system-header-simulator-cxx.h
Original file line number Diff line number Diff line change
Expand Up @@ -1260,13 +1260,6 @@ template<
iterator end() const { return iterator(val + 1); }
};

template <typename T>
class atomic {
public:
T operator++();
T operator--();
};

namespace execution {
class sequenced_policy {};
}
Expand Down
116 changes: 8 additions & 108 deletions clang/test/Analysis/NewDelete-atomics.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ typedef enum memory_order {
memory_order_seq_cst = __ATOMIC_SEQ_CST
} memory_order;

class RawObj {
class Obj {
int RefCnt;

public:
Expand All @@ -37,27 +37,11 @@ class RawObj {
void foo();
};

class StdAtomicObj {
std::atomic<int> RefCnt;

public:
int incRef() {
return ++RefCnt;
}

int decRef() {
return --RefCnt;
}

void foo();
};

template <typename T>
class IntrusivePtr {
T *Ptr;
Obj *Ptr;

public:
IntrusivePtr(T *Ptr) : Ptr(Ptr) {
IntrusivePtr(Obj *Ptr) : Ptr(Ptr) {
Ptr->incRef();
}

Expand All @@ -71,106 +55,22 @@ class IntrusivePtr {
delete Ptr;
}

T *getPtr() const { return Ptr; } // no-warning
};

// Also IntrusivePtr but let's dodge name-based heuristics.
template <typename T>
class DifferentlyNamed {
T *Ptr;

public:
DifferentlyNamed(T *Ptr) : Ptr(Ptr) {
Ptr->incRef();
}

DifferentlyNamed(const DifferentlyNamed &Other) : Ptr(Other.Ptr) {
Ptr->incRef();
}

~DifferentlyNamed() {
// We should not take the path on which the object is deleted.
if (Ptr->decRef() == 1)
delete Ptr;
}

T *getPtr() const { return Ptr; } // no-warning
Obj *getPtr() const { return Ptr; } // no-warning
};

void testDestroyLocalRefPtr() {
IntrusivePtr<RawObj> p1(new RawObj());
{
IntrusivePtr<RawObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}

void testDestroySymbolicRefPtr(const IntrusivePtr<RawObj> &p1) {
{
IntrusivePtr<RawObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}

void testDestroyLocalRefPtrWithAtomics() {
IntrusivePtr<StdAtomicObj> p1(new StdAtomicObj());
{
IntrusivePtr<StdAtomicObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}


void testDestroyLocalRefPtrWithAtomics(const IntrusivePtr<StdAtomicObj> &p1) {
IntrusivePtr p1(new Obj());
{
IntrusivePtr<StdAtomicObj> p2(p1);
IntrusivePtr p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}

void testDestroyLocalRefPtrDifferentlyNamed() {
DifferentlyNamed<RawObj> p1(new RawObj());
{
DifferentlyNamed<RawObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}

void testDestroySymbolicRefPtrDifferentlyNamed(
const DifferentlyNamed<RawObj> &p1) {
{
DifferentlyNamed<RawObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}

void testDestroyLocalRefPtrWithAtomicsDifferentlyNamed() {
DifferentlyNamed<StdAtomicObj> p1(new StdAtomicObj());
{
DifferentlyNamed<StdAtomicObj> p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
p1.getPtr()->foo(); // no-warning
}


void testDestroyLocalRefPtrWithAtomicsDifferentlyNamed(
const DifferentlyNamed<StdAtomicObj> &p1) {
void testDestroySymbolicRefPtr(const IntrusivePtr &p1) {
{
DifferentlyNamed<StdAtomicObj> p2(p1);
IntrusivePtr p2(p1);
}

// p1 still maintains ownership. The object is not deleted.
Expand Down
1 change: 1 addition & 0 deletions clang/test/Analysis/scan-build/deduplication.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Analysis/scan-build/exclude_directories.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir %clang -S \
RUN: %S/Inputs/multidirectory_project/directory1/file1.c \
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Analysis/scan-build/help.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: %scan-build -h | FileCheck %s
RUN: %scan-build --help | FileCheck %s

Expand Down
1 change: 1 addition & 0 deletions clang/test/Analysis/scan-build/html_output.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
Expand Down
13 changes: 5 additions & 8 deletions clang/test/Analysis/scan-build/lit.local.cfg
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# -*- Python -*-

import lit.util
import lit.formats
import os
import platform

use_lit_shell = os.environ.get("LIT_USE_INTERNAL_SHELL")
config.test_format = lit.formats.ShTest(use_lit_shell == "0")
Expand All @@ -12,16 +12,13 @@ clang_path = config.clang if config.have_llvm_driver else os.path.realpath(confi
config.substitutions.append(
(
"%scan-build",
"'%s' '%s' --use-analyzer=%s "
"'%s' --use-analyzer=%s "
% (
config.perl_executable,
os.path.join(
config.clang_src_dir, "tools", "scan-build", "bin", "scan-build"
lit.util.which(
"scan-build",
os.path.join(config.clang_src_dir, "tools", "scan-build", "bin"),
),
clang_path,
),
)
)

if not config.perl_executable or platform.system() == "Windows":
config.unsupported = True
1 change: 1 addition & 0 deletions clang/test/Analysis/scan-build/plist_html_output.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
Expand Down
1 change: 1 addition & 0 deletions clang/test/Analysis/scan-build/plist_output.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: cp %S/report-1.html %t.output_dir
RUN: cp %S/report-2.html %t.output_dir
Expand Down
3 changes: 3 additions & 0 deletions clang/test/Analysis/scan-build/silence-core-checkers.test
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
// FIXME: Actually, "perl".
REQUIRES: shell

RUN: rm -rf %t.output_dir && mkdir %t.output_dir
RUN: %scan-build -o %t.output_dir \
RUN: %clang -S %S/Inputs/null_dereference_and_division_by_zero.c \
Expand Down
13 changes: 0 additions & 13 deletions clang/test/CXX/temp/temp.res/temp.dep/temp.dep.type/p4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -471,19 +471,6 @@ namespace N3 {
this->C::operator=(*this);
}
};

template<typename T>
struct D {
auto not_instantiated() -> decltype(operator=(0)); // expected-error {{use of undeclared 'operator='}}
};

template<typename T>
struct E {
auto instantiated(E& e) -> decltype(operator=(e)); // expected-error {{use of undeclared 'operator='}}
};

template struct E<int>; // expected-note {{in instantiation of template class 'N3::E<int>' requested here}}

} // namespace N3

namespace N4 {
Expand Down
31 changes: 0 additions & 31 deletions clang/test/CodeGen/linking-bitcode-postopt.cpp

This file was deleted.

16 changes: 10 additions & 6 deletions clang/test/CodeGenCoroutines/coro-dwarf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,14 @@ void f_coro(int val, MoveOnly moParam, MoveAndCopy mcParam) {
// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "mcParam", arg: 3, scope: ![[SP]], file: !{{[0-9]+}}, line: {{[0-9]+}}, type: !{{[0-9]+}})
// CHECK: !{{[0-9]+}} = !DILocalVariable(name: "__promise",

// CHECK: ![[INIT:[0-9]+]] = distinct !DISubprogram(linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy.__await_suspend_wrapper__init"
// CHECK: !{{[0-9]+}} = !DILocalVariable(arg: 1, scope: ![[INIT]]
// CHECK: !{{[0-9]+}} = !DILocalVariable(arg: 2, scope: ![[INIT]]
// CHECK: !{{[0-9]+}} = distinct !DISubprogram(linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy.__await_suspend_wrapper__init"
// CHECK-NEXT: !{{[0-9]+}} = !DIFile
// CHECK-NEXT: !{{[0-9]+}} = !DISubroutineType
// CHECK-NEXT: !{{[0-9]+}} = !DILocalVariable(arg: 1,
// CHECK-NEXT: !{{[0-9]+}} = !DILocation
// CHECK-NEXT: !{{[0-9]+}} = !DILocalVariable(arg: 2,

// CHECK: ![[FINAL:[0-9]+]] = distinct !DISubprogram(linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy.__await_suspend_wrapper__final"
// CHECK: !{{[0-9]+}} = !DILocalVariable(arg: 1, scope: ![[FINAL]]
// CHECK: !{{[0-9]+}} = !DILocalVariable(arg: 2, scope: ![[FINAL]]
// CHECK: !{{[0-9]+}} = distinct !DISubprogram(linkageName: "_Z6f_coroi8MoveOnly11MoveAndCopy.__await_suspend_wrapper__final"
// CHECK-NEXT: !{{[0-9]+}} = !DILocalVariable(arg: 1,
// CHECK-NEXT: !{{[0-9]+}} = !DILocation
// CHECK-NEXT: !{{[0-9]+}} = !DILocalVariable(arg: 2,
2 changes: 1 addition & 1 deletion clang/test/CodeGenHLSL/basic-target.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@
// RUN: %clang -target dxil-pc-shadermodel6.0-geometry -S -emit-llvm -o - %s | FileCheck %s

// CHECK: target datalayout = "e-m:e-p:32:32-i1:32-i8:8-i16:16-i32:32-i64:64-f16:16-f32:32-f64:64-n8:16:32:64"
// CHECK: target triple = "dxilv1.0-pc-shadermodel6.0-{{[a-z]+}}"
// CHECK: target triple = "dxil-pc-shadermodel6.0-{{[a-z]+}}"
6 changes: 3 additions & 3 deletions clang/test/Driver/dxc_dxv_path.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,12 @@
// DXV_PATH:dxv{{(.exe)?}}" "-" "-o" "-"

// RUN: %clang_dxc -I test -Vd -Tlib_6_3 -### %s 2>&1 | FileCheck %s --check-prefix=VD
// VD:"-cc1"{{.*}}"-triple" "dxilv1.3-unknown-shadermodel6.3-library"
// VD:"-cc1"{{.*}}"-triple" "dxil-unknown-shadermodel6.3-library"
// VD-NOT:dxv not found

// RUN: %clang_dxc -Tlib_6_3 -ccc-print-bindings --dxv-path=%T -Fo %t.dxo %s 2>&1 | FileCheck %s --check-prefix=BINDINGS
// BINDINGS: "dxilv1.3-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
// BINDINGS-NEXT: "dxilv1.3-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"]
// BINDINGS: "dxil-unknown-shadermodel6.3-library" - "clang", inputs: ["[[INPUT:.+]]"], output: "[[DXC:.+]].dxo"
// BINDINGS-NEXT: "dxil-unknown-shadermodel6.3-library" - "hlsl::Validator", inputs: ["[[DXC]].dxo"]

// RUN: %clang_dxc -Tlib_6_3 -ccc-print-phases --dxv-path=%T -Fo %t.dxc %s 2>&1 | FileCheck %s --check-prefix=PHASES

Expand Down
58 changes: 58 additions & 0 deletions clang/test/OpenMP/target_ast_print.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1201,6 +1201,64 @@ foo();
}
#endif // OMP52

#ifdef OMP60

///==========================================================================///
// RUN: %clang_cc1 -DOMP60 -verify -Wno-vla -fopenmp -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix OMP60
// RUN: %clang_cc1 -DOMP60 -fopenmp -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -DOMP60 -fopenmp -fopenmp-version=60 -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck %s --check-prefix OMP60

// RUN: %clang_cc1 -DOMP60 -verify -Wno-vla -fopenmp-simd -fopenmp-version=60 -ast-print %s | FileCheck %s --check-prefix OMP60
// RUN: %clang_cc1 -DOMP60 -fopenmp-simd -fopenmp-version=60 -x c++ -std=c++11 -emit-pch -o %t %s
// RUN: %clang_cc1 -DOMP60 -fopenmp-simd -fopenmp-version=60 -std=c++11 -include-pch %t -fsyntax-only -verify -Wno-vla %s -ast-print | FileCheck %s --check-prefix OMP60

void foo() {}
template <typename T, int C>
T tmain(T argc, T *argv) {
T i;
#pragma omp target map(from always: i)
foo();
#pragma omp target map(from, close: i)
foo();
#pragma omp target map(always,close: i)
foo();
return 0;
}
//OMP60: template <typename T, int C> T tmain(T argc, T *argv) {
//OMP60-NEXT: T i;
//OMP60-NEXT: #pragma omp target map(always,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(close,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(always,close,tofrom: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: return 0;
//OMP60-NEXT:}
//OMP60: template<> int tmain<int, 5>(int argc, int *argv) {
//OMP60-NEXT: int i;
//OMP60-NEXT: #pragma omp target map(always,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(close,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(always,close,tofrom: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: return 0;
//OMP60-NEXT:}
//OMP60: template<> char tmain<char, 1>(char argc, char *argv) {
//OMP60-NEXT: char i;
//OMP60-NEXT: #pragma omp target map(always,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(close,from: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: #pragma omp target map(always,close,tofrom: i)
//OMP60-NEXT: foo();
//OMP60-NEXT: return 0;
//OMP60-NEXT:}
int main (int argc, char **argv) {
return tmain<int, 5>(argc, &argc) + tmain<char, 1>(argv[0][0], argv[0]);
}
#endif // OMP60

#ifdef OMPX

// RUN: %clang_cc1 -DOMPX -verify -Wno-vla -fopenmp -fopenmp-extensions -ast-print %s | FileCheck %s --check-prefix=OMPX
Expand Down
105 changes: 59 additions & 46 deletions clang/test/OpenMP/target_map_messages.cpp

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions clang/test/Options/enable_16bit_types_validation.hlsl
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@
// HV_invalid_2017: error: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl2017' and shader model is '6.4'
// TP_invalid: error: '-enable-16bit-types' option requires target HLSL Version >= 2018 and shader model >= 6.2, but HLSL Version is 'hlsl2021' and shader model is '6.0'

// valid_2021: "dxilv1.4-unknown-shadermodel6.4-library"
// valid_2021: "dxil-unknown-shadermodel6.4-library"
// valid_2021-SAME: "-std=hlsl2021"
// valid_2021-SAME: "-fnative-half-type"

// valid_2018: "dxilv1.4-unknown-shadermodel6.4-library"
// valid_2018: "dxil-unknown-shadermodel6.4-library"
// valid_2018-SAME: "-std=hlsl2018"
// valid_2018-SAME: "-fnative-half-type"

Expand Down
1 change: 0 additions & 1 deletion clang/test/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ config.enable_backtrace = @ENABLE_BACKTRACES@
config.enable_threads = @LLVM_ENABLE_THREADS@
config.reverse_iteration = @LLVM_ENABLE_REVERSE_ITERATION@
config.host_arch = "@HOST_ARCH@"
config.perl_executable = "@PERL_EXECUTABLE@"
config.python_executable = "@Python3_EXECUTABLE@"
config.use_z3_solver = lit_config.params.get('USE_Z3_SOLVER', "@USE_Z3_SOLVER@")
config.has_plugins = @CLANG_PLUGIN_SUPPORT@
Expand Down
2 changes: 1 addition & 1 deletion clang/unittests/Analysis/FlowSensitive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@ add_clang_unittest(ClangAnalysisFlowSensitiveTests
SignAnalysisTest.cpp
SimplifyConstraintsTest.cpp
SingleVarConstantPropagationTest.cpp
SolverTest.cpp
TestingSupport.cpp
TestingSupportTest.cpp
TransferBranchTest.cpp
TransferTest.cpp
TypeErasedDataflowAnalysisTest.cpp
UncheckedOptionalAccessModelTest.cpp
ValueTest.cpp
WatchedLiteralsSolverTest.cpp
)

clang_target_link_libraries(ClangAnalysisFlowSensitiveTests
Expand Down

Large diffs are not rendered by default.

This file was deleted.

22 changes: 10 additions & 12 deletions clang/unittests/Driver/DXCModeTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,27 +68,25 @@ TEST(DxcModeTest, TargetProfileValidation) {
IntrusiveRefCntPtr<DiagnosticOptions> DiagOpts = new DiagnosticOptions();
DiagnosticsEngine Diags(DiagID, &*DiagOpts, DiagConsumer);

validateTargetProfile("-Tvs_6_0", "dxilv1.0--shadermodel6.0-vertex",
validateTargetProfile("-Tvs_6_0", "dxil--shadermodel6.0-vertex",
InMemoryFileSystem, Diags);
validateTargetProfile("-Ths_6_1", "dxilv1.1--shadermodel6.1-hull",
validateTargetProfile("-Ths_6_1", "dxil--shadermodel6.1-hull",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tds_6_2", "dxilv1.2--shadermodel6.2-domain",
validateTargetProfile("-Tds_6_2", "dxil--shadermodel6.2-domain",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tds_6_2", "dxilv1.2--shadermodel6.2-domain",
validateTargetProfile("-Tds_6_2", "dxil--shadermodel6.2-domain",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tgs_6_3", "dxilv1.3--shadermodel6.3-geometry",
validateTargetProfile("-Tgs_6_3", "dxil--shadermodel6.3-geometry",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tps_6_4", "dxilv1.4--shadermodel6.4-pixel",
validateTargetProfile("-Tps_6_4", "dxil--shadermodel6.4-pixel",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tcs_6_5", "dxilv1.5--shadermodel6.5-compute",
validateTargetProfile("-Tcs_6_5", "dxil--shadermodel6.5-compute",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tms_6_6", "dxilv1.6--shadermodel6.6-mesh",
validateTargetProfile("-Tms_6_6", "dxil--shadermodel6.6-mesh",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tas_6_7", "dxilv1.7--shadermodel6.7-amplification",
validateTargetProfile("-Tas_6_7", "dxil--shadermodel6.7-amplification",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tcs_6_8", "dxilv1.8--shadermodel6.8-compute",
InMemoryFileSystem, Diags);
validateTargetProfile("-Tlib_6_x", "dxilv1.8--shadermodel6.15-library",
validateTargetProfile("-Tlib_6_x", "dxil--shadermodel6.15-library",
InMemoryFileSystem, Diags);

// Invalid tests.
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/test/asan/TestCases/Posix/fake_stack_gc.cpp
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// RUN: %clangxx_asan -O0 -pthread %s -o %t && %env_asan_opts=use_sigaltstack=0 not --crash %run %t 2>&1 | FileCheck %s
// RUN: %clangxx_asan -O0 -pthread %s -o %t && %env_asan_opts=use_sigaltstack=0 %run not --crash %t 2>&1 | FileCheck %s

// Check that fake stack does not discard frames on the main stack, when GC is
// triggered from high alt stack.
Expand Down
14 changes: 13 additions & 1 deletion cross-project-tests/lit.cfg.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ def get_required_attr(config, attr_name):
# use_clang() and use_lld() respectively, so set them to "", if needed.
if not hasattr(config, "clang_src_dir"):
config.clang_src_dir = ""
llvm_config.use_clang(required=("clang" in config.llvm_enabled_projects))
# Facebook T92898286
should_test_bolt = get_required_attr(config, "llvm_test_bolt")
if should_test_bolt:
llvm_config.use_clang(required=("clang" in config.llvm_enabled_projects), additional_flags=["--post-link-optimize"])
else:
llvm_config.use_clang(required=("clang" in config.llvm_enabled_projects))
# End Facebook T92898286

if not hasattr(config, "lld_src_dir"):
config.lld_src_dir = ""
Expand Down Expand Up @@ -293,3 +299,9 @@ def get_clang_default_dwarf_version_string(triple):
# Allow 'REQUIRES: XXX-registered-target' in tests.
for arch in config.targets_to_build:
config.available_features.add(arch.lower() + "-registered-target")

# Facebook T92898286
# Ensure the user's PYTHONPATH is included.
if "PYTHONPATH" in os.environ:
config.environment["PYTHONPATH"] = os.environ["PYTHONPATH"]
# End Facebook T92898286
4 changes: 4 additions & 0 deletions cross-project-tests/lit.site.cfg.py.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ config.mlir_src_root = "@MLIR_SOURCE_DIR@"

config.llvm_use_sanitizer = "@LLVM_USE_SANITIZER@"

# Facebook T92898286
config.llvm_test_bolt = lit.util.pythonize_bool("@LLVM_TEST_BOLT@")
# End Facebook T92898286

import lit.llvm
lit.llvm.initialize(lit_config, config)

Expand Down
8 changes: 0 additions & 8 deletions flang/include/flang/Frontend/CompilerInvocation.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,8 @@ class CompilerInvocation : public CompilerInvocationBase {
// Fortran Dialect options
Fortran::common::IntrinsicTypeDefaultKinds defaultKinds;

// Fortran Warning options
bool enableConformanceChecks = false;
bool enableUsageChecks = false;
bool disableWarnings = false;

/// Used in e.g. unparsing to dump the analyzed rather than the original
/// parse-tree objects.
Expand Down Expand Up @@ -199,9 +197,6 @@ class CompilerInvocation : public CompilerInvocationBase {
bool &getEnableUsageChecks() { return enableUsageChecks; }
const bool &getEnableUsageChecks() const { return enableUsageChecks; }

bool &getDisableWarnings() { return disableWarnings; }
const bool &getDisableWarnings() const { return disableWarnings; }

Fortran::parser::AnalyzedObjectsAsFortran &getAsFortran() {
return asFortran;
}
Expand Down Expand Up @@ -231,9 +226,6 @@ class CompilerInvocation : public CompilerInvocationBase {
// Enables the usage checks
void setEnableUsageChecks() { enableUsageChecks = true; }

// Disables all Warnings
void setDisableWarnings() { disableWarnings = true; }

/// Useful setters
void setArgv0(const char *dir) { argv0 = dir; }

Expand Down
12 changes: 0 additions & 12 deletions flang/include/flang/Lower/AbstractConverter.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,18 +219,6 @@ class AbstractConverter {
/// function.
virtual void bindHostAssocTuple(mlir::Value val) = 0;

/// Returns fir.dummy_scope operation's result value to be used
/// as dummy_scope operand of hlfir.declare operations for the dummy
/// arguments of this function.
virtual mlir::Value dummyArgsScopeValue() const = 0;

/// Returns true if the given symbol is a dummy argument of this function.
/// Note that it returns false for all the symbols after all the variables
/// are instantiated for this function, i.e. it can only be used reliably
/// during the instatiation of the variables.
virtual bool
isRegisteredDummySymbol(Fortran::semantics::SymbolRef symRef) const = 0;

//===--------------------------------------------------------------------===//
// Types
//===--------------------------------------------------------------------===//
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Optimizer/Builder/HLFIRTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,6 @@ fir::FortranVariableOpInterface
genDeclare(mlir::Location loc, fir::FirOpBuilder &builder,
const fir::ExtendedValue &exv, llvm::StringRef name,
fir::FortranVariableFlagsAttr flags,
mlir::Value dummyScope = nullptr,
fir::CUDADataAttributeAttr cudaAttr = {});

/// Generate an hlfir.associate to build a variable from an expression value.
Expand Down
1 change: 0 additions & 1 deletion flang/include/flang/Optimizer/HLFIR/HLFIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@ def hlfir_DeclareOp : hlfir_Op<"declare", [AttrSizedOperandSegments,
let builders = [
OpBuilder<(ins "mlir::Value":$memref, "llvm::StringRef":$uniq_name,
CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::ValueRange", "{}">:$typeparams,
CArg<"mlir::Value", "{}">:$dummy_scope,
CArg<"fir::FortranVariableFlagsAttr", "{}">:$fortran_attrs,
CArg<"fir::CUDADataAttributeAttr", "{}">:$cuda_attr)>];

Expand Down
10 changes: 0 additions & 10 deletions flang/lib/Frontend/CompilerInvocation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -975,11 +975,6 @@ static bool parseDialectArgs(CompilerInvocation &res, llvm::opt::ArgList &args,
res.setEnableConformanceChecks();
res.setEnableUsageChecks();
}

// -w
if (args.hasArg(clang::driver::options::OPT_w))
res.setDisableWarnings();

// -std=f2018
// TODO: Set proper options when more fortran standards
// are supported.
Expand Down Expand Up @@ -1408,11 +1403,6 @@ void CompilerInvocation::setFortranOpts() {

if (getEnableUsageChecks())
fortranOptions.features.WarnOnAllUsage();

if (getDisableWarnings()) {
fortranOptions.features.DisableAllNonstandardWarnings();
fortranOptions.features.DisableAllUsageWarnings();
}
}

std::unique_ptr<Fortran::semantics::SemanticsContext>
Expand Down
73 changes: 11 additions & 62 deletions flang/lib/Lower/Bridge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -900,16 +900,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
hostAssocTuple = val;
}

mlir::Value dummyArgsScopeValue() const override final {
return dummyArgsScope;
}

bool isRegisteredDummySymbol(
Fortran::semantics::SymbolRef symRef) const override final {
auto *sym = &*symRef;
return registeredDummySymbols.contains(sym);
}

void registerTypeInfo(mlir::Location loc,
Fortran::lower::SymbolRef typeInfoSym,
const Fortran::semantics::DerivedTypeSpec &typeSpec,
Expand Down Expand Up @@ -1155,11 +1145,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
/// yet. The final mapping will be done using this pre-mapping in
/// Fortran::lower::mapSymbolAttributes.
bool mapBlockArgToDummyOrResult(const Fortran::semantics::SymbolRef sym,
mlir::Value val, bool isResult) {
localSymbols.addSymbol(sym, val);
if (!isResult)
registerDummySymbol(sym);

mlir::Value val, bool forced = false) {
if (!forced && lookupSymbol(sym))
return false;
localSymbols.addSymbol(sym, val, forced);
return true;
}

Expand Down Expand Up @@ -4570,7 +4559,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
const Fortran::lower::CalleeInterface &callee) {
assert(builder && "require a builder object at this point");
using PassBy = Fortran::lower::CalleeInterface::PassEntityBy;
auto mapPassedEntity = [&](const auto arg, bool isResult = false) {
auto mapPassedEntity = [&](const auto arg) {
if (arg.passBy == PassBy::AddressAndLength) {
if (callee.characterize().IsBindC())
return;
Expand All @@ -4580,11 +4569,10 @@ class FirConverter : public Fortran::lower::AbstractConverter {
fir::factory::CharacterExprHelper charHelp{*builder, loc};
mlir::Value box =
charHelp.createEmboxChar(arg.firArgument, arg.firLength);
mapBlockArgToDummyOrResult(arg.entity->get(), box, isResult);
mapBlockArgToDummyOrResult(arg.entity->get(), box);
} else {
if (arg.entity.has_value()) {
mapBlockArgToDummyOrResult(arg.entity->get(), arg.firArgument,
isResult);
mapBlockArgToDummyOrResult(arg.entity->get(), arg.firArgument);
} else {
assert(funit.parentHasTupleHostAssoc() && "expect tuple argument");
}
Expand All @@ -4593,19 +4581,15 @@ class FirConverter : public Fortran::lower::AbstractConverter {
for (const Fortran::lower::CalleeInterface::PassedEntity &arg :
callee.getPassedArguments())
mapPassedEntity(arg);
if (lowerToHighLevelFIR() && !callee.getPassedArguments().empty()) {
mlir::Value scopeOp = builder->create<fir::DummyScopeOp>(toLocation());
setDummyArgsScope(scopeOp);
}
if (std::optional<Fortran::lower::CalleeInterface::PassedEntity>
passedResult = callee.getPassedResult()) {
mapPassedEntity(*passedResult, /*isResult=*/true);
mapPassedEntity(*passedResult);
// FIXME: need to make sure things are OK here. addSymbol may not be OK
if (funit.primaryResult &&
passedResult->entity->get() != *funit.primaryResult)
mapBlockArgToDummyOrResult(
*funit.primaryResult, getSymbolAddress(passedResult->entity->get()),
/*isResult=*/true);
*funit.primaryResult,
getSymbolAddress(passedResult->entity->get()));
}
}

Expand Down Expand Up @@ -4782,8 +4766,7 @@ class FirConverter : public Fortran::lower::AbstractConverter {
Fortran::lower::StatementContext stmtCtx;
if (std::optional<Fortran::lower::CalleeInterface::PassedEntity>
passedResult = callee.getPassedResult()) {
mapBlockArgToDummyOrResult(altResult.getSymbol(), resultArg.getAddr(),
/*isResult=*/true);
mapBlockArgToDummyOrResult(altResult.getSymbol(), resultArg.getAddr());
Fortran::lower::mapSymbolAttributes(*this, altResult, localSymbols,
stmtCtx);
} else {
Expand Down Expand Up @@ -4827,11 +4810,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
if (!funit.getHostAssoc().empty())
funit.getHostAssoc().hostProcedureBindings(*this, localSymbols);

// Unregister all dummy symbols, so that their cloning (e.g. for OpenMP
// privatization) does not create the cloned hlfir.declare operations
// with dummy_scope operands.
resetRegisteredDummySymbols();

// Create most function blocks in advance.
createEmptyBlocks(funit.evaluationList);

Expand Down Expand Up @@ -4951,8 +4929,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
hostAssocTuple = mlir::Value{};
localSymbols.clear();
blockId = 0;
dummyArgsScope = mlir::Value{};
resetRegisteredDummySymbols();
}

/// Helper to generate GlobalOps when the builder is not positioned in any
Expand Down Expand Up @@ -4981,7 +4957,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
delete builder;
builder = nullptr;
localSymbols.clear();
resetRegisteredDummySymbols();
}

/// Instantiate the data from a BLOCK DATA unit.
Expand Down Expand Up @@ -5399,23 +5374,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
globalOmpRequiresSymbol);
}

/// Record fir.dummy_scope operation for this function.
/// It will be used to set dummy_scope operand of the hlfir.declare
/// operations.
void setDummyArgsScope(mlir::Value val) {
assert(!dummyArgsScope && val);
dummyArgsScope = val;
}

/// Record the given symbol as a dummy argument of this function.
void registerDummySymbol(Fortran::semantics::SymbolRef symRef) {
auto *sym = &*symRef;
registeredDummySymbols.insert(sym);
}

/// Reset all registered dummy symbols.
void resetRegisteredDummySymbols() { registeredDummySymbols.clear(); }

//===--------------------------------------------------------------------===//

Fortran::lower::LoweringBridge &bridge;
Expand All @@ -5442,15 +5400,6 @@ class FirConverter : public Fortran::lower::AbstractConverter {
/// Tuple of host associated variables
mlir::Value hostAssocTuple;

/// Value of fir.dummy_scope operation for this function.
mlir::Value dummyArgsScope;

/// A set of dummy argument symbols for this function.
/// The set is only preserved during the instatiation
/// of variables for this function.
llvm::SmallPtrSet<const Fortran::semantics::Symbol *, 16>
registeredDummySymbols;

/// A map of unique names for constant expressions.
/// The names are used for representing the constant expressions
/// with global constant initialized objects.
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Lower/ConvertArrayConstructor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ class RuntimeTempStrategy : public StrategyBase {
mlir::Value shape = builder.genShape(loc, extents);
declare = builder.create<hlfir::DeclareOp>(
loc, tempStorage, tempName, shape, lengths,
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
fir::FortranVariableFlagsAttr{});
initialBoxValue =
builder.createBox(loc, boxType, declare->getOriginalBase(), shape,
/*slice=*/mlir::Value{}, lengths, /*tdesc=*/{});
Expand Down
3 changes: 1 addition & 2 deletions flang/lib/Lower/ConvertExprToHLFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1676,8 +1676,7 @@ class HlfirBuilder {
mlir::Value storagePtr = builder.createTemporary(loc, recTy);
auto varOp = hlfir::EntityWithAttributes{builder.create<hlfir::DeclareOp>(
loc, storagePtr, "ctor.temp", /*shape=*/nullptr,
/*typeparams=*/mlir::ValueRange{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{})};
/*typeparams=*/mlir::ValueRange{}, fir::FortranVariableFlagsAttr{})};

// Initialize any components that need initialization.
mlir::Value box = builder.createBox(loc, fir::ExtendedValue{varOp});
Expand Down
20 changes: 5 additions & 15 deletions flang/lib/Lower/ConvertVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1683,8 +1683,7 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,

// Declare a local pointer variable.
auto newBase = builder.create<hlfir::DeclareOp>(
loc, boxAlloc, name, /*shape=*/nullptr, lenParams,
/*dummy_scope=*/nullptr, attributes);
loc, boxAlloc, name, /*shape=*/nullptr, lenParams, attributes);
mlir::Value nullAddr = builder.createNullConstant(
loc, llvm::cast<fir::BaseBoxType>(ptrBoxType).getEleTy());

Expand All @@ -1711,12 +1710,8 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
symMap.addVariableDefinition(sym, newBase, force);
return;
}
mlir::Value dummyScope;
if (converter.isRegisteredDummySymbol(sym))
dummyScope = converter.dummyArgsScopeValue();
auto newBase = builder.create<hlfir::DeclareOp>(
loc, base, name, shapeOrShift, lenParams, dummyScope, attributes,
cudaAttr);
loc, base, name, shapeOrShift, lenParams, attributes, cudaAttr);
symMap.addVariableDefinition(sym, newBase, force);
return;
}
Expand Down Expand Up @@ -1766,11 +1761,8 @@ void Fortran::lower::genDeclareSymbol(
Fortran::lower::translateSymbolCUDADataAttribute(builder.getContext(),
sym.GetUltimate());
auto name = converter.mangleName(sym);
mlir::Value dummyScope;
if (converter.isRegisteredDummySymbol(sym))
dummyScope = converter.dummyArgsScopeValue();
hlfir::EntityWithAttributes declare = hlfir::genDeclare(
loc, builder, exv, name, attributes, dummyScope, cudaAttr);
hlfir::EntityWithAttributes declare =
hlfir::genDeclare(loc, builder, exv, name, attributes, cudaAttr);
symMap.addVariableDefinition(sym, declare.getIfVariableInterface(), force);
return;
}
Expand Down Expand Up @@ -2030,9 +2022,7 @@ void Fortran::lower::mapSymbolAttributes(
fir::factory::genMutableBoxRead(
builder, loc,
fir::factory::createTempMutableBox(builder, loc, ty, {}, {},
isPolymorphic)),
fir::FortranVariableFlagsEnum::None,
converter.isRegisteredDummySymbol(sym));
isPolymorphic)));
return true;
}
return false;
Expand Down
22 changes: 8 additions & 14 deletions flang/lib/Lower/OpenACC.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -425,8 +425,7 @@ static void genPrivateLikeInitRegion(mlir::OpBuilder &builder, RecipeOp recipe,
auto alloca = builder.create<fir::AllocaOp>(loc, refTy.getEleTy());
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, alloca, accPrivateInitName, /*shape=*/nullptr,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
retVal = declareOp.getBase();
} else if (auto seqTy = mlir::dyn_cast_or_null<fir::SequenceType>(
refTy.getEleTy())) {
Expand All @@ -447,8 +446,7 @@ static void genPrivateLikeInitRegion(mlir::OpBuilder &builder, RecipeOp recipe,
loc, seqTy, /*typeparams=*/mlir::ValueRange{}, extents);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, alloca, accPrivateInitName, shape,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
retVal = declareOp.getBase();
}
}
Expand Down Expand Up @@ -668,12 +666,10 @@ mlir::acc::FirstprivateRecipeOp Fortran::lower::createOrGetFirstprivateRecipe(

auto leftDeclOp = builder.create<hlfir::DeclareOp>(
loc, recipe.getCopyRegion().getArgument(0), llvm::StringRef{}, shape,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
auto rightDeclOp = builder.create<hlfir::DeclareOp>(
loc, recipe.getCopyRegion().getArgument(1), llvm::StringRef{}, shape,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});

hlfir::DesignateOp::Subscripts triplets =
getSubscriptsFromArgs(recipe.getCopyRegion().getArguments());
Expand Down Expand Up @@ -979,8 +975,7 @@ static mlir::Value genReductionInitRegion(fir::FirOpBuilder &builder,
mlir::Value alloca = builder.create<fir::AllocaOp>(loc, ty);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, alloca, accReductionInitName, /*shape=*/nullptr,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
builder.create<fir::StoreOp>(loc, builder.createConvert(loc, ty, initValue),
declareOp.getBase());
return declareOp.getBase();
Expand All @@ -996,8 +991,7 @@ static mlir::Value genReductionInitRegion(fir::FirOpBuilder &builder,
loc, seqTy, /*typeparams=*/mlir::ValueRange{}, extents);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, alloca, accReductionInitName, shape,
llvm::ArrayRef<mlir::Value>{}, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{});
llvm::ArrayRef<mlir::Value>{}, fir::FortranVariableFlagsAttr{});
mlir::Type idxTy = builder.getIndexType();
mlir::Type refTy = fir::ReferenceType::get(seqTy.getEleTy());
llvm::SmallVector<fir::DoLoopOp> loops;
Expand Down Expand Up @@ -1149,10 +1143,10 @@ static void genCombiner(fir::FirOpBuilder &builder, mlir::Location loc,
recipe.getCombinerRegion().getArguments());
auto v1DeclareOp = builder.create<hlfir::DeclareOp>(
loc, value1, llvm::StringRef{}, shape, llvm::ArrayRef<mlir::Value>{},
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
fir::FortranVariableFlagsAttr{});
auto v2DeclareOp = builder.create<hlfir::DeclareOp>(
loc, value2, llvm::StringRef{}, shape, llvm::ArrayRef<mlir::Value>{},
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
fir::FortranVariableFlagsAttr{});
hlfir::DesignateOp::Subscripts triplets = getTripletsFromArgs(recipe);

llvm::SmallVector<mlir::Value> lenParamsLeft;
Expand Down
12 changes: 6 additions & 6 deletions flang/lib/Lower/OpenMP/ClauseProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,12 @@ createCopyFunc(mlir::Location loc, Fortran::lower::AbstractConverter &converter,
builder.createIntegerConstant(loc, builder.getIndexType(), extent));
shape = builder.create<fir::ShapeOp>(loc, extents);
}
auto declDst = builder.create<hlfir::DeclareOp>(
loc, funcOp.getArgument(0), copyFuncName + "_dst", shape, typeparams,
/*dummy_scope=*/nullptr, attrs);
auto declSrc = builder.create<hlfir::DeclareOp>(
loc, funcOp.getArgument(1), copyFuncName + "_src", shape, typeparams,
/*dummy_scope=*/nullptr, attrs);
auto declDst = builder.create<hlfir::DeclareOp>(loc, funcOp.getArgument(0),
copyFuncName + "_dst", shape,
typeparams, attrs);
auto declSrc = builder.create<hlfir::DeclareOp>(loc, funcOp.getArgument(1),
copyFuncName + "_src", shape,
typeparams, attrs);
converter.copyVar(loc, declDst.getBase(), declSrc.getBase());
builder.create<mlir::func::ReturnOp>(loc);
return funcOp;
Expand Down
19 changes: 8 additions & 11 deletions flang/lib/Optimizer/Builder/HLFIRTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ mlir::Value hlfir::Entity::getFirBase() const {
fir::FortranVariableOpInterface
hlfir::genDeclare(mlir::Location loc, fir::FirOpBuilder &builder,
const fir::ExtendedValue &exv, llvm::StringRef name,
fir::FortranVariableFlagsAttr flags, mlir::Value dummyScope,
fir::FortranVariableFlagsAttr flags,
fir::CUDADataAttributeAttr cudaAttr) {

mlir::Value base = fir::getBase(exv);
Expand Down Expand Up @@ -229,7 +229,7 @@ hlfir::genDeclare(mlir::Location loc, fir::FirOpBuilder &builder,
},
[](const auto &) {});
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, base, name, shapeOrShift, lenParams, dummyScope, flags, cudaAttr);
loc, base, name, shapeOrShift, lenParams, flags, cudaAttr);
return mlir::cast<fir::FortranVariableOpInterface>(declareOp.getOperation());
}

Expand Down Expand Up @@ -1096,9 +1096,8 @@ hlfir::createTempFromMold(mlir::Location loc, fir::FirOpBuilder &builder,
/*shape=*/std::nullopt, lenParams);
isHeapAlloc = builder.createBool(loc, false);
}
auto declareOp =
builder.create<hlfir::DeclareOp>(loc, alloc, tmpName, shape, lenParams,
/*dummy_scope=*/nullptr, declAttrs);
auto declareOp = builder.create<hlfir::DeclareOp>(loc, alloc, tmpName, shape,
lenParams, declAttrs);
if (mold.isPolymorphic()) {
int rank = mold.getRank();
// TODO: should probably read rank from the mold.
Expand Down Expand Up @@ -1135,9 +1134,8 @@ hlfir::Entity hlfir::createStackTempFromMold(mlir::Location loc,
alloc = builder.createTemporary(loc, mold.getFortranElementType(), tmpName,
/*shape=*/std::nullopt, lenParams);
}
auto declareOp =
builder.create<hlfir::DeclareOp>(loc, alloc, tmpName, shape, lenParams,
/*dummy_scope=*/nullptr, declAttrs);
auto declareOp = builder.create<hlfir::DeclareOp>(loc, alloc, tmpName, shape,
lenParams, declAttrs);
return hlfir::Entity{declareOp.getBase()};
}

Expand All @@ -1155,7 +1153,7 @@ hlfir::convertCharacterKind(mlir::Location loc, fir::FirOpBuilder &builder,
return hlfir::EntityWithAttributes{builder.create<hlfir::DeclareOp>(
loc, res.getAddr(), ".temp.kindconvert", /*shape=*/nullptr,
/*typeparams=*/mlir::ValueRange{res.getLen()},
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{})};
fir::FortranVariableFlagsAttr{})};
}

std::pair<hlfir::Entity, std::optional<hlfir::CleanupFunction>>
Expand Down Expand Up @@ -1227,8 +1225,7 @@ hlfir::genTypeAndKindConvert(mlir::Location loc, fir::FirOpBuilder &builder,
builder.create<fir::ShapeShiftOp>(loc, shapeShiftType, lbAndExtents);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, associate.getFirBase(), *associate.getUniqName(), shapeShift,
associate.getTypeparams(), /*dummy_scope=*/nullptr,
/*flags=*/fir::FortranVariableFlagsAttr{});
associate.getTypeparams(), /*flags=*/fir::FortranVariableFlagsAttr{});
hlfir::Entity castWithLbounds =
mlir::cast<fir::FortranVariableOpInterface>(declareOp.getOperation());
fir::FirOpBuilder *bldr = &builder;
Expand Down
3 changes: 1 addition & 2 deletions flang/lib/Optimizer/Builder/TemporaryStorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ fir::factory::HomogeneousScalarStack::HomogeneousScalarStack(
mlir::Value shape = builder.genShape(loc, extents);
temp = builder
.create<hlfir::DeclareOp>(loc, tempStorage, tempName, shape,
lengths, /*dummy_scope=*/nullptr,
fir::FortranVariableFlagsAttr{})
lengths, fir::FortranVariableFlagsAttr{})
.getBase();
}

Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,6 @@ void hlfir::DeclareOp::build(mlir::OpBuilder &builder,
mlir::OperationState &result, mlir::Value memref,
llvm::StringRef uniq_name, mlir::Value shape,
mlir::ValueRange typeparams,
mlir::Value dummy_scope,
fir::FortranVariableFlagsAttr fortran_attrs,
fir::CUDADataAttributeAttr cuda_attr) {
auto nameAttr = builder.getStringAttr(uniq_name);
Expand All @@ -134,7 +133,8 @@ void hlfir::DeclareOp::build(mlir::OpBuilder &builder,
mlir::Type hlfirVariableType =
getHLFIRVariableType(inputType, hasExplicitLbs);
build(builder, result, {hlfirVariableType, inputType}, memref, shape,
typeparams, dummy_scope, nameAttr, fortran_attrs, cuda_attr);
typeparams, /*dummy_scope=*/nullptr, nameAttr, fortran_attrs,
cuda_attr);
}

mlir::LogicalResult hlfir::DeclareOp::verify() {
Expand Down
15 changes: 7 additions & 8 deletions flang/lib/Optimizer/HLFIR/Transforms/BufferizeHLFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,10 +122,9 @@ createArrayTemp(mlir::Location loc, fir::FirOpBuilder &builder,
fir::FortranVariableFlagsAttr::get(
builder.getContext(), fir::FortranVariableFlagsEnum::allocatable);

auto declareOp =
builder.create<hlfir::DeclareOp>(loc, alloc, tmpName,
/*shape=*/nullptr, lenParams,
/*dummy_scope=*/nullptr, declAttrs);
auto declareOp = builder.create<hlfir::DeclareOp>(loc, alloc, tmpName,
/*shape=*/nullptr,
lenParams, declAttrs);

int rank = extents.size();
fir::runtime::genAllocatableApplyMold(builder, loc, alloc,
Expand Down Expand Up @@ -153,9 +152,9 @@ createArrayTemp(mlir::Location loc, fir::FirOpBuilder &builder,

mlir::Value allocmem = builder.createHeapTemporary(loc, sequenceType, tmpName,
extents, lenParams);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, allocmem, tmpName, shape, lenParams,
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
auto declareOp =
builder.create<hlfir::DeclareOp>(loc, allocmem, tmpName, shape, lenParams,
fir::FortranVariableFlagsAttr{});
mlir::Value trueVal = builder.createBool(loc, true);
return {hlfir::Entity{declareOp.getBase()}, trueVal};
}
Expand Down Expand Up @@ -332,7 +331,7 @@ struct SetLengthOpConversion
/*shape=*/std::nullopt, lenParams);
auto declareOp = builder.create<hlfir::DeclareOp>(
loc, alloca, tmpName, /*shape=*/mlir::Value{}, lenParams,
/*dummy_scope=*/nullptr, fir::FortranVariableFlagsAttr{});
fir::FortranVariableFlagsAttr{});
hlfir::Entity temp{declareOp.getBase()};
// Assign string value to the created temp.
builder.create<hlfir::AssignOp>(loc, string, temp,
Expand Down
47 changes: 15 additions & 32 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,69 +84,52 @@ class OmpWorkshareBlockChecker {
parser::CharBlock source_;
};

class OmpCycleAndExitChecker {
class OmpCycleChecker {
public:
OmpCycleAndExitChecker(SemanticsContext &context, std::int64_t level)
: context_{context}, level_{level} {}
OmpCycleChecker(SemanticsContext &context, std::int64_t cycleLevel)
: context_{context}, cycleLevel_{cycleLevel} {}

template <typename T> bool Pre(const T &) { return true; }
template <typename T> void Post(const T &) {}

bool Pre(const parser::DoConstruct &dc) {
level_--;
cycleLevel_--;
const auto &constructName{std::get<0>(std::get<0>(dc.t).statement.t)};
if (constructName) {
constructNamesAndLevels_.emplace(
constructName.value().ToString(), level_);
constructName.value().ToString(), cycleLevel_);
}
return true;
}

void Post(const parser::DoConstruct &dc) { level_++; }

bool Pre(const parser::CycleStmt &cyclestmt) {
std::map<std::string, std::int64_t>::iterator it;
bool err{false};
if (cyclestmt.v) {
it = constructNamesAndLevels_.find(cyclestmt.v->source.ToString());
err = (it != constructNamesAndLevels_.end() && it->second > 0);
} else { // If there is no label then use the level of the last enclosing DO
err = level_ > 0;
} else {
// If there is no label then the cycle statement is associated with the
// closest enclosing DO. Use its level for the checks.
err = cycleLevel_ > 0;
}
if (err) {
context_.Say(*source_,
context_.Say(*cycleSource_,
"CYCLE statement to non-innermost associated loop of an OpenMP DO "
"construct"_err_en_US);
}
return true;
}

bool Pre(const parser::ExitStmt &exitStmt) {
std::map<std::string, std::int64_t>::iterator it;
bool err{false};
if (exitStmt.v) {
it = constructNamesAndLevels_.find(exitStmt.v->source.ToString());
err = (it != constructNamesAndLevels_.end() && it->second >= 0);
} else { // If there is no label then use the level of the last enclosing DO
err = level_ >= 0;
}
if (err) {
context_.Say(*source_,
"EXIT statement terminates associated loop of an OpenMP DO "
"construct"_err_en_US);
}
return true;
}

bool Pre(const parser::Statement<parser::ActionStmt> &actionstmt) {
source_ = &actionstmt.source;
cycleSource_ = &actionstmt.source;
return true;
}

private:
SemanticsContext &context_;
const parser::CharBlock *source_;
std::int64_t level_;
const parser::CharBlock *cycleSource_;
std::int64_t cycleLevel_;
std::map<std::string, std::int64_t> constructNamesAndLevels_;
};

Expand Down Expand Up @@ -674,8 +657,8 @@ std::int64_t OmpStructureChecker::GetOrdCollapseLevel(
void OmpStructureChecker::CheckCycleConstraints(
const parser::OpenMPLoopConstruct &x) {
std::int64_t ordCollapseLevel{GetOrdCollapseLevel(x)};
OmpCycleAndExitChecker checker{context_, ordCollapseLevel};
parser::Walk(x, checker);
OmpCycleChecker ompCycleChecker{context_, ordCollapseLevel};
parser::Walk(x, ompCycleChecker);
}

void OmpStructureChecker::CheckDistLinear(
Expand Down
31 changes: 0 additions & 31 deletions flang/test/Driver/w-option.f90

This file was deleted.

2 changes: 1 addition & 1 deletion flang/test/Fir/dispatch.f90
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ program test_type_to_class

! CHECK-LABEL: func.func @_QMdispatch1Pdisplay_class(
! CHECK-SAME: %[[ARG:.*]]: [[CLASS:!fir.class<.*>>]]
! CHECK: %[[ARG_DECL:.*]]:2 = hlfir.declare %[[ARG]] dummy_scope %{{[0-9]+}} {uniq_name = "_QMdispatch1Fdisplay_classEp"} : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.dscope) -> (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>)
! CHECK: %[[ARG_DECL:.*]]:2 = hlfir.declare %[[ARG]] {uniq_name = "_QMdispatch1Fdisplay_classEp"} : (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>) -> (!fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>, !fir.class<!fir.type<_QMdispatch1Tp1{a:i32,b:i32}>>)

! Check dynamic dispatch equal to `call p%display2()` with binding index = 2.
! CHECK: %[[BOXDESC:.*]] = fir.box_tdesc %[[ARG_DECL]]#0 : ([[CLASS]]) -> !fir.tdesc<none>
Expand Down
Loading