4 changes: 2 additions & 2 deletions clang/test/Misc/target-invalid-cpu-note.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

// RUN: not %clang_cc1 -triple arm64--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix AARCH64
// AARCH64: error: unknown target CPU 'not-a-cpu'
// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, cobalt-100, grace{{$}}
// AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}

// RUN: not %clang_cc1 -triple arm64--- -tune-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix TUNE_AARCH64
// TUNE_AARCH64: error: unknown target CPU 'not-a-cpu'
// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, cobalt-100, grace{{$}}
// TUNE_AARCH64-NEXT: note: valid target CPU values are: cortex-a34, cortex-a35, cortex-a53, cortex-a55, cortex-a510, cortex-a520, cortex-a57, cortex-a65, cortex-a65ae, cortex-a72, cortex-a73, cortex-a75, cortex-a76, cortex-a76ae, cortex-a77, cortex-a78, cortex-a78c, cortex-a710, cortex-a715, cortex-a720, cortex-r82, cortex-x1, cortex-x1c, cortex-x2, cortex-x3, cortex-x4, neoverse-e1, neoverse-n1, neoverse-n2, neoverse-512tvb, neoverse-v1, neoverse-v2, cyclone, apple-a7, apple-a8, apple-a9, apple-a10, apple-a11, apple-a12, apple-a13, apple-a14, apple-a15, apple-a16, apple-a17, apple-m1, apple-m2, apple-m3, apple-s4, apple-s5, exynos-m3, exynos-m4, exynos-m5, falkor, saphira, kryo, thunderx2t99, thunderx3t110, thunderx, thunderxt88, thunderxt81, thunderxt83, tsv110, a64fx, carmel, ampere1, ampere1a, ampere1b, cobalt-100, grace{{$}}

// RUN: not %clang_cc1 -triple i386--- -target-cpu not-a-cpu -fsyntax-only %s 2>&1 | FileCheck %s --check-prefix X86
// X86: error: unknown target CPU 'not-a-cpu'
Expand Down
16 changes: 16 additions & 0 deletions clang/test/SemaCXX/attr-target-mv-warn-unused.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// RUN: %clang_cc1 -triple x86_64-linux-gnu -fsyntax-only -verify -Wunused %s

__attribute__((target("sse3")))
static int not_used_fmv() { return 1; }
__attribute__((target("avx2")))
static int not_used_fmv() { return 2; }
__attribute__((target("default")))
static int not_used_fmv() { return 0; } // expected-warning {{unused function 'not_used_fmv'}}

__attribute__((target("sse3")))
static int definitely_used_fmv() { return 1; }
__attribute__((target("avx2")))
static int definitely_used_fmv() { return 2; }
__attribute__((target("default")))
static int definitely_used_fmv() { return 0; }
int definite_user() { return definitely_used_fmv(); }
13 changes: 13 additions & 0 deletions clang/unittests/Format/ConfigParseTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -695,6 +695,19 @@ TEST(ConfigParseTest, ParsesConfiguration) {
FormatStyle::RTBS_TopLevelDefinitions);

Style.AlwaysBreakTemplateDeclarations = FormatStyle::BTDS_Yes;
CHECK_PARSE("BreakTemplateDeclarations: Leave",
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Leave);
CHECK_PARSE("BreakTemplateDeclarations: No", AlwaysBreakTemplateDeclarations,
FormatStyle::BTDS_No);
CHECK_PARSE("BreakTemplateDeclarations: MultiLine",
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
CHECK_PARSE("BreakTemplateDeclarations: Yes", AlwaysBreakTemplateDeclarations,
FormatStyle::BTDS_Yes);
CHECK_PARSE("BreakTemplateDeclarations: false",
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_MultiLine);
CHECK_PARSE("BreakTemplateDeclarations: true",
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Yes);
// For backward compatibility:
CHECK_PARSE("AlwaysBreakTemplateDeclarations: Leave",
AlwaysBreakTemplateDeclarations, FormatStyle::BTDS_Leave);
CHECK_PARSE("AlwaysBreakTemplateDeclarations: No",
Expand Down
2 changes: 1 addition & 1 deletion compiler-rt/lib/hwasan/hwasan_report.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class ScopedReport {
public:
explicit ScopedReport(bool fatal) : fatal(fatal) {
Lock lock(&error_message_lock_);
error_message_ptr_ = fatal ? &error_message_ : nullptr;
error_message_ptr_ = &error_message_;
++hwasan_report_count;
}

Expand Down
6 changes: 3 additions & 3 deletions flang/include/flang/Lower/ConvertVariable.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,9 +139,9 @@ translateSymbolAttributes(mlir::MLIRContext *mlirContext,

/// Translate the CUDA Fortran attributes of \p sym into the FIR CUDA attribute
/// representation.
fir::CUDAAttributeAttr
translateSymbolCUDAAttribute(mlir::MLIRContext *mlirContext,
const Fortran::semantics::Symbol &sym);
fir::CUDADataAttributeAttr
translateSymbolCUDADataAttribute(mlir::MLIRContext *mlirContext,
const Fortran::semantics::Symbol &sym);

/// Map a symbol to a given fir::ExtendedValue. This will generate an
/// hlfir.declare when lowering to HLFIR and map the hlfir.declare result to the
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Optimizer/Builder/FIRBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -231,13 +231,13 @@ class FirOpBuilder : public mlir::OpBuilder, public mlir::OpBuilder::Listener {
mlir::StringAttr linkage = {},
mlir::Attribute value = {}, bool isConst = false,
bool isTarget = false,
fir::CUDAAttributeAttr cudaAttr = {});
fir::CUDADataAttributeAttr cudaAttr = {});

fir::GlobalOp createGlobal(mlir::Location loc, mlir::Type type,
llvm::StringRef name, bool isConst, bool isTarget,
std::function<void(FirOpBuilder &)> bodyBuilder,
mlir::StringAttr linkage = {},
fir::CUDAAttributeAttr cudaAttr = {});
fir::CUDADataAttributeAttr cudaAttr = {});

/// Create a global constant (read-only) value.
fir::GlobalOp createGlobalConstant(mlir::Location loc, mlir::Type type,
Expand Down
2 changes: 1 addition & 1 deletion flang/include/flang/Optimizer/Builder/HLFIRTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ fir::FortranVariableOpInterface
genDeclare(mlir::Location loc, fir::FirOpBuilder &builder,
const fir::ExtendedValue &exv, llvm::StringRef name,
fir::FortranVariableFlagsAttr flags,
fir::CUDAAttributeAttr cudaAttr = {});
fir::CUDADataAttributeAttr cudaAttr = {});

/// Generate an hlfir.associate to build a variable from an expression value.
/// The type of the variable must be provided so that scalar logicals are
Expand Down
61 changes: 41 additions & 20 deletions flang/include/flang/Optimizer/Dialect/FIRAttr.td
Original file line number Diff line number Diff line change
Expand Up @@ -58,38 +58,59 @@ def fir_FortranVariableFlagsAttr : fir_Attr<"FortranVariableFlags"> {
"::fir::FortranVariableFlagsAttr::get($_builder.getContext(), $0)";
}

def CUDAconstant : I32EnumAttrCase<"Constant", 0, "constant">;
def CUDAdevice : I32EnumAttrCase<"Device", 1, "device">;
def CUDAmanaged : I32EnumAttrCase<"Managed", 2, "managed">;
def CUDApinned : I32EnumAttrCase<"Pinned", 3, "pinned">;
def CUDAshared : I32EnumAttrCase<"Shared", 4, "shared">;
def CUDAunified : I32EnumAttrCase<"Unified", 5, "unified">;
// Texture is omitted since it is obsolete and rejected by semantic.
def fir_BoxFieldAttr : I32EnumAttr<
"BoxFieldAttr", "",
[
I32EnumAttrCase<"base_addr", 0>,
I32EnumAttrCase<"derived_type", 1>
]> {
let cppNamespace = "fir";
}

// mlir::SideEffects::Resource for modelling operations which add debugging information
def DebuggingResource : Resource<"::fir::DebuggingResource">;

//===----------------------------------------------------------------------===//
// CUDA Fortran specific attributes
//===----------------------------------------------------------------------===//

def fir_CUDAAttribute : I32EnumAttr<
"CUDAAttribute",
def fir_CUDADataAttribute : I32EnumAttr<
"CUDADataAttribute",
"CUDA Fortran variable attributes",
[CUDAconstant, CUDAdevice, CUDAmanaged, CUDApinned, CUDAshared,
CUDAunified]> {
[
I32EnumAttrCase<"Constant", 0, "constant">,
I32EnumAttrCase<"Device", 1, "device">,
I32EnumAttrCase<"Managed", 2, "managed">,
I32EnumAttrCase<"Pinned", 3, "pinned">,
I32EnumAttrCase<"Shared", 4, "shared">,
I32EnumAttrCase<"Unified", 5, "unified">,
// Texture is omitted since it is obsolete and rejected by semantic.
]> {
let genSpecializedAttr = 0;
let cppNamespace = "::fir";
}

def fir_CUDAAttributeAttr : EnumAttr<fir_Dialect, fir_CUDAAttribute, "cuda"> {
def fir_CUDADataAttributeAttr :
EnumAttr<fir_Dialect, fir_CUDADataAttribute, "cuda"> {
let assemblyFormat = [{ ```<` $value `>` }];
}

def fir_BoxFieldAttr : I32EnumAttr<
"BoxFieldAttr", "",
def fir_CUDAProcAttribute : I32EnumAttr<
"CUDAProcAttribute", "CUDA Fortran procedure attributes",
[
I32EnumAttrCase<"base_addr", 0>,
I32EnumAttrCase<"derived_type", 1>
I32EnumAttrCase<"Host", 0, "host">,
I32EnumAttrCase<"Device", 1, "device">,
I32EnumAttrCase<"HostDevice", 2, "host_device">,
I32EnumAttrCase<"Global", 3, "global">,
I32EnumAttrCase<"GridGlobal", 4, "grid_global">,
]> {
let cppNamespace = "fir";
let genSpecializedAttr = 0;
let cppNamespace = "::fir";
}


// mlir::SideEffects::Resource for modelling operations which add debugging information
def DebuggingResource : Resource<"::fir::DebuggingResource">;
def fir_CUDAProcAttributeAttr :
EnumAttr<fir_Dialect, fir_CUDAProcAttribute, "cuda_proc"> {
let assemblyFormat = [{ ```<` $value `>` }];
}

#endif // FIR_DIALECT_FIR_ATTRS
4 changes: 2 additions & 2 deletions flang/include/flang/Optimizer/Dialect/FIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -2738,7 +2738,7 @@ def fir_GlobalOp : fir_Op<"global", [IsolatedFromAbove, Symbol]> {
OptionalAttr<UnitAttr>:$constant,
OptionalAttr<UnitAttr>:$target,
OptionalAttr<StrAttr>:$linkName,
OptionalAttr<fir_CUDAAttributeAttr>:$cuda_attr
OptionalAttr<fir_CUDADataAttributeAttr>:$cuda_attr
);

let regions = (region AtMostRegion<1>:$region);
Expand Down Expand Up @@ -3029,7 +3029,7 @@ def fir_DeclareOp : fir_Op<"declare", [AttrSizedOperandSegments,
Variadic<AnyIntegerType>:$typeparams,
Builtin_StringAttr:$uniq_name,
OptionalAttr<fir_FortranVariableFlagsAttr>:$fortran_attrs,
OptionalAttr<fir_CUDAAttributeAttr>:$cuda_attr
OptionalAttr<fir_CUDADataAttributeAttr>:$cuda_attr
);

let results = (outs AnyRefOrBox);
Expand Down
4 changes: 2 additions & 2 deletions flang/include/flang/Optimizer/HLFIR/HLFIROps.td
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ def hlfir_DeclareOp : hlfir_Op<"declare", [AttrSizedOperandSegments,
Variadic<AnyIntegerType>:$typeparams,
Builtin_StringAttr:$uniq_name,
OptionalAttr<fir_FortranVariableFlagsAttr>:$fortran_attrs,
OptionalAttr<fir_CUDAAttributeAttr>:$cuda_attr
OptionalAttr<fir_CUDADataAttributeAttr>:$cuda_attr
);

let results = (outs AnyFortranVariable, AnyRefOrBoxLike);
Expand All @@ -103,7 +103,7 @@ def hlfir_DeclareOp : hlfir_Op<"declare", [AttrSizedOperandSegments,
OpBuilder<(ins "mlir::Value":$memref, "llvm::StringRef":$uniq_name,
CArg<"mlir::Value", "{}">:$shape, CArg<"mlir::ValueRange", "{}">:$typeparams,
CArg<"fir::FortranVariableFlagsAttr", "{}">:$fortran_attrs,
CArg<"fir::CUDAAttributeAttr", "{}">:$cuda_attr)>];
CArg<"fir::CUDADataAttributeAttr", "{}">:$cuda_attr)>];

let extraClassDeclaration = [{
/// Get the variable original base (same as input). It lacks
Expand Down
47 changes: 37 additions & 10 deletions flang/include/flang/Optimizer/Support/Utils.h
Original file line number Diff line number Diff line change
Expand Up @@ -273,32 +273,59 @@ inline void genMinMaxlocReductionLoop(
builder.setInsertionPointAfter(ifMaskTrueOp);
}

inline fir::CUDAAttributeAttr
getCUDAAttribute(mlir::MLIRContext *mlirContext,
std::optional<Fortran::common::CUDADataAttr> cudaAttr) {
inline fir::CUDADataAttributeAttr
getCUDADataAttribute(mlir::MLIRContext *mlirContext,
std::optional<Fortran::common::CUDADataAttr> cudaAttr) {
if (cudaAttr) {
fir::CUDAAttribute attr;
fir::CUDADataAttribute attr;
switch (*cudaAttr) {
case Fortran::common::CUDADataAttr::Constant:
attr = fir::CUDAAttribute::Constant;
attr = fir::CUDADataAttribute::Constant;
break;
case Fortran::common::CUDADataAttr::Device:
attr = fir::CUDAAttribute::Device;
attr = fir::CUDADataAttribute::Device;
break;
case Fortran::common::CUDADataAttr::Managed:
attr = fir::CUDAAttribute::Managed;
attr = fir::CUDADataAttribute::Managed;
break;
case Fortran::common::CUDADataAttr::Pinned:
attr = fir::CUDAAttribute::Pinned;
attr = fir::CUDADataAttribute::Pinned;
break;
case Fortran::common::CUDADataAttr::Shared:
attr = fir::CUDAAttribute::Shared;
attr = fir::CUDADataAttribute::Shared;
break;
case Fortran::common::CUDADataAttr::Texture:
// Obsolete attribute
return {};
}
return fir::CUDAAttributeAttr::get(mlirContext, attr);
return fir::CUDADataAttributeAttr::get(mlirContext, attr);
}
return {};
}

inline fir::CUDAProcAttributeAttr getCUDAProcAttribute(
mlir::MLIRContext *mlirContext,
std::optional<Fortran::common::CUDASubprogramAttrs> cudaAttr) {
if (cudaAttr) {
fir::CUDAProcAttribute attr;
switch (*cudaAttr) {
case Fortran::common::CUDASubprogramAttrs::Host:
attr = fir::CUDAProcAttribute::Host;
break;
case Fortran::common::CUDASubprogramAttrs::Device:
attr = fir::CUDAProcAttribute::Device;
break;
case Fortran::common::CUDASubprogramAttrs::HostDevice:
attr = fir::CUDAProcAttribute::HostDevice;
break;
case Fortran::common::CUDASubprogramAttrs::Global:
attr = fir::CUDAProcAttribute::Global;
break;
case Fortran::common::CUDASubprogramAttrs::Grid_Global:
attr = fir::CUDAProcAttribute::GridGlobal;
break;
}
return fir::CUDAProcAttributeAttr::get(mlirContext, attr);
}
return {};
}
Expand Down
9 changes: 8 additions & 1 deletion flang/lib/Lower/CallInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//===----------------------------------------------------------------------===//

#include "flang/Lower/CallInterface.h"
#include "flang/Common/Fortran.h"
#include "flang/Evaluate/fold.h"
#include "flang/Lower/Bridge.h"
#include "flang/Lower/Mangler.h"
Expand Down Expand Up @@ -559,6 +560,12 @@ void Fortran::lower::CallInterface<T>::declare() {
func.setArgAttrs(placeHolder.index(), placeHolder.value().attributes);
side().setFuncAttrs(func);
}
if (characteristic && characteristic->cudaSubprogramAttrs) {
func.getOperation()->setAttr(
fir::getCUDAAttrName(),
fir::getCUDAProcAttribute(func.getContext(),
*characteristic->cudaSubprogramAttrs));
}
}
}

Expand Down Expand Up @@ -972,7 +979,7 @@ class Fortran::lower::CallInterfaceImpl {
if (obj.cudaDataAttr)
attrs.emplace_back(
mlir::StringAttr::get(&mlirContext, fir::getCUDAAttrName()),
fir::getCUDAAttribute(&mlirContext, obj.cudaDataAttr));
fir::getCUDADataAttribute(&mlirContext, obj.cudaDataAttr));

// TODO: intents that require special care (e.g finalization)

Expand Down
23 changes: 12 additions & 11 deletions flang/lib/Lower/ConvertVariable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
const Fortran::lower::pft::Variable &var,
llvm::StringRef globalName,
mlir::StringAttr linkage,
fir::CUDAAttributeAttr cudaAttr = {});
fir::CUDADataAttributeAttr cudaAttr = {});

static mlir::Location genLocation(Fortran::lower::AbstractConverter &converter,
const Fortran::semantics::Symbol &sym) {
Expand Down Expand Up @@ -464,7 +464,7 @@ static fir::GlobalOp defineGlobal(Fortran::lower::AbstractConverter &converter,
const Fortran::lower::pft::Variable &var,
llvm::StringRef globalName,
mlir::StringAttr linkage,
fir::CUDAAttributeAttr cudaAttr) {
fir::CUDADataAttributeAttr cudaAttr) {
fir::FirOpBuilder &builder = converter.getFirOpBuilder();
const Fortran::semantics::Symbol &sym = var.getSymbol();
mlir::Location loc = genLocation(converter, sym);
Expand Down Expand Up @@ -1583,11 +1583,11 @@ fir::FortranVariableFlagsAttr Fortran::lower::translateSymbolAttributes(
return fir::FortranVariableFlagsAttr::get(mlirContext, flags);
}

fir::CUDAAttributeAttr Fortran::lower::translateSymbolCUDAAttribute(
fir::CUDADataAttributeAttr Fortran::lower::translateSymbolCUDADataAttribute(
mlir::MLIRContext *mlirContext, const Fortran::semantics::Symbol &sym) {
std::optional<Fortran::common::CUDADataAttr> cudaAttr =
Fortran::semantics::GetCUDADataAttr(&sym);
return fir::getCUDAAttribute(mlirContext, cudaAttr);
return fir::getCUDADataAttribute(mlirContext, cudaAttr);
}

/// Map a symbol to its FIR address and evaluated specification expressions.
Expand Down Expand Up @@ -1629,8 +1629,9 @@ static void genDeclareSymbol(Fortran::lower::AbstractConverter &converter,
auto name = converter.mangleName(sym);
fir::FortranVariableFlagsAttr attributes =
Fortran::lower::translateSymbolAttributes(builder.getContext(), sym);
fir::CUDAAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDAAttribute(builder.getContext(), sym);
fir::CUDADataAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDADataAttribute(builder.getContext(),
sym);

if (isCrayPointee) {
mlir::Type baseType =
Expand Down Expand Up @@ -1722,9 +1723,9 @@ void Fortran::lower::genDeclareSymbol(
fir::FortranVariableFlagsAttr attributes =
Fortran::lower::translateSymbolAttributes(
builder.getContext(), sym.GetUltimate(), extraFlags);
fir::CUDAAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDAAttribute(builder.getContext(),
sym.GetUltimate());
fir::CUDADataAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDADataAttribute(builder.getContext(),
sym.GetUltimate());
auto name = converter.mangleName(sym);
hlfir::EntityWithAttributes declare =
hlfir::genDeclare(loc, builder, exv, name, attributes, cudaAttr);
Expand Down Expand Up @@ -2222,8 +2223,8 @@ void Fortran::lower::defineModuleVariable(
// Do nothing. Mapping will be done on user side.
} else {
std::string globalName = converter.mangleName(sym);
fir::CUDAAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDAAttribute(
fir::CUDADataAttributeAttr cudaAttr =
Fortran::lower::translateSymbolCUDADataAttribute(
converter.getFirOpBuilder().getContext(), sym);
defineGlobal(converter, var, globalName, linkage, cudaAttr);
}
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/Builder/FIRBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,7 +274,7 @@ mlir::Value fir::FirOpBuilder::createHeapTemporary(
fir::GlobalOp fir::FirOpBuilder::createGlobal(
mlir::Location loc, mlir::Type type, llvm::StringRef name,
mlir::StringAttr linkage, mlir::Attribute value, bool isConst,
bool isTarget, fir::CUDAAttributeAttr cudaAttr) {
bool isTarget, fir::CUDADataAttributeAttr cudaAttr) {
auto module = getModule();
auto insertPt = saveInsertionPoint();
if (auto glob = module.lookupSymbol<fir::GlobalOp>(name))
Expand All @@ -296,7 +296,7 @@ fir::GlobalOp fir::FirOpBuilder::createGlobal(
fir::GlobalOp fir::FirOpBuilder::createGlobal(
mlir::Location loc, mlir::Type type, llvm::StringRef name, bool isConst,
bool isTarget, std::function<void(FirOpBuilder &)> bodyBuilder,
mlir::StringAttr linkage, fir::CUDAAttributeAttr cudaAttr) {
mlir::StringAttr linkage, fir::CUDADataAttributeAttr cudaAttr) {
auto module = getModule();
auto insertPt = saveInsertionPoint();
if (auto glob = module.lookupSymbol<fir::GlobalOp>(name))
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Builder/HLFIRTools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ fir::FortranVariableOpInterface
hlfir::genDeclare(mlir::Location loc, fir::FirOpBuilder &builder,
const fir::ExtendedValue &exv, llvm::StringRef name,
fir::FortranVariableFlagsAttr flags,
fir::CUDAAttributeAttr cudaAttr) {
fir::CUDADataAttributeAttr cudaAttr) {

mlir::Value base = fir::getBase(exv);
assert(fir::conformsWithPassByRef(base.getType()) &&
Expand Down
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/Dialect/FIRAttr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -298,5 +298,5 @@ void fir::printFirAttribute(FIROpsDialect *dialect, mlir::Attribute attr,
void FIROpsDialect::registerAttributes() {
addAttributes<ClosedIntervalAttr, ExactTypeAttr, FortranVariableFlagsAttr,
LowerBoundAttr, PointIntervalAttr, RealAttr, SubclassAttr,
UpperBoundAttr, CUDAAttributeAttr>();
UpperBoundAttr, CUDADataAttributeAttr, CUDAProcAttributeAttr>();
}
2 changes: 1 addition & 1 deletion flang/lib/Optimizer/HLFIR/IR/HLFIROps.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ void hlfir::DeclareOp::build(mlir::OpBuilder &builder,
llvm::StringRef uniq_name, mlir::Value shape,
mlir::ValueRange typeparams,
fir::FortranVariableFlagsAttr fortran_attrs,
fir::CUDAAttributeAttr cuda_attr) {
fir::CUDADataAttributeAttr cuda_attr) {
auto nameAttr = builder.getStringAttr(uniq_name);
mlir::Type inputType = memref.getType();
bool hasExplicitLbs = hasExplicitLowerBounds(shape);
Expand Down
4 changes: 2 additions & 2 deletions flang/lib/Optimizer/HLFIR/Transforms/ConvertToFIR.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -320,12 +320,12 @@ class DeclareOpConversion : public mlir::OpRewritePattern<hlfir::DeclareOp> {
mlir::Location loc = declareOp->getLoc();
mlir::Value memref = declareOp.getMemref();
fir::FortranVariableFlagsAttr fortranAttrs;
fir::CUDAAttributeAttr cudaAttr;
fir::CUDADataAttributeAttr cudaAttr;
if (auto attrs = declareOp.getFortranAttrs())
fortranAttrs =
fir::FortranVariableFlagsAttr::get(rewriter.getContext(), *attrs);
if (auto attr = declareOp.getCudaAttr())
cudaAttr = fir::CUDAAttributeAttr::get(rewriter.getContext(), *attr);
cudaAttr = fir::CUDADataAttributeAttr::get(rewriter.getContext(), *attr);
auto firDeclareOp = rewriter.create<fir::DeclareOp>(
loc, memref.getType(), memref, declareOp.getShape(),
declareOp.getTypeparams(), declareOp.getUniqName(), fortranAttrs,
Expand Down
7 changes: 3 additions & 4 deletions flang/lib/Semantics/resolve-names.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5648,10 +5648,9 @@ void DeclarationVisitor::Post(const parser::ProcDecl &x) {
const auto &name{std::get<parser::Name>(x.t)};
const Symbol *procInterface{nullptr};
if (interfaceName_) {
Symbol *ultimate{&interfaceName_->symbol->GetUltimate()};
procInterface = ultimate->has<GenericDetails>()
? ultimate->get<GenericDetails>().specific()
: ultimate;
procInterface = interfaceName_->symbol->has<GenericDetails>()
? interfaceName_->symbol->get<GenericDetails>().specific()
: interfaceName_->symbol;
}
auto attrs{HandleSaveName(name.source, GetAttrs())};
DerivedTypeDetails *dtDetails{nullptr};
Expand Down
2 changes: 1 addition & 1 deletion flang/test/Driver/driver-help-hidden.f90
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
! CHECK-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
! CHECK-NEXT: -R<remark> Enable the specified remark
! CHECK-NEXT: -save-temps=<value> Save intermediate compilation results.
! CHECK-NEXT: -save-temps Save intermediate compilation results
! CHECK-NEXT: -save-temps Alias for --save-temps=cwd
! CHECK-NEXT: -std=<value> Language standard to compile for
! CHECK-NEXT: -S Only run preprocess and compilation steps
! CHECK-NEXT: --target=<value> Generate code for the given target
Expand Down
4 changes: 2 additions & 2 deletions flang/test/Driver/driver-help.f90
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@
! HELP-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
! HELP-NEXT: -R<remark> Enable the specified remark
! HELP-NEXT: -save-temps=<value> Save intermediate compilation results.
! HELP-NEXT: -save-temps Save intermediate compilation results
! HELP-NEXT: -save-temps Alias for --save-temps=cwd
! HELP-NEXT: -std=<value> Language standard to compile for
! HELP-NEXT: -S Only run preprocess and compilation steps
! HELP-NEXT: --target=<value> Generate code for the given target
Expand Down Expand Up @@ -275,7 +275,7 @@
! HELP-FC1-NEXT: -Rpass=<value> Report transformations performed by optimization passes whose name matches the given POSIX regular expression
! HELP-FC1-NEXT: -R<remark> Enable the specified remark
! HELP-FC1-NEXT: -save-temps=<value> Save intermediate compilation results.
! HELP-FC1-NEXT: -save-temps Save intermediate compilation results
! HELP-FC1-NEXT: -save-temps Alias for --save-temps=cwd
! HELP-FC1-NEXT: -std=<value> Language standard to compile for
! HELP-FC1-NEXT: -S Only run preprocess and compilation steps
! HELP-FC1-NEXT: -target-cpu <value> Target a specific cpu type
Expand Down
34 changes: 34 additions & 0 deletions flang/test/Lower/CUDA/cuda-proc-attribute.cuf
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
! RUN: bbc -emit-hlfir -fcuda %s -o - | fir-opt -convert-hlfir-to-fir | FileCheck %s

! Test lowering of CUDA attribute on procedures.

attributes(host) subroutine sub_host(); end
! CHECK: func.func @_QPsub_host() attributes {fir.cuda_attr = #fir.cuda_proc<host>}

attributes(device) subroutine sub_device(); end
! CHECK: func.func @_QPsub_device() attributes {fir.cuda_attr = #fir.cuda_proc<device>}

attributes(host) attributes(device) subroutine sub_host_device; end
! CHECK: func.func @_QPsub_host_device() attributes {fir.cuda_attr = #fir.cuda_proc<host_device>}

attributes(device) attributes(host) subroutine sub_device_host; end
! CHECK: func.func @_QPsub_device_host() attributes {fir.cuda_attr = #fir.cuda_proc<host_device>}

attributes(global) subroutine sub_global(); end
! CHECK: func.func @_QPsub_global() attributes {fir.cuda_attr = #fir.cuda_proc<global>}

attributes(grid_global) subroutine sub_grid_global(); end
! CHECK: func.func @_QPsub_grid_global() attributes {fir.cuda_attr = #fir.cuda_proc<grid_global>}

attributes(host) integer function fct_host(); end
! CHECK: func.func @_QPfct_host() -> i32 attributes {fir.cuda_attr = #fir.cuda_proc<host>}

attributes(device) integer function fct_device(); end
! CHECK: func.func @_QPfct_device() -> i32 attributes {fir.cuda_attr = #fir.cuda_proc<device>}

attributes(host) attributes(device) integer function fct_host_device; end
! CHECK: func.func @_QPfct_host_device() -> i32 attributes {fir.cuda_attr = #fir.cuda_proc<host_device>}

attributes(device) attributes(host) integer function fct_device_host; end
! CHECK: func.func @_QPfct_device_host() -> i32 attributes {fir.cuda_attr = #fir.cuda_proc<host_device>}
8 changes: 4 additions & 4 deletions flang/unittests/Optimizer/FortranVariableTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ TEST_F(FortranVariableTest, SimpleScalar) {
auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
/*shape=*/mlir::Value{}, /*typeParams=*/std::nullopt, name,
/*fortran_attrs=*/fir::FortranVariableFlagsAttr{},
/*cuda_attr=*/fir::CUDAAttributeAttr{});
/*cuda_attr=*/fir::CUDADataAttributeAttr{});

fir::FortranVariableOpInterface fortranVariable = declare;
EXPECT_FALSE(fortranVariable.isArray());
Expand All @@ -76,7 +76,7 @@ TEST_F(FortranVariableTest, CharacterScalar) {
auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
/*shape=*/mlir::Value{}, typeParams, name,
/*fortran_attrs=*/fir::FortranVariableFlagsAttr{},
/*cuda_attr=*/fir::CUDAAttributeAttr{});
/*cuda_attr=*/fir::CUDADataAttributeAttr{});

fir::FortranVariableOpInterface fortranVariable = declare;
EXPECT_FALSE(fortranVariable.isArray());
Expand Down Expand Up @@ -107,7 +107,7 @@ TEST_F(FortranVariableTest, SimpleArray) {
auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
shape, /*typeParams*/ std::nullopt, name,
/*fortran_attrs=*/fir::FortranVariableFlagsAttr{},
/*cuda_attr=*/fir::CUDAAttributeAttr{});
/*cuda_attr=*/fir::CUDADataAttributeAttr{});

fir::FortranVariableOpInterface fortranVariable = declare;
EXPECT_TRUE(fortranVariable.isArray());
Expand Down Expand Up @@ -138,7 +138,7 @@ TEST_F(FortranVariableTest, CharacterArray) {
auto declare = builder->create<fir::DeclareOp>(loc, addr.getType(), addr,
shape, typeParams, name,
/*fortran_attrs=*/fir::FortranVariableFlagsAttr{},
/*cuda_attr=*/fir::CUDAAttributeAttr{});
/*cuda_attr=*/fir::CUDADataAttributeAttr{});

fir::FortranVariableOpInterface fortranVariable = declare;
EXPECT_TRUE(fortranVariable.isArray());
Expand Down
8 changes: 4 additions & 4 deletions libc/cmake/modules/LLVMLibCObjectRules.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,13 @@ function(get_nvptx_compile_options output_var gpu_arch)
list(APPEND nvptx_options "-Wno-unknown-cuda-version")
list(APPEND nvptx_options "SHELL:-mllvm -nvptx-emit-init-fini-kernel=false")
if(${gpu_arch} STREQUAL "sm_35")
list(APPEND nvptx_options "--cuda-feature=+ptx60")
list(APPEND nvptx_options "--cuda-feature=+ptx63")
elseif(${gpu_arch} STREQUAL "sm_37")
list(APPEND nvptx_options "--cuda-feature=+ptx60")
list(APPEND nvptx_options "--cuda-feature=+ptx63")
elseif(${gpu_arch} STREQUAL "sm_50")
list(APPEND nvptx_options "--cuda-feature=+ptx60")
list(APPEND nvptx_options "--cuda-feature=+ptx63")
elseif(${gpu_arch} STREQUAL "sm_52")
list(APPEND nvptx_options "--cuda-feature=+ptx60")
list(APPEND nvptx_options "--cuda-feature=+ptx63")
elseif(${gpu_arch} STREQUAL "sm_53")
list(APPEND nvptx_options "--cuda-feature=+ptx63")
elseif(${gpu_arch} STREQUAL "sm_60")
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/aarch64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -386,6 +386,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
libc.src.math.frexpf128
libc.src.math.roundf128
libc.src.math.sqrtf128
libc.src.math.truncf128
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/riscv/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -395,6 +395,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
libc.src.math.frexpf128
libc.src.math.roundf128
libc.src.math.sqrtf128
libc.src.math.truncf128
Expand Down
1 change: 1 addition & 0 deletions libc/config/linux/x86_64/entrypoints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ if(LIBC_COMPILER_HAS_FLOAT128)
libc.src.math.floorf128
libc.src.math.fmaxf128
libc.src.math.fminf128
libc.src.math.frexpf128
libc.src.math.roundf128
libc.src.math.sqrtf128
libc.src.math.truncf128
Expand Down
2 changes: 2 additions & 0 deletions libc/docs/math/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,8 @@ Basic Operations
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| frexpl | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| frexpf128 | |check| | |check| | | |check| | | | | | | | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| ilogb | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
+--------------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+---------+
| ilogbf | |check| | |check| | |check| | |check| | |check| | | | |check| | |check| | |check| | | |
Expand Down
1 change: 1 addition & 0 deletions libc/spec/stdc.td
Original file line number Diff line number Diff line change
Expand Up @@ -401,6 +401,7 @@ def StdC : StandardSpec<"stdc"> {
FunctionSpec<"frexp", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<IntPtr>]>,
FunctionSpec<"frexpf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<IntPtr>]>,
FunctionSpec<"frexpl", RetValSpec<LongDoubleType>, [ArgSpec<LongDoubleType>, ArgSpec<IntPtr>]>,
GuardedFunctionSpec<"frexpf128", RetValSpec<Float128Type>, [ArgSpec<Float128Type>, ArgSpec<IntPtr>]], "LIBC_COMPILER_HAS_FLOAT128">,

FunctionSpec<"hypot", RetValSpec<DoubleType>, [ArgSpec<DoubleType>, ArgSpec<DoubleType>]>,
FunctionSpec<"hypotf", RetValSpec<FloatType>, [ArgSpec<FloatType>, ArgSpec<FloatType>]>,
Expand Down
1 change: 1 addition & 0 deletions libc/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ add_math_entrypoint_object(fmodf)
add_math_entrypoint_object(frexp)
add_math_entrypoint_object(frexpf)
add_math_entrypoint_object(frexpl)
add_math_entrypoint_object(frexpf128)

add_math_entrypoint_object(hypot)
add_math_entrypoint_object(hypotf)
Expand Down
20 changes: 20 additions & 0 deletions libc/src/math/frexpf128.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
//===-- Implementation header for frexpf128 ---------------------*- C++ -*-===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_SRC_MATH_FREXPF128_H
#define LLVM_LIBC_SRC_MATH_FREXPF128_H

#include "src/__support/macros/properties/float.h"

namespace LIBC_NAMESPACE {

float128 frexpf128(float128 x, int *exp);

} // namespace LIBC_NAMESPACE

#endif // LLVM_LIBC_SRC_MATH_FREXPF128_H
23 changes: 18 additions & 5 deletions libc/src/math/generic/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -916,10 +916,10 @@ add_entrypoint_object(
frexp.cpp
HDRS
../frexp.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.manipulation_functions
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -928,10 +928,10 @@ add_entrypoint_object(
frexpf.cpp
HDRS
../frexpf.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.manipulation_functions
COMPILE_OPTIONS
-O2
)

add_entrypoint_object(
Expand All @@ -940,10 +940,23 @@ add_entrypoint_object(
frexpl.cpp
HDRS
../frexpl.h
COMPILE_OPTIONS
-O3
DEPENDS
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
frexpf128
SRCS
frexpf128.cpp
HDRS
../frexpf128.h
COMPILE_OPTIONS
-O2
-O3
DEPENDS
libc.src.__support.macros.properties.float
libc.src.__support.FPUtil.manipulation_functions
)

add_entrypoint_object(
Expand Down
19 changes: 19 additions & 0 deletions libc/src/math/generic/frexpf128.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
//===-- Implementation of frexpf128 function ------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "src/math/frexpf128.h"
#include "src/__support/FPUtil/ManipulationFunctions.h"
#include "src/__support/common.h"

namespace LIBC_NAMESPACE {

LLVM_LIBC_FUNCTION(float128, frexpf128, (float128 x, int *exp)) {
return fputil::frexp(x, *exp);
}

} // namespace LIBC_NAMESPACE
18 changes: 12 additions & 6 deletions libc/test/src/math/smoke/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -779,9 +779,7 @@ add_fp_unittest(
HDRS
FrexpTest.h
DEPENDS
libc.include.math
libc.src.math.frexp
libc.src.__support.FPUtil.basic_operations
)

add_fp_unittest(
Expand All @@ -793,9 +791,7 @@ add_fp_unittest(
HDRS
FrexpTest.h
DEPENDS
libc.include.math
libc.src.math.frexpf
libc.src.__support.FPUtil.basic_operations
)

add_fp_unittest(
Expand All @@ -807,9 +803,19 @@ add_fp_unittest(
HDRS
FrexpTest.h
DEPENDS
libc.include.math
libc.src.math.frexpl
libc.src.__support.FPUtil.basic_operations
)

add_fp_unittest(
frexpf128_test
SUITE
libc-math-smoke-tests
SRCS
frexpf128_test.cpp
HDRS
FrexpTest.h
DEPENDS
libc.src.math.frexpf128
)

# FIXME: These tests are currently broken for NVPTX.
Expand Down
58 changes: 27 additions & 31 deletions libc/test/src/math/smoke/FrexpTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,81 +10,76 @@
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"

#include <math.h>

template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {

DECLARE_SPECIAL_CONSTANTS(T)

static constexpr StorageType HIDDEN_BIT =
StorageType(1) << LIBC_NAMESPACE::fputil::FPBits<T>::FRACTION_LEN;

public:
typedef T (*FrexpFunc)(T, int *);

void testSpecialNumbers(FrexpFunc func) {
int exponent;
ASSERT_FP_EQ(aNaN, func(aNaN, &exponent));
ASSERT_FP_EQ(inf, func(inf, &exponent));
ASSERT_FP_EQ(neg_inf, func(neg_inf, &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(aNaN, func(aNaN, &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(inf, func(inf, &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(neg_inf, func(neg_inf, &exponent));

ASSERT_FP_EQ(0.0, func(0.0, &exponent));
ASSERT_EQ(exponent, 0);
EXPECT_FP_EQ_ALL_ROUNDING(0.0, func(0.0, &exponent));
EXPECT_EQ(exponent, 0);

ASSERT_FP_EQ(-0.0, func(-0.0, &exponent));
ASSERT_EQ(exponent, 0);
EXPECT_FP_EQ_ALL_ROUNDING(-0.0, func(-0.0, &exponent));
EXPECT_EQ(exponent, 0);
}

void testPowersOfTwo(FrexpFunc func) {
int exponent;

EXPECT_FP_EQ(T(0.5), func(T(1.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(1.0), &exponent));
EXPECT_EQ(exponent, 1);
EXPECT_FP_EQ(T(-0.5), func(T(-1.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-1.0), &exponent));
EXPECT_EQ(exponent, 1);

EXPECT_FP_EQ(T(0.5), func(T(2.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(2.0), &exponent));
EXPECT_EQ(exponent, 2);
EXPECT_FP_EQ(T(-0.5), func(T(-2.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-2.0), &exponent));
EXPECT_EQ(exponent, 2);

EXPECT_FP_EQ(T(0.5), func(T(4.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(4.0), &exponent));
EXPECT_EQ(exponent, 3);
EXPECT_FP_EQ(T(-0.5), func(T(-4.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-4.0), &exponent));
EXPECT_EQ(exponent, 3);

EXPECT_FP_EQ(T(0.5), func(T(8.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(8.0), &exponent));
EXPECT_EQ(exponent, 4);
EXPECT_FP_EQ(T(-0.5), func(T(-8.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-8.0), &exponent));
EXPECT_EQ(exponent, 4);

EXPECT_FP_EQ(T(0.5), func(T(16.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(16.0), &exponent));
EXPECT_EQ(exponent, 5);
EXPECT_FP_EQ(T(-0.5), func(T(-16.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-16.0), &exponent));
EXPECT_EQ(exponent, 5);

EXPECT_FP_EQ(T(0.5), func(T(32.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.5), func(T(32.0), &exponent));
EXPECT_EQ(exponent, 6);
EXPECT_FP_EQ(T(-0.5), func(T(-32.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.5), func(T(-32.0), &exponent));
EXPECT_EQ(exponent, 6);
}

void testSomeIntegers(FrexpFunc func) {
int exponent;

EXPECT_FP_EQ(T(0.75), func(T(24.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.75), func(T(24.0), &exponent));
EXPECT_EQ(exponent, 5);
EXPECT_FP_EQ(T(-0.75), func(T(-24.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.75), func(T(-24.0), &exponent));
EXPECT_EQ(exponent, 5);

EXPECT_FP_EQ(T(0.625), func(T(40.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.625), func(T(40.0), &exponent));
EXPECT_EQ(exponent, 6);
EXPECT_FP_EQ(T(-0.625), func(T(-40.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.625), func(T(-40.0), &exponent));
EXPECT_EQ(exponent, 6);

EXPECT_FP_EQ(T(0.78125), func(T(800.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(0.78125), func(T(800.0), &exponent));
EXPECT_EQ(exponent, 10);
EXPECT_FP_EQ(T(-0.78125), func(T(-800.0), &exponent));
EXPECT_FP_EQ_ALL_ROUNDING(T(-0.78125), func(T(-800.0), &exponent));
EXPECT_EQ(exponent, 10);
}
};
Expand All @@ -93,4 +88,5 @@ template <typename T> class FrexpTest : public LIBC_NAMESPACE::testing::Test {
using LlvmLibcFrexpTest = FrexpTest<T>; \
TEST_F(LlvmLibcFrexpTest, SpecialNumbers) { testSpecialNumbers(&func); } \
TEST_F(LlvmLibcFrexpTest, PowersOfTwo) { testPowersOfTwo(&func); } \
TEST_F(LlvmLibcFrexpTest, SomeIntegers) { testSomeIntegers(&func); }
TEST_F(LlvmLibcFrexpTest, SomeIntegers) { testSomeIntegers(&func); } \
static_assert(true, "Require semicolon.")
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/frexp_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

#include "src/math/frexp.h"

LIST_FREXP_TESTS(double, LIBC_NAMESPACE::frexp)
LIST_FREXP_TESTS(double, LIBC_NAMESPACE::frexp);
13 changes: 13 additions & 0 deletions libc/test/src/math/smoke/frexpf128_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
//===-- Unittests for frexpf128 -------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//

#include "FrexpTest.h"

#include "src/math/frexpf128.h"

LIST_FREXP_TESTS(float128, LIBC_NAMESPACE::frexpf128);
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/frexpf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

#include "src/math/frexpf.h"

LIST_FREXP_TESTS(float, LIBC_NAMESPACE::frexpf)
LIST_FREXP_TESTS(float, LIBC_NAMESPACE::frexpf);
2 changes: 1 addition & 1 deletion libc/test/src/math/smoke/frexpl_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@

#include "src/math/frexpl.h"

LIST_FREXP_TESTS(long double, LIBC_NAMESPACE::frexpl)
LIST_FREXP_TESTS(long double, LIBC_NAMESPACE::frexpl);
10 changes: 5 additions & 5 deletions lld/ELF/Writer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2446,8 +2446,8 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
// Segments are contiguous memory regions that has the same attributes
// (e.g. executable or writable). There is one phdr for each segment.
// Therefore, we need to create a new phdr when the next section has
// compatible flags or is loaded at a discontiguous address or memory region
// using AT or AT> linker script command, respectively.
// incompatible flags or is loaded at a discontiguous address or memory
// region using AT or AT> linker script command, respectively.
//
// As an exception, we don't create a separate load segment for the ELF
// headers, even if the first "real" output has an AT or AT> attribute.
Expand All @@ -2461,10 +2461,10 @@ SmallVector<PhdrEntry *, 0> Writer<ELFT>::createPhdrs(Partition &part) {
// needed to create a new LOAD)
uint64_t newFlags = computeFlags(sec->getPhdrFlags());
// When --no-rosegment is specified, RO and RX sections are compatible.
uint32_t diff = flags ^ newFlags;
uint32_t incompatible = flags ^ newFlags;
if (config->singleRoRx && !(newFlags & PF_W))
diff &= ~PF_X;
if (diff)
incompatible &= ~PF_X;
if (incompatible)
load = nullptr;

bool sameLMARegion =
Expand Down
25 changes: 13 additions & 12 deletions lld/test/ELF/riscv-section-layout.s
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,20 @@

# RUN: llvm-mc -filetype=obj -triple=riscv32 %s -o %t.32.o
# RUN: ld.lld -pie %t.32.o -o %t.32
# RUN: llvm-readelf -S -s %t.32 | FileCheck %s --check-prefix=NOSDATA
# RUN: llvm-readelf -S -sX %t.32 | FileCheck %s --check-prefix=NOSDATA
# RUN: llvm-mc -filetype=obj -triple=riscv32 --defsym=SDATA=1 %s -o %t.32s.o
# RUN: ld.lld -pie %t.32s.o -o %t.32s
# RUN: llvm-readelf -S -s %t.32s | FileCheck %s
# RUN: llvm-readelf -S -sX %t.32s | FileCheck %s

# RUN: llvm-mc -filetype=obj -triple=riscv64 %s -o %t.64.o
# RUN: ld.lld -pie %t.64.o -o %t.64
# RUN: llvm-readelf -S -s %t.64 | FileCheck %s --check-prefix=NOSDATA
# RUN: llvm-readelf -S -sX %t.64 | FileCheck %s --check-prefix=NOSDATA
# RUN: llvm-mc -filetype=obj -triple=riscv64 --defsym=SDATA=1 %s -o %t.64s.o
# RUN: ld.lld -pie %t.64s.o -o %t.64s
# RUN: llvm-readelf -S -s %t.64s | FileCheck %s
# RUN: llvm-readelf -S -sX %t.64s | FileCheck %s

# NOSDATA: .text
# NOSDATA-NEXT: .tdata
# NOSDATA-NEXT: .tdata PROGBITS [[#%x,TDATA:]]
# NOSDATA-NEXT: .tbss
# NOSDATA-NEXT: .dynamic
# NOSDATA-NEXT: .got
Expand All @@ -28,9 +28,10 @@
## exist, define __global_pointer$ and set its st_shndx arbitrarily to 1.
## The symbol value should not be used by the program.

# NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] _edata
# NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] __bss_start
# NOSDATA-DAG: [[#]]: {{0*}}800 0 NOTYPE GLOBAL DEFAULT 1 __global_pointer$
# NOSDATA-DAG: [[#]]: {{.*}} 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _etext
# NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.data) _edata
# NOSDATA-DAG: [[#]]: {{0*}}[[#BSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.bss) __bss_start
# NOSDATA-DAG: [[#]]: {{0*}}800 0 NOTYPE GLOBAL DEFAULT 1 (.dynsym) __global_pointer$

# CHECK: .text
# CHECK-NEXT: .tdata
Expand All @@ -43,11 +44,11 @@
# CHECK-NEXT: .sbss NOBITS [[#%x,SBSS:]]
# CHECK-NEXT: .bss

# CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] _edata
# CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] __bss_start
# CHECK-DAG: [[#]]: {{0*}}[[#SDATA+0x800]] 0 NOTYPE GLOBAL DEFAULT [[#]] __global_pointer$
# CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sdata) _edata
# CHECK-DAG: [[#]]: {{0*}}[[#SBSS]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sbss) __bss_start
# CHECK-DAG: [[#]]: {{0*}}[[#SDATA+0x800]] 0 NOTYPE GLOBAL DEFAULT [[#]] (.sdata) __global_pointer$

.globl _edata, __bss_start
.globl _etext, _edata, __bss_start
lla gp, __global_pointer$

.section .data,"aw",@progbits; .long _GLOBAL_OFFSET_TABLE_ - .
Expand Down
54 changes: 32 additions & 22 deletions lld/test/ELF/x86-64-section-layout.s
Original file line number Diff line number Diff line change
Expand Up @@ -6,31 +6,31 @@

# RUN: llvm-mc -filetype=obj -triple=x86_64 --defsym=BSS=1 a.s -o a.o
# RUN: ld.lld --section-start=.note=0x200300 a.o -o a
# RUN: llvm-readelf -S -l a | FileCheck %s
# RUN: llvm-readelf -S -l -sX a | FileCheck %s

# RUN: llvm-mc -filetype=obj -triple=x86_64 a.s -o a1.o
# RUN: ld.lld --section-start=.note=0x200300 a1.o -o a1
# RUN: llvm-readelf -S a1 | FileCheck %s --check-prefix=CHECK1
# RUN: llvm-readelf -S -sX a1 | FileCheck %s --check-prefix=CHECK1

# RUN: ld.lld -T b.lds -z norelro a.o -o b
# RUN: llvm-readelf -S -l b | FileCheck %s --check-prefix=CHECK2

# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
# CHECK-NEXT: NULL 0000000000000000 000000 000000 00 0 0 0
# CHECK-NEXT: .note NOTE 0000000000200300 000300 000001 00 A 0 0 1
# CHECK-NEXT: .lrodata PROGBITS 0000000000200301 000301 000002 00 Al 0 0 1
# CHECK-NEXT: .rodata PROGBITS 0000000000200303 000303 000001 00 A 0 0 1
# CHECK-NEXT: .text PROGBITS 0000000000201304 000304 000001 00 AX 0 0 4
# CHECK-NEXT: .tdata PROGBITS 0000000000202305 000305 000001 00 WAT 0 0 1
# CHECK-NEXT: .tbss NOBITS 0000000000202306 000306 000002 00 WAT 0 0 1
# CHECK-NEXT: .relro_padding NOBITS 0000000000202306 000306 000cfa 00 WA 0 0 1
# CHECK-NEXT: .data PROGBITS 0000000000203306 000306 000001 00 WA 0 0 1
# CHECK-NEXT: .bss NOBITS 0000000000203307 000307 001800 00 WA 0 0 1
# CHECK: Name Type Address Off Size ES Flg Lk Inf Al
# CHECK-NEXT: NULL 0000000000000000 000000 000000 00 0 0 0
# CHECK-NEXT: .note NOTE 0000000000200300 000300 000001 00 A 0 0 1
# CHECK-NEXT: .lrodata PROGBITS 0000000000200301 000301 000002 00 Al 0 0 1
# CHECK-NEXT: .rodata PROGBITS 0000000000200303 000303 000001 00 A 0 0 1
# CHECK-NEXT: .text PROGBITS 0000000000201304 000304 000001 00 AX 0 0 4
# CHECK-NEXT: .tdata PROGBITS 0000000000202305 000305 000001 00 WAT 0 0 1
# CHECK-NEXT: .tbss NOBITS 0000000000202306 000306 000002 00 WAT 0 0 1
# CHECK-NEXT: .relro_padding NOBITS 0000000000202306 000306 000cfa 00 WA 0 0 1
# CHECK-NEXT: .data PROGBITS 0000000000203306 000306 000001 00 WA 0 0 1
# CHECK-NEXT: .bss NOBITS 0000000000203307 000307 001800 00 WA 0 0 1
## We spend size(.bss) % MAXPAGESIZE bytes for .bss.
# CHECK-NEXT: .ldata PROGBITS 0000000000205b07 000b07 000002 00 WAl 0 0 1
# CHECK-NEXT: .ldata2 PROGBITS 0000000000205b09 000b09 000001 00 WAl 0 0 1
# CHECK-NEXT: .lbss NOBITS 0000000000205b0a 000b0a 000002 00 WAl 0 0 1
# CHECK-NEXT: .comment PROGBITS 0000000000000000 000b0a {{.*}} 01 MS 0 0 1
# CHECK-NEXT: .ldata PROGBITS 0000000000205b07 000b07 000002 00 WAl 0 0 1
# CHECK-NEXT: .ldata2 PROGBITS 0000000000205b09 000b09 000001 00 WAl 0 0 1
# CHECK-NEXT: .lbss NOBITS 0000000000205b0a 000b0a 001201 00 WAl 0 0 1
# CHECK-NEXT: .comment PROGBITS 0000000000000000 000b0a {{.*}} 01 MS 0 0 1

# CHECK: Program Headers:
# CHECK-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
Expand All @@ -39,13 +39,23 @@
# CHECK-NEXT: LOAD 0x000304 0x0000000000201304 0x0000000000201304 0x000001 0x000001 R E 0x1000
# CHECK-NEXT: LOAD 0x000305 0x0000000000202305 0x0000000000202305 0x000001 0x000cfb RW 0x1000
# CHECK-NEXT: LOAD 0x000306 0x0000000000203306 0x0000000000203306 0x000001 0x001801 RW 0x1000
# CHECK-NEXT: LOAD 0x000b07 0x0000000000205b07 0x0000000000205b07 0x000003 0x000005 RW 0x1000
# CHECK-NEXT: LOAD 0x000b07 0x0000000000205b07 0x0000000000205b07 0x000003 0x001204 RW 0x1000

# CHECK: 0000000000201304 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _start
# CHECK-NEXT: 0000000000201305 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _etext
# CHECK-NEXT: 0000000000205b0a 0 NOTYPE GLOBAL DEFAULT [[#]] (.ldata2) _edata
# CHECK-NEXT: 0000000000206d0b 0 NOTYPE GLOBAL DEFAULT [[#]] (.lbss) _end

# CHECK1: .data PROGBITS 0000000000203306 000306 000001 00 WA 0 0 1
# CHECK1-NEXT: .ldata PROGBITS 0000000000203307 000307 000002 00 WAl 0 0 1
# CHECK1-NEXT: .ldata2 PROGBITS 0000000000203309 000309 000001 00 WAl 0 0 1
# CHECK1-NEXT: .comment PROGBITS 0000000000000000 00030a {{.*}} 01 MS 0 0 1

# CHECK1: 0000000000201304 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _start
# CHECK1-NEXT: 0000000000201305 0 NOTYPE GLOBAL DEFAULT [[#]] (.text) _etext
# CHECK1-NEXT: 000000000020330a 0 NOTYPE GLOBAL DEFAULT [[#]] (.ldata2) _edata
# CHECK1-NEXT: 000000000020330a 0 NOTYPE GLOBAL DEFAULT [[#]] (.ldata2) _end

# CHECK2: .note NOTE 0000000000200300 000300 000001 00 A 0 0 1
# CHECK2-NEXT: .lrodata PROGBITS 0000000000200301 000301 000001 00 Al 0 0 1
## With a SECTIONS command, we suppress the default rule placing .lrodata.* into .lrodata.
Expand All @@ -59,19 +69,19 @@
# CHECK2-NEXT: .bss NOBITS 0000000000200307 000307 001800 00 WA 0 0 1
# CHECK2-NEXT: .ldata PROGBITS 0000000000201b07 001b07 000002 00 WAl 0 0 1
# CHECK2-NEXT: .ldata2 PROGBITS 0000000000201b09 001b09 000001 00 WAl 0 0 1
# CHECK2-NEXT: .lbss NOBITS 0000000000201b0a 001b0a 000002 00 WAl 0 0 1
# CHECK2-NEXT: .lbss NOBITS 0000000000201b0a 001b0a 001201 00 WAl 0 0 1
# CHECK2-NEXT: .comment PROGBITS 0000000000000000 001b0a {{.*}} 01 MS 0 0 1

# CHECK2: Program Headers:
# CHECK2-NEXT: Type Offset VirtAddr PhysAddr FileSiz MemSiz Flg Align
# CHECK2-NEXT: PHDR 0x000040 0x0000000000200040 0x0000000000200040 {{.*}} {{.*}} R 0x8
# CHECK2-NEXT: LOAD 0x000000 0x0000000000200000 0x0000000000200000 0x000304 0x000304 R 0x1000
# CHECK2-NEXT: LOAD 0x000304 0x0000000000200304 0x0000000000200304 0x000001 0x000001 R E 0x1000
# CHECK2-NEXT: LOAD 0x000305 0x0000000000200305 0x0000000000200305 0x001805 0x001807 RW 0x1000
# CHECK2-NEXT: LOAD 0x000305 0x0000000000200305 0x0000000000200305 0x001805 0x002a06 RW 0x1000
# CHECK2-NEXT: TLS 0x000305 0x0000000000200305 0x0000000000200305 0x000001 0x000003 R 0x1

#--- a.s
.globl _start
.globl _start, _etext, _edata, _end
_start:
ret

Expand All @@ -92,7 +102,7 @@ _start:
## Input .ldata.rel.ro sections are placed in the output .ldata section.
.section .ldata.rel.ro,"awl"; .space 1
.ifdef BSS
.section .lbss,"awl",@nobits; .space 1
.section .lbss,"awl",@nobits; .space 0x1200
## Input .lbss.rel.ro sections are placed in the output .lbss section.
.section .lbss.rel.ro,"awl",@nobits; .space 1
.endif
Expand Down
5 changes: 4 additions & 1 deletion llvm/include/llvm/BinaryFormat/COFF.h
Original file line number Diff line number Diff line change
Expand Up @@ -716,7 +716,10 @@ enum ImportNameType : unsigned {
IMPORT_NAME_NOPREFIX = 2,
/// The import name is the public symbol name, but skipping the leading ?,
/// @, or optionally _, and truncating at the first @.
IMPORT_NAME_UNDECORATE = 3
IMPORT_NAME_UNDECORATE = 3,
/// The import name is specified as a separate string in the import library
/// object file.
IMPORT_NAME_EXPORTAS = 4
};

enum class GuardFlags : uint32_t {
Expand Down
3 changes: 2 additions & 1 deletion llvm/include/llvm/IR/IntrinsicsNVVM.td
Original file line number Diff line number Diff line change
Expand Up @@ -1625,7 +1625,8 @@ def int_nvvm_compiler_warn :
Intrinsic<[], [llvm_anyptr_ty], [], "llvm.nvvm.compiler.warn">;

def int_nvvm_reflect :
Intrinsic<[llvm_i32_ty], [llvm_anyptr_ty], [IntrNoMem], "llvm.nvvm.reflect">;
Intrinsic<[llvm_i32_ty], [llvm_ptr_ty], [IntrNoMem], "llvm.nvvm.reflect">,
ClangBuiltin<"__nvvm_reflect">;

// isspacep.{const, global, local, shared}
def int_nvvm_isspacep_const
Expand Down
4 changes: 4 additions & 0 deletions llvm/include/llvm/Object/COFFImportFile.h
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,10 @@ struct COFFShortExport {
/// file, this is "baz" in "EXPORTS\nfoo = bar == baz".
std::string AliasTarget;

/// Specifies EXPORTAS name. In a .def file, this is "bar" in
/// "EXPORTS\nfoo EXPORTAS bar".
std::string ExportAs;

uint16_t Ordinal = 0;
bool Noname = false;
bool Data = false;
Expand Down
1 change: 1 addition & 0 deletions llvm/include/llvm/Object/Wasm.h
Original file line number Diff line number Diff line change
Expand Up @@ -179,6 +179,7 @@ class WasmObjectFile : public ObjectFile {
Expected<SymbolRef::Type> getSymbolType(DataRefImpl Symb) const override;
Expected<section_iterator> getSymbolSection(DataRefImpl Symb) const override;
uint32_t getSymbolSectionId(SymbolRef Sym) const;
uint32_t getSymbolSize(SymbolRef Sym) const;

// Overrides from SectionRef.
void moveSectionNext(DataRefImpl &Sec) const override;
Expand Down
6 changes: 6 additions & 0 deletions llvm/include/llvm/TargetParser/AArch64TargetParser.h
Original file line number Diff line number Diff line change
Expand Up @@ -805,6 +805,12 @@ inline constexpr CpuInfo CpuInfos[] = {
{AArch64::AEK_FP16, AArch64::AEK_RAND, AArch64::AEK_SM4,
AArch64::AEK_SHA3, AArch64::AEK_SHA2, AArch64::AEK_AES,
AArch64::AEK_MTE, AArch64::AEK_SB, AArch64::AEK_SSBS}))},
{"ampere1b", ARMV8_7A,
(AArch64::ExtensionBitset({AArch64::AEK_FP16, AArch64::AEK_RAND,
AArch64::AEK_SM4, AArch64::AEK_SHA3,
AArch64::AEK_SHA2, AArch64::AEK_AES,
AArch64::AEK_MTE, AArch64::AEK_SB,
AArch64::AEK_SSBS, AArch64::AEK_CSSC}))},
};

// An alias for a CPU.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/ObjCopy/ELF/ELFObject.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2980,7 +2980,7 @@ SRECWriter::getTotalSize(WritableMemoryBuffer &EmptyBuffer) const {
SRECSizeCalculator SizeCalc(EmptyBuffer, 0);
for (const SectionBase *Sec : Sections)
if (Error Err = Sec->accept(SizeCalc))
return Err;
return std::move(Err);

SizeCalc.writeRecords(Obj.Entry);
// We need to add the size of the Header and Terminator records.
Expand Down
66 changes: 45 additions & 21 deletions llvm/lib/Object/COFFImportFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,12 @@ StringRef COFFImportFile::getExportName() const {
name = ltrim1(name, "?@_");
name = name.substr(0, name.find('@'));
break;
case IMPORT_NAME_EXPORTAS: {
// Skip DLL name
name = Data.getBuffer().substr(sizeof(*hdr) + name.size() + 1);
name = name.split('\0').second.split('\0').first;
break;
}
default:
break;
}
Expand Down Expand Up @@ -209,6 +215,7 @@ class ObjectFactory {
// Library Format.
NewArchiveMember createShortImport(StringRef Sym, uint16_t Ordinal,
ImportType Type, ImportNameType NameType,
StringRef ExportName,
MachineTypes Machine);

// Create a weak external file which is described in PE/COFF Aux Format 3.
Expand Down Expand Up @@ -500,12 +507,13 @@ NewArchiveMember ObjectFactory::createNullThunk(std::vector<uint8_t> &Buffer) {
return {MemoryBufferRef{F, ImportName}};
}

NewArchiveMember ObjectFactory::createShortImport(StringRef Sym,
uint16_t Ordinal,
ImportType ImportType,
ImportNameType NameType,
MachineTypes Machine) {
NewArchiveMember
ObjectFactory::createShortImport(StringRef Sym, uint16_t Ordinal,
ImportType ImportType, ImportNameType NameType,
StringRef ExportName, MachineTypes Machine) {
size_t ImpSize = ImportName.size() + Sym.size() + 2; // +2 for NULs
if (!ExportName.empty())
ImpSize += ExportName.size() + 1;
size_t Size = sizeof(coff_import_header) + ImpSize;
char *Buf = Alloc.Allocate<char>(Size);
memset(Buf, 0, Size);
Expand All @@ -525,6 +533,10 @@ NewArchiveMember ObjectFactory::createShortImport(StringRef Sym,
memcpy(P, Sym.data(), Sym.size());
P += Sym.size() + 1;
memcpy(P, ImportName.data(), ImportName.size());
if (!ExportName.empty()) {
P += ImportName.size() + 1;
memcpy(P, ExportName.data(), ExportName.size());
}

return {MemoryBufferRef(StringRef(Buf, Size), ImportName)};
}
Expand Down Expand Up @@ -641,27 +653,39 @@ Error writeImportLibrary(StringRef ImportName, StringRef Path,
ImportType = IMPORT_CONST;

StringRef SymbolName = E.SymbolName.empty() ? E.Name : E.SymbolName;
ImportNameType NameType = E.Noname
? IMPORT_ORDINAL
: getNameType(SymbolName, E.Name,
Machine, MinGW);
Expected<std::string> Name = E.ExtName.empty()
? std::string(SymbolName)
: replace(SymbolName, E.Name, E.ExtName);

if (!Name)
return Name.takeError();

if (!E.AliasTarget.empty() && *Name != E.AliasTarget) {
std::string Name;

if (E.ExtName.empty()) {
Name = std::string(SymbolName);
} else {
Expected<std::string> ReplacedName =
replace(SymbolName, E.Name, E.ExtName);
if (!ReplacedName)
return ReplacedName.takeError();
Name.swap(*ReplacedName);
}

if (!E.AliasTarget.empty() && Name != E.AliasTarget) {
Members.push_back(
OF.createWeakExternal(E.AliasTarget, *Name, false, Machine));
OF.createWeakExternal(E.AliasTarget, Name, false, Machine));
Members.push_back(
OF.createWeakExternal(E.AliasTarget, *Name, true, Machine));
OF.createWeakExternal(E.AliasTarget, Name, true, Machine));
continue;
}

Members.push_back(
OF.createShortImport(*Name, E.Ordinal, ImportType, NameType, Machine));
ImportNameType NameType;
std::string ExportName;
if (E.Noname) {
NameType = IMPORT_ORDINAL;
} else if (!E.ExportAs.empty()) {
NameType = IMPORT_NAME_EXPORTAS;
ExportName = E.ExportAs;
} else {
NameType = getNameType(SymbolName, E.Name, Machine, MinGW);
}

Members.push_back(OF.createShortImport(Name, E.Ordinal, ImportType,
NameType, ExportName, Machine));
}

return writeArchive(Path, Members, SymtabWritingMode::NormalSymtab,
Expand Down
13 changes: 12 additions & 1 deletion llvm/lib/Object/COFFModuleDefinition.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ enum Kind {
KwConstant,
KwData,
KwExports,
KwExportAs,
KwHeapsize,
KwLibrary,
KwName,
Expand Down Expand Up @@ -116,6 +117,7 @@ class Lexer {
.Case("CONSTANT", KwConstant)
.Case("DATA", KwData)
.Case("EXPORTS", KwExports)
.Case("EXPORTAS", KwExportAs)
.Case("HEAPSIZE", KwHeapsize)
.Case("LIBRARY", KwLibrary)
.Case("NAME", KwName)
Expand Down Expand Up @@ -284,7 +286,16 @@ class Parser {
E.AliasTarget = std::string("_").append(E.AliasTarget);
continue;
}
unget();
// EXPORTAS must be at the end of export definition
if (Tok.K == KwExportAs) {
read();
if (Tok.K == Eof)
return createError(
"unexpected end of file, EXPORTAS identifier expected");
E.ExportAs = std::string(Tok.Value);
} else {
unget();
}
Info.Exports.push_back(E);
return Error::success();
}
Expand Down
14 changes: 14 additions & 0 deletions llvm/lib/Object/WasmObjectFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1932,6 +1932,20 @@ uint32_t WasmObjectFile::getSymbolSectionIdImpl(const WasmSymbol &Sym) const {
}
}

uint32_t WasmObjectFile::getSymbolSize(SymbolRef Symb) const {
const WasmSymbol &Sym = getWasmSymbol(Symb);
if (!Sym.isDefined())
return 0;
if (Sym.isTypeData())
return Sym.Info.DataRef.Size;
if (Sym.isTypeFunction())
return functions()[Sym.Info.ElementIndex - getNumImportedFunctions()].Size;
// Currently symbol size is only tracked for data segments and functions. In
// principle we could also track size (e.g. binary size) for tables, globals
// and element segments etc too.
return 0;
}

void WasmObjectFile::moveSectionNext(DataRefImpl &Sec) const { Sec.d.a++; }

Expected<StringRef> WasmObjectFile::getSectionName(DataRefImpl Sec) const {
Expand Down
31 changes: 30 additions & 1 deletion llvm/lib/Target/AArch64/AArch64.td
Original file line number Diff line number Diff line change
Expand Up @@ -1120,7 +1120,6 @@ def TuneAppleA14 : SubtargetFeature<"apple-a14", "ARMProcFamily", "AppleA14",
FeatureFuseArithmeticLogic,
FeatureFuseCCSelect,
FeatureFuseCryptoEOR,
FeatureFuseAdrpAdd,
FeatureFuseLiterals,
FeatureStorePairSuppress,
FeatureZCRegMove,
Expand Down Expand Up @@ -1149,6 +1148,7 @@ def TuneAppleA16 : SubtargetFeature<"apple-a16", "ARMProcFamily", "AppleA16",
FeatureArithmeticCbzFusion,
FeatureDisableLatencySchedHeuristic,
FeatureFuseAddress,
FeatureFuseAdrpAdd,
FeatureFuseAES,
FeatureFuseArithmeticLogic,
FeatureFuseCCSelect,
Expand All @@ -1165,6 +1165,7 @@ def TuneAppleA17 : SubtargetFeature<"apple-a17", "ARMProcFamily", "AppleA17",
FeatureArithmeticCbzFusion,
FeatureDisableLatencySchedHeuristic,
FeatureFuseAddress,
FeatureFuseAdrpAdd,
FeatureFuseAES,
FeatureFuseArithmeticLogic,
FeatureFuseCCSelect,
Expand Down Expand Up @@ -1349,6 +1350,7 @@ def TuneAmpere1 : SubtargetFeature<"ampere1", "ARMProcFamily", "Ampere1",
"Ampere Computing Ampere-1 processors", [
FeaturePostRAScheduler,
FeatureFuseAES,
FeatureFuseAdrpAdd,
FeatureAddrLSLFast,
FeatureALULSLFast,
FeatureAggressiveFMA,
Expand All @@ -1364,15 +1366,34 @@ def TuneAmpere1A : SubtargetFeature<"ampere1a", "ARMProcFamily", "Ampere1A",
"Ampere Computing Ampere-1A processors", [
FeaturePostRAScheduler,
FeatureFuseAES,
FeatureFuseAdrpAdd,
FeatureAddrLSLFast,
FeatureALULSLFast,
FeatureAggressiveFMA,
FeatureArithmeticBccFusion,
FeatureCmpBccFusion,
FeatureFuseAddress,
FeatureFuseLiterals,
FeatureFuseAddSub2RegAndConstOne,
FeatureStorePairSuppress,
FeatureLdpAlignedOnly,
FeatureStpAlignedOnly]>;

def TuneAmpere1B : SubtargetFeature<"ampere1b", "ARMProcFamily", "Ampere1B",
"Ampere Computing Ampere-1B processors", [
FeaturePostRAScheduler,
FeatureFuseAES,
FeatureFuseAdrpAdd,
FeatureAddrLSLFast,
FeatureALULSLFast,
FeatureAggressiveFMA,
FeatureArithmeticBccFusion,
FeatureCmpBccFusion,
FeatureFuseAddress,
FeatureFuseLiterals,
FeatureStorePairSuppress,
FeatureEnableSelectOptimize,
FeaturePredictableSelectIsExpensive,
FeatureLdpAlignedOnly,
FeatureStpAlignedOnly]>;

Expand Down Expand Up @@ -1530,6 +1551,11 @@ def ProcessorFeatures {
FeatureMTE, FeatureSSBS, FeatureRandGen,
FeatureSB, FeatureSM4, FeatureSHA2,
FeatureSHA3, FeatureAES];
list<SubtargetFeature> Ampere1B = [HasV8_7aOps, FeatureNEON, FeaturePerfMon,
FeatureMTE, FeatureSSBS, FeatureRandGen,
FeatureSB, FeatureSM4, FeatureSHA2,
FeatureSHA3, FeatureAES, FeatureCSSC,
FeatureWFxT];

// ETE and TRBE are future architecture extensions. We temporarily enable them
// by default for users targeting generic AArch64. The extensions do not
Expand Down Expand Up @@ -1697,6 +1723,9 @@ def : ProcessorModel<"ampere1", Ampere1Model, ProcessorFeatures.Ampere1,
def : ProcessorModel<"ampere1a", Ampere1Model, ProcessorFeatures.Ampere1A,
[TuneAmpere1A]>;

def : ProcessorModel<"ampere1b", Ampere1Model, ProcessorFeatures.Ampere1B,
[TuneAmpere1B]>;

//===----------------------------------------------------------------------===//
// Assembly parser
//===----------------------------------------------------------------------===//
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/AArch64/AArch64Subtarget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ void AArch64Subtarget::initializeProperties(bool HasMinSize) {
break;
case Ampere1:
case Ampere1A:
case Ampere1B:
CacheLineSize = 64;
PrefFunctionAlignment = Align(64);
PrefLoopAlignment = Align(64);
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/Target/AArch64/AArch64Subtarget.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ class AArch64Subtarget final : public AArch64GenSubtargetInfo {
A64FX,
Ampere1,
Ampere1A,
Ampere1B,
AppleA7,
AppleA10,
AppleA11,
Expand Down
1 change: 1 addition & 0 deletions llvm/lib/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,7 @@ StringRef sys::detail::getHostCPUNameForARM(StringRef ProcCpuinfoContent) {
return StringSwitch<const char *>(Part)
.Case("0xac3", "ampere1")
.Case("0xac4", "ampere1a")
.Case("0xac5", "ampere1b")
.Default("generic");
}

Expand Down
28 changes: 26 additions & 2 deletions llvm/lib/Transforms/IPO/LowerTypeTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -470,6 +470,9 @@ class LowerTypeTestsModule {

Function *WeakInitializerFn = nullptr;

GlobalVariable *GlobalAnnotation;
DenseSet<Value *> FunctionAnnotations;

bool shouldExportConstantsAsAbsoluteSymbols();
uint8_t *exportTypeId(StringRef TypeId, const TypeIdLowering &TIL);
TypeIdLowering importTypeId(StringRef TypeId);
Expand Down Expand Up @@ -531,6 +534,10 @@ class LowerTypeTestsModule {
/// replace each use, which is a direct function call.
void replaceDirectCalls(Value *Old, Value *New);

bool isFunctionAnnotation(Value *V) const {
return FunctionAnnotations.contains(V);
}

public:
LowerTypeTestsModule(Module &M, ModuleAnalysisManager &AM,
ModuleSummaryIndex *ExportSummary,
Expand Down Expand Up @@ -1377,8 +1384,11 @@ void LowerTypeTestsModule::replaceWeakDeclarationWithJumpTablePtr(
// (all?) targets. Switch to a runtime initializer.
SmallSetVector<GlobalVariable *, 8> GlobalVarUsers;
findGlobalVariableUsersOf(F, GlobalVarUsers);
for (auto *GV : GlobalVarUsers)
for (auto *GV : GlobalVarUsers) {
if (GV == GlobalAnnotation)
continue;
moveInitializerToModuleConstructor(GV);
}

// Can not RAUW F with an expression that uses F. Replace with a temporary
// placeholder first.
Expand Down Expand Up @@ -1837,6 +1847,16 @@ LowerTypeTestsModule::LowerTypeTestsModule(
}
OS = TargetTriple.getOS();
ObjectFormat = TargetTriple.getObjectFormat();

// Function annotation describes or applies to function itself, and
// shouldn't be associated with jump table thunk generated for CFI.
GlobalAnnotation = M.getGlobalVariable("llvm.global.annotations");
if (GlobalAnnotation && GlobalAnnotation->hasInitializer()) {
const ConstantArray *CA =
cast<ConstantArray>(GlobalAnnotation->getInitializer());
for (Value *Op : CA->operands())
FunctionAnnotations.insert(Op);
}
}

bool LowerTypeTestsModule::runForTesting(Module &M, ModuleAnalysisManager &AM) {
Expand Down Expand Up @@ -1896,10 +1916,14 @@ void LowerTypeTestsModule::replaceCfiUses(Function *Old, Value *New,
if (isa<BlockAddress, NoCFIValue>(U.getUser()))
continue;

// Skip direct calls to externally defined or non-dso_local functions
// Skip direct calls to externally defined or non-dso_local functions.
if (isDirectCall(U) && (Old->isDSOLocal() || !IsJumpTableCanonical))
continue;

// Skip function annotation.
if (isFunctionAnnotation(U.getUser()))
continue;

// Must handle Constants specially, we cannot call replaceUsesOfWith on a
// constant because they are uniqued.
if (auto *C = dyn_cast<Constant>(U.getUser())) {
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AArch64/cpus.ll
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=a64fx 2>&1 | FileCheck %s
; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=ampere1 2>&1 | FileCheck %s
; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=ampere1a 2>&1 | FileCheck %s
; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=ampere1b 2>&1 | FileCheck %s
; RUN: llc < %s -mtriple=arm64-unknown-unknown -mcpu=invalidcpu 2>&1 | FileCheck %s --check-prefix=INVALID

; CHECK-NOT: {{.*}} is not a recognized processor for this target
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AArch64/neon-dot-product.ll
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
; RUN: llc -mtriple aarch64-none-linux-gnu -mcpu=neoverse-n2 < %s | FileCheck %s
; RUN: llc -mtriple aarch64-none-linux-gnu -mcpu=ampere1 < %s | FileCheck %s
; RUN: llc -mtriple aarch64-none-linux-gnu -mcpu=ampere1a < %s | FileCheck %s
; RUN: llc -mtriple aarch64-none-linux-gnu -mcpu=ampere1b < %s | FileCheck %s

declare <2 x i32> @llvm.aarch64.neon.udot.v2i32.v8i8(<2 x i32>, <8 x i8>, <8 x i8>)
declare <4 x i32> @llvm.aarch64.neon.udot.v4i32.v16i8(<4 x i32>, <16 x i8>, <16 x i8>)
Expand Down
1 change: 1 addition & 0 deletions llvm/test/CodeGen/AArch64/remat.ll
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=thunderx3t110 -o - %s | FileCheck %s
; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=ampere1 -o - %s | FileCheck %s
; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=ampere1a -o - %s | FileCheck %s
; RUN: llc -mtriple=aarch64-linux-gnuabi -mcpu=ampere1b -o - %s | FileCheck %s

%X = type { i64, i64, i64 }
declare void @f(ptr)
Expand Down
219 changes: 219 additions & 0 deletions llvm/test/CodeGen/AMDGPU/uniform-select.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,219 @@
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 4
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx90a < %s | FileCheck -check-prefixes=GFX90A %s
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx940 < %s | FileCheck -check-prefixes=GFX940 %s
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx1030 < %s | FileCheck -check-prefixes=GFX1030 %s
; RUN: llc -mtriple=amdgcn--amdhsa -mcpu=gfx1100 < %s | FileCheck -check-prefixes=GFX1100 %s

define amdgpu_kernel void @test_insert_extract(i32 %p, i32 %q) {
; GFX90A-LABEL: test_insert_extract:
; GFX90A: ; %bb.0: ; %entry
; GFX90A-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
; GFX90A-NEXT: s_mov_b32 s2, 0
; GFX90A-NEXT: s_and_b64 vcc, exec, -1
; GFX90A-NEXT: s_mov_b32 s3, 0
; GFX90A-NEXT: s_mov_b32 s4, 0
; GFX90A-NEXT: s_mov_b32 s5, 0
; GFX90A-NEXT: s_mov_b32 s6, 0
; GFX90A-NEXT: .LBB0_1: ; %for.body
; GFX90A-NEXT: ; =>This Inner Loop Header: Depth=1
; GFX90A-NEXT: s_waitcnt lgkmcnt(0)
; GFX90A-NEXT: s_cmp_eq_u32 s1, 1
; GFX90A-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX90A-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX90A-NEXT: s_cselect_b32 s7, s4, s3
; GFX90A-NEXT: s_cmp_eq_u32 s1, 2
; GFX90A-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX90A-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX90A-NEXT: s_cselect_b32 s7, s5, s7
; GFX90A-NEXT: s_cmp_eq_u32 s1, 3
; GFX90A-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX90A-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX90A-NEXT: s_cselect_b32 s7, s6, s7
; GFX90A-NEXT: s_or_b32 s7, s7, s0
; GFX90A-NEXT: s_cmp_eq_u32 s1, 1
; GFX90A-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX90A-NEXT: s_and_b64 s[10:11], s[8:9], exec
; GFX90A-NEXT: s_cselect_b32 s4, s7, s4
; GFX90A-NEXT: s_cmp_eq_u32 s1, 3
; GFX90A-NEXT: s_cselect_b64 s[10:11], -1, 0
; GFX90A-NEXT: s_and_b64 s[12:13], s[10:11], exec
; GFX90A-NEXT: s_cselect_b32 s6, s7, s6
; GFX90A-NEXT: s_cmp_eq_u32 s1, 2
; GFX90A-NEXT: s_cselect_b64 s[12:13], -1, 0
; GFX90A-NEXT: s_and_b64 s[14:15], s[12:13], exec
; GFX90A-NEXT: s_cselect_b32 s5, s7, s5
; GFX90A-NEXT: s_cmp_eq_u32 s1, 0
; GFX90A-NEXT: s_cselect_b32 s3, s7, s3
; GFX90A-NEXT: s_or_b64 s[8:9], s[12:13], s[8:9]
; GFX90A-NEXT: s_or_b64 s[8:9], s[10:11], s[8:9]
; GFX90A-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX90A-NEXT: s_cselect_b32 s2, 0, s2
; GFX90A-NEXT: s_mov_b64 vcc, vcc
; GFX90A-NEXT: s_cbranch_vccnz .LBB0_1
; GFX90A-NEXT: ; %bb.2: ; %DummyReturnBlock
; GFX90A-NEXT: s_endpgm
;
; GFX940-LABEL: test_insert_extract:
; GFX940: ; %bb.0: ; %entry
; GFX940-NEXT: s_load_dwordx2 s[0:1], s[0:1], 0x0
; GFX940-NEXT: s_mov_b32 s2, 0
; GFX940-NEXT: s_and_b64 vcc, exec, -1
; GFX940-NEXT: s_mov_b32 s3, 0
; GFX940-NEXT: s_mov_b32 s4, 0
; GFX940-NEXT: s_mov_b32 s5, 0
; GFX940-NEXT: s_mov_b32 s6, 0
; GFX940-NEXT: .LBB0_1: ; %for.body
; GFX940-NEXT: ; =>This Inner Loop Header: Depth=1
; GFX940-NEXT: s_waitcnt lgkmcnt(0)
; GFX940-NEXT: s_cmp_eq_u32 s1, 1
; GFX940-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX940-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX940-NEXT: s_cselect_b32 s7, s4, s3
; GFX940-NEXT: s_cmp_eq_u32 s1, 2
; GFX940-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX940-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX940-NEXT: s_cselect_b32 s7, s5, s7
; GFX940-NEXT: s_cmp_eq_u32 s1, 3
; GFX940-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX940-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX940-NEXT: s_cselect_b32 s7, s6, s7
; GFX940-NEXT: s_or_b32 s7, s7, s0
; GFX940-NEXT: s_cmp_eq_u32 s1, 1
; GFX940-NEXT: s_cselect_b64 s[8:9], -1, 0
; GFX940-NEXT: s_and_b64 s[10:11], s[8:9], exec
; GFX940-NEXT: s_cselect_b32 s4, s7, s4
; GFX940-NEXT: s_cmp_eq_u32 s1, 3
; GFX940-NEXT: s_cselect_b64 s[10:11], -1, 0
; GFX940-NEXT: s_and_b64 s[12:13], s[10:11], exec
; GFX940-NEXT: s_cselect_b32 s6, s7, s6
; GFX940-NEXT: s_cmp_eq_u32 s1, 2
; GFX940-NEXT: s_cselect_b64 s[12:13], -1, 0
; GFX940-NEXT: s_and_b64 s[14:15], s[12:13], exec
; GFX940-NEXT: s_cselect_b32 s5, s7, s5
; GFX940-NEXT: s_cmp_eq_u32 s1, 0
; GFX940-NEXT: s_cselect_b32 s3, s7, s3
; GFX940-NEXT: s_or_b64 s[8:9], s[12:13], s[8:9]
; GFX940-NEXT: s_or_b64 s[8:9], s[10:11], s[8:9]
; GFX940-NEXT: s_and_b64 s[8:9], s[8:9], exec
; GFX940-NEXT: s_cselect_b32 s2, 0, s2
; GFX940-NEXT: s_mov_b64 vcc, vcc
; GFX940-NEXT: s_cbranch_vccnz .LBB0_1
; GFX940-NEXT: ; %bb.2: ; %DummyReturnBlock
; GFX940-NEXT: s_endpgm
;
; GFX1030-LABEL: test_insert_extract:
; GFX1030: ; %bb.0: ; %entry
; GFX1030-NEXT: s_load_dwordx2 s[0:1], s[4:5], 0x0
; GFX1030-NEXT: s_mov_b32 s2, 0
; GFX1030-NEXT: s_mov_b32 s3, 0
; GFX1030-NEXT: s_mov_b32 s4, 0
; GFX1030-NEXT: s_mov_b32 s5, 0
; GFX1030-NEXT: s_mov_b32 s6, 0
; GFX1030-NEXT: s_mov_b32 vcc_lo, exec_lo
; GFX1030-NEXT: .p2align 6
; GFX1030-NEXT: .LBB0_1: ; %for.body
; GFX1030-NEXT: ; =>This Inner Loop Header: Depth=1
; GFX1030-NEXT: s_waitcnt lgkmcnt(0)
; GFX1030-NEXT: s_cmp_eq_u32 s1, 1
; GFX1030-NEXT: s_cselect_b32 s7, -1, 0
; GFX1030-NEXT: s_and_b32 s7, s7, exec_lo
; GFX1030-NEXT: s_cselect_b32 s7, s4, s3
; GFX1030-NEXT: s_cmp_eq_u32 s1, 2
; GFX1030-NEXT: s_cselect_b32 s8, -1, 0
; GFX1030-NEXT: s_and_b32 s8, s8, exec_lo
; GFX1030-NEXT: s_cselect_b32 s7, s5, s7
; GFX1030-NEXT: s_cmp_eq_u32 s1, 3
; GFX1030-NEXT: s_cselect_b32 s8, -1, 0
; GFX1030-NEXT: s_and_b32 s8, s8, exec_lo
; GFX1030-NEXT: s_cselect_b32 s7, s6, s7
; GFX1030-NEXT: s_or_b32 s7, s7, s0
; GFX1030-NEXT: s_cmp_eq_u32 s1, 1
; GFX1030-NEXT: s_cselect_b32 s8, -1, 0
; GFX1030-NEXT: s_and_b32 s9, s8, exec_lo
; GFX1030-NEXT: s_cselect_b32 s4, s7, s4
; GFX1030-NEXT: s_cmp_eq_u32 s1, 3
; GFX1030-NEXT: s_cselect_b32 s9, -1, 0
; GFX1030-NEXT: s_and_b32 s10, s9, exec_lo
; GFX1030-NEXT: s_cselect_b32 s6, s7, s6
; GFX1030-NEXT: s_cmp_eq_u32 s1, 2
; GFX1030-NEXT: s_cselect_b32 s10, -1, 0
; GFX1030-NEXT: s_and_b32 s11, s10, exec_lo
; GFX1030-NEXT: s_cselect_b32 s5, s7, s5
; GFX1030-NEXT: s_cmp_eq_u32 s1, 0
; GFX1030-NEXT: s_cselect_b32 s3, s7, s3
; GFX1030-NEXT: s_or_b32 s7, s10, s8
; GFX1030-NEXT: s_or_b32 s7, s9, s7
; GFX1030-NEXT: s_and_b32 s7, s7, exec_lo
; GFX1030-NEXT: s_cselect_b32 s2, 0, s2
; GFX1030-NEXT: s_cbranch_vccnz .LBB0_1
; GFX1030-NEXT: ; %bb.2: ; %DummyReturnBlock
; GFX1030-NEXT: s_endpgm
;
; GFX1100-LABEL: test_insert_extract:
; GFX1100: ; %bb.0: ; %entry
; GFX1100-NEXT: s_load_b64 s[0:1], s[0:1], 0x0
; GFX1100-NEXT: s_mov_b32 s2, 0
; GFX1100-NEXT: s_mov_b32 s3, 0
; GFX1100-NEXT: s_mov_b32 s4, 0
; GFX1100-NEXT: s_mov_b32 s5, 0
; GFX1100-NEXT: s_mov_b32 s6, 0
; GFX1100-NEXT: s_mov_b32 vcc_lo, exec_lo
; GFX1100-NEXT: .p2align 6
; GFX1100-NEXT: .LBB0_1: ; %for.body
; GFX1100-NEXT: ; =>This Inner Loop Header: Depth=1
; GFX1100-NEXT: s_waitcnt lgkmcnt(0)
; GFX1100-NEXT: s_cmp_eq_u32 s1, 1
; GFX1100-NEXT: s_cselect_b32 s7, -1, 0
; GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
; GFX1100-NEXT: s_and_b32 s7, s7, exec_lo
; GFX1100-NEXT: s_cselect_b32 s7, s4, s3
; GFX1100-NEXT: s_cmp_eq_u32 s1, 2
; GFX1100-NEXT: s_cselect_b32 s8, -1, 0
; GFX1100-NEXT: s_and_b32 s8, s8, exec_lo
; GFX1100-NEXT: s_cselect_b32 s7, s5, s7
; GFX1100-NEXT: s_cmp_eq_u32 s1, 3
; GFX1100-NEXT: s_cselect_b32 s8, -1, 0
; GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_1) | instid1(SALU_CYCLE_1)
; GFX1100-NEXT: s_and_b32 s8, s8, exec_lo
; GFX1100-NEXT: s_cselect_b32 s7, s6, s7
; GFX1100-NEXT: s_or_b32 s7, s7, s0
; GFX1100-NEXT: s_cmp_eq_u32 s1, 1
; GFX1100-NEXT: s_cselect_b32 s8, -1, 0
; GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_3) | instid1(SALU_CYCLE_1)
; GFX1100-NEXT: s_and_b32 s9, s8, exec_lo
; GFX1100-NEXT: s_cselect_b32 s4, s7, s4
; GFX1100-NEXT: s_cmp_eq_u32 s1, 3
; GFX1100-NEXT: s_cselect_b32 s9, -1, 0
; GFX1100-NEXT: s_and_b32 s10, s9, exec_lo
; GFX1100-NEXT: s_cselect_b32 s6, s7, s6
; GFX1100-NEXT: s_cmp_eq_u32 s1, 2
; GFX1100-NEXT: s_cselect_b32 s10, -1, 0
; GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1) | instskip(SKIP_4) | instid1(SALU_CYCLE_1)
; GFX1100-NEXT: s_and_b32 s11, s10, exec_lo
; GFX1100-NEXT: s_cselect_b32 s5, s7, s5
; GFX1100-NEXT: s_cmp_eq_u32 s1, 0
; GFX1100-NEXT: s_cselect_b32 s3, s7, s3
; GFX1100-NEXT: s_or_b32 s7, s10, s8
; GFX1100-NEXT: s_or_b32 s7, s9, s7
; GFX1100-NEXT: s_delay_alu instid0(SALU_CYCLE_1)
; GFX1100-NEXT: s_and_b32 s7, s7, exec_lo
; GFX1100-NEXT: s_cselect_b32 s2, 0, s2
; GFX1100-NEXT: s_cbranch_vccnz .LBB0_1
; GFX1100-NEXT: ; %bb.2: ; %DummyReturnBlock
; GFX1100-NEXT: s_endpgm
entry:
%init = insertelement <4 x i32> zeroinitializer, i32 0, i64 0
br label %for.body

for.body: ; preds = %for.body, %entry
%x1 = phi <4 x i32> [ %init, %entry ], [ %i4, %for.body ]
%x2 = phi <4 x i32> [ zeroinitializer, %entry ], [ %i2, %for.body ]
%idxprom = zext i32 %q to i64
%e1 = extractelement <4 x i32> %x2, i64 %idxprom
%add = or i32 %e1, %p
%i2 = insertelement <4 x i32> %x2, i32 %add, i64 %idxprom
%e3 = extractelement <4 x i32> %x1, i64 %idxprom
%i4 = insertelement <4 x i32> %x1, i32 %e3, i64 0
br label %for.body
}

8 changes: 4 additions & 4 deletions llvm/test/CodeGen/NVPTX/intrinsics.ll
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
; RUN: llc < %s -march=nvptx -mcpu=sm_20 | FileCheck %s
; RUN: llc < %s -march=nvptx64 -mcpu=sm_20 | FileCheck %s
; RUN: %if ptxas && !ptxas-12.0 %{ llc < %s -march=nvptx -mcpu=sm_20 | %ptxas-verify %}
; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_20 | %ptxas-verify %}
; RUN: llc < %s -march=nvptx -mcpu=sm_60 | FileCheck %s
; RUN: llc < %s -march=nvptx64 -mcpu=sm_60 | FileCheck %s
; RUN: %if ptxas && !ptxas-12.0 %{ llc < %s -march=nvptx -mcpu=sm_60 | %ptxas-verify %}
; RUN: %if ptxas %{ llc < %s -march=nvptx64 -mcpu=sm_60 | %ptxas-verify %}

; CHECK-LABEL: test_fabsf(
define float @test_fabsf(float %f) {
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/NVPTX/nvvm-reflect-opaque.ll
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ exit:
ret float %ret
}

declare i32 @llvm.nvvm.reflect.p0(ptr)
declare i32 @llvm.nvvm.reflect(ptr)

; CHECK-LABEL: define noundef i32 @intrinsic
define i32 @intrinsic() {
; CHECK-NOT: call i32 @llvm.nvvm.reflect
; USE_FTZ_0: ret i32 0
; USE_FTZ_1: ret i32 1
%ptr = tail call ptr @llvm.nvvm.ptr.constant.to.gen.p0.p4(ptr addrspace(4) @str)
%reflect = tail call i32 @llvm.nvvm.reflect.p0(ptr %ptr)
%reflect = tail call i32 @llvm.nvvm.reflect(ptr %ptr)
ret i32 %reflect
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/NVPTX/nvvm-reflect.ll
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,15 @@ exit:
ret float %ret
}

declare i32 @llvm.nvvm.reflect.p0(ptr)
declare i32 @llvm.nvvm.reflect(ptr)

; CHECK-LABEL: define noundef i32 @intrinsic
define i32 @intrinsic() {
; CHECK-NOT: call i32 @llvm.nvvm.reflect
; USE_FTZ_0: ret i32 0
; USE_FTZ_1: ret i32 1
%ptr = tail call ptr @llvm.nvvm.ptr.constant.to.gen.p0.p4(ptr addrspace(4) @str)
%reflect = tail call i32 @llvm.nvvm.reflect.p0(ptr %ptr)
%reflect = tail call i32 @llvm.nvvm.reflect(ptr %ptr)
ret i32 %reflect
}

Expand Down
4 changes: 2 additions & 2 deletions llvm/test/CodeGen/RISCV/push-pop-opt-crash.ll
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
; RUN: llc -mattr=+zcmp -verify-machineinstrs \
; RUN: -mtriple=riscv32 -target-abi ilp32 < %s \
; RUN: -mtriple=riscv32 -target-abi=ilp32 < %s \
; RUN: | FileCheck %s -check-prefixes=RV32IZCMP
; RUN: llc -mattr=+zcmp -verify-machineinstrs \
; RUN: -mtriple=riscv64 -target-abi ilp64 < %s \
; RUN: -mtriple=riscv64 -target-abi=lp64 < %s \
; RUN: | FileCheck %s -check-prefixes=RV64IZCMP

; This source code exposed a crash in the RISC-V Zcmp Push/Pop optimization
Expand Down
3 changes: 3 additions & 0 deletions llvm/test/MC/AArch64/armv8.2a-dotprod.s
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
// RUN: llvm-mc -triple aarch64 -mattr=+v8r,+dotprod -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
// RUN: llvm-mc -triple aarch64 -mcpu=ampere1 -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
// RUN: llvm-mc -triple aarch64 -mcpu=ampere1a -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD
// RUN: llvm-mc -triple aarch64 -mcpu=ampere1b -show-encoding < %s | FileCheck %s --check-prefix=CHECK-DOTPROD

// RUN: not llvm-mc -triple aarch64 -mattr=+v8.2a -show-encoding < %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
Expand Down Expand Up @@ -42,6 +43,8 @@
// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
// RUN: not llvm-mc -triple aarch64 -mcpu=ampere1a -mattr=-dotprod -show-encoding < %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s
// RUN: not llvm-mc -triple aarch64 -mcpu=ampere1b -mattr=-dotprod -show-encoding < %s 2> %t
// RUN: FileCheck --check-prefix=CHECK-NO-DOTPROD < %t %s

udot v0.2s, v1.8b, v2.8b
sdot v0.2s, v1.8b, v2.8b
Expand Down
1 change: 1 addition & 0 deletions llvm/test/MC/Disassembler/AArch64/armv8.3a-rcpc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=neoverse-n2 --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1 --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1a --disassemble < %s | FileCheck %s
# RUN: llvm-mc -triple aarch64-none-linux-gnu -mcpu=ampere1b --disassemble < %s | FileCheck %s

# CHECK: ldaprb w0, [x0]
# CHECK: ldaprh w0, [x0]
Expand Down
8 changes: 4 additions & 4 deletions llvm/test/MC/WebAssembly/alias-offset.s
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ sym_a:
.set sym_b, sym_a + 4

# CHECK-LABEL: SYMBOL TABLE:
# CHECK-NEXT: 00000000 l O DATA foo
# CHECK-NEXT: 00000004 l O DATA sym_a
# CHECK-NEXT: 00000008 l O DATA sym_b
# CHECK-NEXT: 00000001 l F CODE main
# CHECK-NEXT: 00000000 l O DATA 00000004 foo
# CHECK-NEXT: 00000004 l O DATA 00000008 sym_a
# CHECK-NEXT: 00000008 l O DATA 00000004 sym_b
# CHECK-NEXT: 00000001 l F CODE 00000012 main

.text
.section .text,"",@
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/MC/WebAssembly/alias.s
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,6 @@ sym_a:

.set sym_b, sym_a

# CHECK: 00000000 l O DATA foo
# CHECK: 00000004 l O DATA sym_a
# CHECK: 00000004 l O DATA sym_b
# CHECK: 00000000 l O DATA 00000004 foo
# CHECK: 00000004 l O DATA 00000004 sym_a
# CHECK: 00000004 l O DATA 00000004 sym_b
2 changes: 1 addition & 1 deletion llvm/test/Object/wasm-linked-namesec-with-linkingsec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# RUN: llvm-nm -P %t.wasm | FileCheck %s
#
# Test that names from the linking section override those from the name section
# CHECK: foo T 1 0
# CHECK: foo T 1 3
# CHECK-NOT: my_func_local_name

--- !WASM
Expand Down
6 changes: 3 additions & 3 deletions llvm/test/Object/wasm-linked-symbol-table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@
# RUN: llvm-objdump -t %t.wasm | FileCheck %s
#
# CHECK: SYMBOL TABLE:
# CHECK-NEXT: 0000009f g F CODE my_func_export
# CHECK-NEXT: 0000002a g O DATA my_global_export
# CHECK-NEXT: 00000000 g TABLE my_table_export
# CHECK-NEXT: 0000009f g F CODE 00000003 my_func_export
# CHECK-NEXT: 0000002a g O DATA 00000000 my_global_export
# CHECK-NEXT: 00000000 g TABLE 00000000 my_table_export

--- !WASM
FileHeader:
Expand Down
68 changes: 68 additions & 0 deletions llvm/test/Transforms/LowerTypeTests/cfi-annotation.ll
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
; REQUIRES: aarch64-registered-target

; RUN: opt -passes=lowertypetests %s -o %t.o
; RUN: llvm-dis %t.o -o - | FileCheck %s --check-prefix=CHECK-foobar
; CHECK-foobar: {{llvm.global.annotations = .*[foo|bar], .*[foo|bar],}}
; RUN: llvm-dis %t.o -o - | FileCheck %s --check-prefix=CHECK-cfi
; CHECK-cfi-NOT: {{llvm.global.annotations = .*cfi.*}}

target triple = "aarch64-none-linux-gnu"

@.src = private unnamed_addr constant [7 x i8] c"test.c\00", align 1
@.str = private unnamed_addr constant [30 x i8] c"annotation_string_literal_bar\00", section "llvm.metadata"
@.str.1 = private unnamed_addr constant [7 x i8] c"test.c\00", section "llvm.metadata"
@.str.2 = private unnamed_addr constant [30 x i8] c"annotation_string_literal_foo\00", section "llvm.metadata"
@llvm.global.annotations = appending global [2 x { ptr, ptr, ptr, i32, ptr }] [{ ptr, ptr, ptr, i32, ptr } { ptr @bar, ptr @.str, ptr @.str.1, i32 2, ptr null }, { ptr, ptr, ptr, i32, ptr } { ptr @foo, ptr @.str.2, ptr @.str.1, i32 1, ptr null }], section "llvm.metadata"

define i32 @bar(i32 noundef %0) #0 !type !8 !type !9 {
%2 = alloca i32, align 4
store i32 %0, ptr %2, align 4
%3 = load i32, ptr %2, align 4
%4 = call i32 @foo(i32 noundef %3)
ret i32 %4
}

declare !type !8 !type !9 i32 @foo(i32 noundef) #1

define i32 @test(i32 noundef %0) #0 !type !8 !type !9 {
%2 = alloca i32, align 4
%3 = alloca ptr, align 8
store i32 %0, ptr %2, align 4
%4 = load i32, ptr %2, align 4
%5 = icmp sgt i32 %4, 0
%6 = zext i1 %5 to i64
%7 = select i1 %5, ptr @foo, ptr @bar
store ptr %7, ptr %3, align 8
%8 = load ptr, ptr %3, align 8
%9 = call i1 @llvm.type.test(ptr %8, metadata !"_ZTSFiiE"), !nosanitize !10
br i1 %9, label %11, label %10, !nosanitize !10

10:
call void @llvm.ubsantrap(i8 2) #4, !nosanitize !10
unreachable, !nosanitize !10

11:
%12 = load i32, ptr %2, align 4
%13 = call i32 %8(i32 noundef %12)
ret i32 %13
}

declare i1 @llvm.type.test(ptr, metadata)
declare void @llvm.ubsantrap(i8 immarg)

attributes #0 = { noinline nounwind optnone uwtable "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }
attributes #1 = { "frame-pointer"="non-leaf" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="generic" "target-features"="+fp-armv8,+neon,+v8a,-fmv" }
attributes #4 = { noreturn nounwind }

!llvm.module.flags = !{!0, !1, !2, !3, !4, !5, !6}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 4, !"CFI Canonical Jump Tables", i32 0}
!2 = !{i32 8, !"PIC Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{i32 7, !"frame-pointer", i32 1}
!5 = !{i32 1, !"ThinLTO", i32 0}
!6 = !{i32 1, !"EnableSplitLTOUnit", i32 1}
!8 = !{i64 0, !"_ZTSFiiE"}
!9 = !{i64 0, !"_ZTSFiiE.generalized"}
!10 = !{}
94 changes: 94 additions & 0 deletions llvm/test/tools/llvm-lib/exportas.test
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
Test EXPORTAS in importlibs.

RUN: split-file %s %t.dir && cd %t.dir
RUN: llvm-lib -machine:amd64 -def:test.def -out:test.lib

RUN: llvm-nm --print-armap test.lib | FileCheck --check-prefix=ARMAP %s

ARMAP: Archive map
ARMAP-NEXT: __IMPORT_DESCRIPTOR_test in test.dll
ARMAP-NEXT: __NULL_IMPORT_DESCRIPTOR in test.dll
ARMAP-NEXT: __imp_func in test.dll
ARMAP-NEXT: __imp_func2 in test.dll
ARMAP-NEXT: __imp_func3 in test.dll
ARMAP-NEXT: __imp_mydata in test.dll
ARMAP-NEXT: func in test.dll
ARMAP-NEXT: func2 in test.dll
ARMAP-NEXT: func3 in test.dll
ARMAP-NEXT: test_NULL_THUNK_DATA in test.dll

RUN: llvm-readobj test.lib | FileCheck --check-prefix=READOBJ %s

READOBJ: File: test.lib(test.dll)
READOBJ-NEXT: Format: COFF-x86-64
READOBJ-NEXT: Arch: x86_64
READOBJ-NEXT: AddressSize: 64bit
READOBJ-EMPTY:
READOBJ-NEXT: File: test.lib(test.dll)
READOBJ-NEXT: Format: COFF-x86-64
READOBJ-NEXT: Arch: x86_64
READOBJ-NEXT: AddressSize: 64bit
READOBJ-EMPTY:
READOBJ-NEXT: File: test.lib(test.dll)
READOBJ-NEXT: Format: COFF-x86-64
READOBJ-NEXT: Arch: x86_64
READOBJ-NEXT: AddressSize: 64bit
READOBJ-EMPTY:
READOBJ-NEXT: File: test.dll
READOBJ-NEXT: Format: COFF-import-file-x86-64
READOBJ-NEXT: Type: code
READOBJ-NEXT: Name type: export as
READOBJ-NEXT: Export name: expfunc
READOBJ-NEXT: Symbol: __imp_func
READOBJ-NEXT: Symbol: func
READOBJ-EMPTY:
READOBJ-NEXT: File: test.dll
READOBJ-NEXT: Format: COFF-import-file-x86-64
READOBJ-NEXT: Type: data
READOBJ-NEXT: Name type: export as
READOBJ-NEXT: Export name: expdata
READOBJ-NEXT: Symbol: __imp_mydata
READOBJ-EMPTY:
READOBJ-NEXT: File: test.dll
READOBJ-NEXT: Format: COFF-import-file-x86-64
READOBJ-NEXT: Type: code
READOBJ-NEXT: Name type: export as
READOBJ-NEXT: Export name: expfunc2
READOBJ-NEXT: Symbol: __imp_func2
READOBJ-NEXT: Symbol: func2
READOBJ-EMPTY:
READOBJ-NEXT: File: test.dll
READOBJ-NEXT: Format: COFF-import-file-x86-64
READOBJ-NEXT: Type: code
READOBJ-NEXT: Name type: export as
READOBJ-NEXT: Export name: expfunc3
READOBJ-NEXT: Symbol: __imp_func3
READOBJ-NEXT: Symbol: func3


EXPORTAS must be at the end of entry declaration.
RUN: not llvm-lib -machine:amd64 -def:test2.def -out:test2.lib 2>&1 \
RUN: | FileCheck --check-prefix=ERROR %s
RUN: not llvm-lib -machine:amd64 -def:test3.def -out:test3.lib 2>&1 \
RUN: | FileCheck --check-prefix=ERROR %s
ERROR: Invalid data was encountered while parsing the file


#--- test.def
LIBRARY test.dll
EXPORTS
func EXPORTAS expfunc
mydata DATA EXPORTAS expdata
func2 = myfunc2 EXPORTAS expfunc2
func3 = otherdll.otherfunc3 EXPORTAS expfunc3

#--- test2.def
LIBRARY test.dll
EXPORTS
func EXPORTAS expfunc
mydata EXPORTAS expdata DATA

#--- test3.def
LIBRARY test.dll
EXPORTS
mydata EXPORTAS
5 changes: 5 additions & 0 deletions llvm/test/tools/llvm-nm/wasm/linked.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,15 @@
# RUN: yaml2obj %s -o %t.wasm
# RUN: llvm-nm %t.wasm | FileCheck %s
# RUN: llvm-nm -P %t.wasm | FileCheck %s --check-prefix=POSIX

# CHECK: 0000009f T my_func_export
# CHECK-NEXT: 0000002a D my_global_export
# CHECK-NEXT: 00000000 D my_table_export

# POSIX: my_func_export T 9f 3
# POSIX-NEXT: my_global_export D 2a 0
# POSIX-NEXT: my_table_export D 0 0

--- !WASM
FileHeader:
Version: 0x1
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/tools/llvm-nm/wasm/print-size.test
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,4 @@ Sections:
Size: 32

# CHECK: 00000000 00000020 D a_data_symbol
# CHECK: 00000001 00000000 T a_func
# CHECK: 00000001 0000000d T a_func
4 changes: 2 additions & 2 deletions llvm/test/tools/llvm-objdump/wasm/dylink-symbol-table.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
# RUN: llvm-objdump -t %t.so | FileCheck %s
#
# CHECK: SYMBOL TABLE:
# CHECK-NEXT: 00000001 g F CODE my_func_export
# CHECK-NEXT: 0000002a g O DATA my_global_export
# CHECK-NEXT: 00000001 g F CODE 00000003 my_func_export
# CHECK-NEXT: 0000002a g O DATA 00000000 my_global_export

--- !WASM
FileHeader:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
# RUN: llvm-objdump -t %t.wasm | FileCheck %s
#
# CHECK: SYMBOL TABLE:
# CHECK-NEXT: 00000000 F *UND* my_func_import_name
# CHECK-NEXT: 00000083 g F CODE my_func_export_name
# CHECK-NEXT: 00000086 l F CODE my_func_local_name
# CHECK-NEXT: 00000000 *UND* my_global_import_name
# CHECK-NEXT: 00000001 g GLOBAL my_global_export_name
# CHECK-NEXT: 00000000 l O DATA my_datasegment_name
# CHECK-NEXT: 00000000 F *UND* 00000000 my_func_import_name
# CHECK-NEXT: 00000083 g F CODE 00000003 my_func_export_name
# CHECK-NEXT: 00000086 l F CODE 00000003 my_func_local_name
# CHECK-NEXT: 00000000 *UND* 00000000 my_global_import_name
# CHECK-NEXT: 00000001 g GLOBAL 00000000 my_global_export_name
# CHECK-NEXT: 00000000 l O DATA 00000004 my_datasegment_name

--- !WASM
FileHeader:
Expand Down
12 changes: 6 additions & 6 deletions llvm/test/tools/llvm-objdump/wasm/symbol-table.test
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
RUN: llvm-objdump -t %p/Inputs/trivial.obj.wasm | FileCheck %s

CHECK: SYMBOL TABLE:
CHECK-NEXT: 00000001 g F CODE main
CHECK-NEXT: 00000000 l O DATA .L.str
CHECK-NEXT: 00000000 F *UND* puts
CHECK-NEXT: 00000019 l F CODE .LSomeOtherFunction_bitcast
CHECK-NEXT: 00000000 F *UND* SomeOtherFunction
CHECK-NEXT: 00000010 g O DATA var
CHECK-NEXT: 00000001 g F CODE 00000018 main
CHECK-NEXT: 00000000 l O DATA 0000000d .L.str
CHECK-NEXT: 00000000 F *UND* 00000000 puts
CHECK-NEXT: 00000019 l F CODE 0000000b .LSomeOtherFunction_bitcast
CHECK-NEXT: 00000000 F *UND* 00000000 SomeOtherFunction
CHECK-NEXT: 00000010 g O DATA 00000004 var
5 changes: 3 additions & 2 deletions llvm/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -845,8 +845,9 @@ int main(int argc, char **argv) {

bool OffsetRequested = false;

// Defaults to dumping all sections, unless brief mode is specified in which
// case only the .debug_info section in dumped.
// Defaults to dumping only debug_info, unless: A) verbose mode is specified,
// in which case all sections are dumped, or B) a specific section is
// requested.
#define HANDLE_DWARF_SECTION(ENUM_NAME, ELF_NAME, CMDLINE_NAME, OPTION) \
if (Dump##ENUM_NAME.IsRequested) { \
DumpType |= DIDT_##ENUM_NAME; \
Expand Down
7 changes: 2 additions & 5 deletions llvm/tools/llvm-nm/llvm-nm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1854,11 +1854,8 @@ static bool getSymbolNamesFromObject(SymbolicFile &Obj,
dyn_cast<const XCOFFObjectFile>(&Obj))
S.Size = XCOFFObj->getSymbolSize(Sym.getRawDataRefImpl());

if (const WasmObjectFile *WasmObj = dyn_cast<WasmObjectFile>(&Obj)) {
const WasmSymbol &WasmSym = WasmObj->getWasmSymbol(Sym);
if (WasmSym.isTypeData() && !WasmSym.isUndefined())
S.Size = WasmSym.Info.DataRef.Size;
}
if (const WasmObjectFile *WasmObj = dyn_cast<WasmObjectFile>(&Obj))
S.Size = WasmObj->getSymbolSize(Sym);

if (PrintAddress && isa<ObjectFile>(Obj)) {
SymbolRef SymRef(Sym);
Expand Down
4 changes: 4 additions & 0 deletions llvm/tools/llvm-objdump/llvm-objdump.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2947,6 +2947,10 @@ void Dumper::printSymbol(const SymbolRef &Symbol,
Symbol.getRawDataRefImpl()));
else if (O.isELF())
outs() << '\t' << format(Fmt, ELFSymbolRef(Symbol).getSize());
else if (O.isWasm())
outs() << '\t'
<< format(Fmt, static_cast<uint64_t>(
cast<WasmObjectFile>(O).getSymbolSize(Symbol)));

if (O.isELF()) {
if (!SymbolVersions.empty()) {
Expand Down
3 changes: 3 additions & 0 deletions llvm/tools/llvm-readobj/COFFImportDumper.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ void dumpCOFFImportFile(const COFFImportFile *File, ScopedPrinter &Writer) {
case COFF::IMPORT_NAME_UNDECORATE:
Writer.printString("Name type", "undecorate");
break;
case COFF::IMPORT_NAME_EXPORTAS:
Writer.printString("Name type", "export as");
break;
}

if (H->getNameType() != COFF::IMPORT_ORDINAL)
Expand Down
3 changes: 3 additions & 0 deletions llvm/unittests/TargetParser/Host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,9 @@ TEST(getLinuxHostCPUName, AArch64) {
EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
"CPU part : 0xac4"),
"ampere1a");
EXPECT_EQ(sys::detail::getHostCPUNameForARM("CPU implementer : 0xc0\n"
"CPU part : 0xac5"),
"ampere1b");

// MSM8992/4 weirdness
StringRef MSM8992ProcCpuInfo = R"(
Expand Down
14 changes: 13 additions & 1 deletion llvm/unittests/TargetParser/TargetParserTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1600,6 +1600,18 @@ INSTANTIATE_TEST_SUITE_P(
AArch64::AEK_MTE, AArch64::AEK_JSCVT, AArch64::AEK_FCMA,
AArch64::AEK_PAUTH})),
"8.6-A"),
ARMCPUTestParams<AArch64::ExtensionBitset>(
"ampere1b", "armv8.7-a", "crypto-neon-fp-armv8",
(AArch64::ExtensionBitset(
{AArch64::AEK_CRC, AArch64::AEK_FP, AArch64::AEK_FP16,
AArch64::AEK_SIMD, AArch64::AEK_RAS, AArch64::AEK_LSE,
AArch64::AEK_RDM, AArch64::AEK_RCPC, AArch64::AEK_DOTPROD,
AArch64::AEK_SM4, AArch64::AEK_SHA3, AArch64::AEK_BF16,
AArch64::AEK_SHA2, AArch64::AEK_AES, AArch64::AEK_I8MM,
AArch64::AEK_SSBS, AArch64::AEK_SB, AArch64::AEK_RAND,
AArch64::AEK_MTE, AArch64::AEK_JSCVT, AArch64::AEK_FCMA,
AArch64::AEK_PAUTH, AArch64::AEK_CSSC})),
"8.7-A"),
ARMCPUTestParams<AArch64::ExtensionBitset>(
"neoverse-512tvb", "armv8.4-a", "crypto-neon-fp-armv8",
(AArch64::ExtensionBitset(
Expand Down Expand Up @@ -1679,7 +1691,7 @@ INSTANTIATE_TEST_SUITE_P(
ARMCPUTestParams<AArch64::ExtensionBitset>::PrintToStringParamName);

// Note: number of CPUs includes aliases.
static constexpr unsigned NumAArch64CPUArchs = 68;
static constexpr unsigned NumAArch64CPUArchs = 69;

TEST(TargetParserTest, testAArch64CPUArchList) {
SmallVector<StringRef, NumAArch64CPUArchs> List;
Expand Down
Loading