Skip to content

Update to LLVM 18.1.1 (+ additional commits) #170

New issue

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

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

Already on GitHub? Sign in to your account

Merged
merged 47 commits into from
Mar 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
b92012c
Remove RC suffix
tru Sep 19, 2023
dba2a75
Bump version to 18.1.1
tstellar Mar 8, 2024
2ad8fbd
Bump version to 18.1.2 (#84655)
tstellar Mar 11, 2024
439e6f8
[libc++][modules] Fixes naming inconsistency. (#83036)
mordante Feb 27, 2024
340ba45
MIPS: fix emitDirectiveCpsetup on N32 (#80534)
wzssyqa Feb 26, 2024
267d9b1
Allow .alt_entry symbols to pass the .cfi nesting check (#82268)
jroelofs Feb 28, 2024
16ab081
[clang][fat-lto-objects] Make module flags match non-FatLTO pipelines…
ilovepi Feb 29, 2024
bf45c3a
[DSE] Delay deleting non-memory-defs until end of DSE. (#83411)
fhahn Mar 2, 2024
e90bfdb
[test] Make two sanitize-coverage tests pass with glibc 2.39+
MaskRay Mar 6, 2024
4c36ecb
[InstCombine] Fix shift calculation in InstCombineCasts (#84027)
dianqk Mar 5, 2024
94d8f15
[InstCombine] Fix infinite loop in select equivalence fold (#84036)
nikic Mar 6, 2024
7cb6753
ReleaseNotes for LLVM binary utilities (#83751)
MaskRay Mar 11, 2024
a91b9bd
[OpenMP] fix endianness dependent definitions in OMP headers for MSVC…
vadikp-intel Mar 9, 2024
69d9b15
[TableGen] Fix wrong codegen of BothFusionPredicateWithMCInstPredicat…
wangpc-pp Mar 5, 2024
ea6c457
[LoongArch] Override LoongArchTargetLowering::getExtendForAtomicCmpSw…
SixWeining Mar 4, 2024
d7a9810
[AArch64] Fix variadic tail-calls on ARM64EC (#79774)
bylaws Jan 31, 2024
42c599a
[AArch64] Fix generated types for ARM64EC variadic entry thunk target…
bylaws Feb 5, 2024
89d5432
[AArch64] Skip over shadow space for ARM64EC entry thunk variadic cal…
bylaws Feb 27, 2024
c148795
Unbreak *tf builtins for hexfloat (#82208)
arichardson Feb 21, 2024
c3721c1
[ELF] Internalize enum
MaskRay Mar 1, 2024
eb9bc02
[RISCV] Fix crash when unrolling loop containing vector instructions …
arcbbb Mar 2, 2024
d8352e9
[Clang] [Sema] Handle placeholders in '.*' expressions (#83103)
Sirraide Feb 27, 2024
78859f1
[lld][LoongArch] Support the R_LARCH_{ADD,SUB}_ULEB128 relocation typ…
MQ-mengqing Mar 5, 2024
55193c2
[InstCombine] Handle scalable splat in `getFlippedStrictnessPredicate…
dtcxzyw Mar 5, 2024
c14bf0a
[libc++] Enable availability based on the compiler instead of __has_e…
ldionne Mar 7, 2024
1de8ea7
[analyzer] Fix crash on dereference invalid return value of getAdjust…
mzyKi Mar 6, 2024
d77c5c3
[LoongArch] Make sure that the LoongArchISD::BSTRINS node uses the co…
wangleiat Mar 11, 2024
a9ba36c
[Clang][LoongArch] Precommit test for fix wrong return value type of …
wangleiat Mar 5, 2024
9b9aee1
[Clang][LoongArch] Fix wrong return value type of __iocsrrd_h (#84100)
wangleiat Mar 6, 2024
3f8711f
[InstCombine] Fix miscompilation in PR83947 (#83993)
dtcxzyw Mar 5, 2024
39e3ba8
[DSE] Remove malloc from EarliestEscapeInfo before removing. (#84157)
fhahn Mar 6, 2024
fcc33dc
[X86] combineAndShuffleNot - ensure the type is legal before create X…
RKSimon Mar 10, 2024
2fc8bea
[LLD] [COFF] Set the right alignment for DelayDirectoryChunk (#84697)
mstorsjo Mar 11, 2024
25a989c
[ArgPromotion] Add test case for #84807.
fhahn Mar 11, 2024
7b61dde
[ArgPromotion] Remove incorrect TranspBlocks set for loads. (#84835)
fhahn Mar 12, 2024
159969b
[Release] Install compiler-rt builtins during Phase 1 on AIX (#81485)
azhan92 Feb 16, 2024
b01c3dc
[LAA] Add test case for #82665.
fhahn Mar 7, 2024
c7eb919
[ValueTracking] Treat phi as underlying obj when not decomposing furt…
fhahn Mar 12, 2024
38cf35d
[Inline] Add test for #67054 (NFC)
nikic Mar 4, 2024
8c6015d
[X86][Inline] Skip inline asm in inlining target feature check (#83820)
nikic Mar 5, 2024
33c6b20
SystemZ release notes for 18.x. (#84560)
JonPsson1 Mar 13, 2024
122ba9f
[ELF] Eliminate symbols demoted due to /DISCARD/ discarded sections (…
MaskRay Mar 14, 2024
bb83f05
[runtimes] Prefer -fvisibility-global-new-delete=force-hidden (#84917)
mstorsjo Mar 13, 2024
600f7f2
[clangd] Add clangd 18 release notes (#84436)
HighCommander4 Mar 15, 2024
9b3edb5
release/18.x: [openmp] __kmp_x86_cpuid fix for i386/PIC builds. (#846…
devnexen Mar 15, 2024
12a3bf3
workflows: Add workaround for lld failures on MacOS (#85021) (#85110)
tstellar Mar 15, 2024
7faae6d
Merge remote-tracking branch 'upstream-llvm/release/18.x' into hrmny/…
ForsakenHarmony Mar 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .github/workflows/llvm-project-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,11 @@ jobs:
else
builddir="$(pwd)"/build
fi
if [ "${{ runner.os }}" == "macOS" ]; then
# Workaround test failure on some lld tests on MacOS
# https://github.com/llvm/llvm-project/issues/81967
extra_cmake_args="-DLLVM_DISABLE_ASSEMBLY_FILES=ON"
fi
echo "llvm-builddir=$builddir" >> "$GITHUB_OUTPUT"
cmake -G Ninja \
-B "$builddir" \
Expand Down
43 changes: 36 additions & 7 deletions clang-tools-extra/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -51,21 +51,35 @@ Improvements to clangd
Inlay hints
^^^^^^^^^^^

Diagnostics
^^^^^^^^^^^

Semantic Highlighting
^^^^^^^^^^^^^^^^^^^^^
- Type hints
* Improved heuristics for showing sugared vs. desguared types
* Some hints which provide no information (e.g. ``<dependent-type>``) are now omitted
- Parameter hints
* Parameter hints are now shown for calls through function pointers
* Parameter hints are now shown for calls to a class's ``operator()``
* No longer show bogus parameter hints for some builtins like ``__builtin_dump_struct``

Compile flags
^^^^^^^^^^^^^

- System include extractor (``--query-driver``) improvements
* The directory containing builtin headers is now excluded from extracted system includes
* Various flags which can affect the system includes (``--target``, ``--stdlib``, ``-specs``) are now forwarded to the driver
* Fixed a bug where clangd would sometimes try to call a driver that didn't have obj-c support with ``-x objective-c++-header``
* The driver path is now dot-normalized before being compared to the ``--query-driver`` pattern
* ``--query-driver`` is now supported by ``clangd-indexer``
- Fixed a regression in clangd 17 where response files would not be expanded

Hover
^^^^^

- Hover now shows alignment info for fields and records

Code completion
^^^^^^^^^^^^^^^

- Refined heuristics for determining whether the use of a function can be a call or not

Code actions
^^^^^^^^^^^^

Expand All @@ -75,15 +89,25 @@ Code actions
Signature help
^^^^^^^^^^^^^^

- Improved support for calls through function pointer types

Cross-references
^^^^^^^^^^^^^^^^

- Improved support for C++20 concepts
- Find-references now works for labels
- Improvements to template heuristics

Objective-C
^^^^^^^^^^^

Miscellaneous
^^^^^^^^^^^^^

- Various stability improvements, e.g. crash fixes
- Improved error recovery on invalid code
- Clangd now bails gracefully on assembly and IR source files

Improvements to clang-doc
-------------------------

Expand Down Expand Up @@ -564,10 +588,15 @@ Changes in existing checks
Removed checks
^^^^^^^^^^^^^^

Improvements to include-fixer
Improvements to include-cleaner
-----------------------------

The improvements are...
- Support for ``--only-headers`` flag to limit analysis to headers matching a regex
- Recognizes references through ``concept``s
- Builtin headers are not analyzed
- Handling of references through ``friend`` declarations
- Fixes around handling of IWYU pragmas on stdlib headers
- Improved handling around references to/from template specializations

Improvements to clang-include-fixer
-----------------------------------
Expand Down
7 changes: 7 additions & 0 deletions clang/docs/ReleaseNotes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -1103,6 +1103,8 @@ Bug Fixes to C++ Support
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)
- Correctly immediate-escalate lambda conversion functions.
(`#82258 <https://github.com/llvm/llvm-project/issues/82258>`_)
- Fix a crash when an unresolved overload set is encountered on the RHS of a ``.*`` operator.
(`#53815 <https://github.com/llvm/llvm-project/issues/53815>`_)

Bug Fixes to AST Handling
^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -1325,6 +1327,11 @@ AIX Support
or newer. Similar to the LTO support on AIX, ThinLTO is implemented with
the libLTO.so plugin.

SystemZ Support
^^^^^^^^^^^^^^^
- Properly support 16 byte atomic int/fp types and ops. Atomic __int128 (and
long double) variables are now aligned to 16 bytes by default (like gcc 14).

WebAssembly Support
^^^^^^^^^^^^^^^^^^^

Expand Down
32 changes: 16 additions & 16 deletions clang/lib/CodeGen/BackendUtil.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,14 @@ class EmitAssemblyHelper {
TargetTriple.getVendor() != llvm::Triple::Apple;
}

/// Check whether we should emit a flag for UnifiedLTO.
/// The UnifiedLTO module flag should be set when UnifiedLTO is enabled for
/// ThinLTO or Full LTO with module summaries.
bool shouldEmitUnifiedLTOModueFlag() const {
return CodeGenOpts.UnifiedLTO &&
(CodeGenOpts.PrepareForThinLTO || shouldEmitRegularLTOSummary());
}

public:
EmitAssemblyHelper(DiagnosticsEngine &_Diags,
const HeaderSearchOptions &HeaderSearchOpts,
Expand Down Expand Up @@ -1029,7 +1037,8 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!actionRequiresCodeGen(Action) && CodeGenOpts.VerifyModule)
MPM.addPass(VerifierPass());

if (Action == Backend_EmitBC || Action == Backend_EmitLL) {
if (Action == Backend_EmitBC || Action == Backend_EmitLL ||
CodeGenOpts.FatLTO) {
if (CodeGenOpts.PrepareForThinLTO && !CodeGenOpts.DisableLLVMPasses) {
if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
TheModule->addModuleFlag(llvm::Module::Error, "EnableSplitLTOUnit",
Expand All @@ -1040,11 +1049,9 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!ThinLinkOS)
return;
}
if (CodeGenOpts.UnifiedLTO)
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
MPM.addPass(ThinLTOBitcodeWriterPass(
*OS, ThinLinkOS ? &ThinLinkOS->os() : nullptr));
} else {
} else if (Action == Backend_EmitLL) {
MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
/*EmitLTOSummary=*/true));
}
Expand All @@ -1058,24 +1065,17 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
TheModule->addModuleFlag(llvm::Module::Error, "EnableSplitLTOUnit",
uint32_t(1));
if (CodeGenOpts.UnifiedLTO)
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
}
if (Action == Backend_EmitBC)
if (Action == Backend_EmitBC) {
MPM.addPass(BitcodeWriterPass(*OS, CodeGenOpts.EmitLLVMUseLists,
EmitLTOSummary));
else
} else if (Action == Backend_EmitLL) {
MPM.addPass(PrintModulePass(*OS, "", CodeGenOpts.EmitLLVMUseLists,
EmitLTOSummary));
}
}
}
if (CodeGenOpts.FatLTO) {
// Set the EnableSplitLTOUnit and UnifiedLTO module flags, since FatLTO
// uses a different action than Backend_EmitBC or Backend_EmitLL.
if (!TheModule->getModuleFlag("EnableSplitLTOUnit"))
TheModule->addModuleFlag(llvm::Module::Error, "EnableSplitLTOUnit",
uint32_t(CodeGenOpts.EnableSplitLTOUnit));
if (CodeGenOpts.UnifiedLTO && !TheModule->getModuleFlag("UnifiedLTO"))

if (shouldEmitUnifiedLTOModueFlag())
TheModule->addModuleFlag(llvm::Module::Error, "UnifiedLTO", uint32_t(1));
}

Expand Down
2 changes: 1 addition & 1 deletion clang/lib/Headers/larchintrin.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ extern __inline unsigned char
return (unsigned char)__builtin_loongarch_iocsrrd_b((unsigned int)_1);
}

extern __inline unsigned char
extern __inline unsigned short
__attribute__((__gnu_inline__, __always_inline__, __artificial__))
__iocsrrd_h(unsigned int _1) {
return (unsigned short)__builtin_loongarch_iocsrrd_h((unsigned int)_1);
Expand Down
22 changes: 17 additions & 5 deletions clang/lib/Sema/SemaOverload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14470,6 +14470,23 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
CurFPFeatureOverrides());
}

// If this is the .* operator, which is not overloadable, just
// create a built-in binary operator.
if (Opc == BO_PtrMemD) {
auto CheckPlaceholder = [&](Expr *&Arg) {
ExprResult Res = CheckPlaceholderExpr(Arg);
if (Res.isUsable())
Arg = Res.get();
return !Res.isUsable();
};

// CreateBuiltinBinOp() doesn't like it if we tell it to create a '.*'
// expression that contains placeholders (in either the LHS or RHS).
if (CheckPlaceholder(Args[0]) || CheckPlaceholder(Args[1]))
return ExprError();
return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);
}

// Always do placeholder-like conversions on the RHS.
if (checkPlaceholderForOverload(*this, Args[1]))
return ExprError();
Expand All @@ -14489,11 +14506,6 @@ ExprResult Sema::CreateOverloadedBinOp(SourceLocation OpLoc,
if (Opc == BO_Assign && !Args[0]->getType()->isOverloadableType())
return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);

// If this is the .* operator, which is not overloadable, just
// create a built-in binary operator.
if (Opc == BO_PtrMemD)
return CreateBuiltinBinOp(OpLoc, Opc, Args[0], Args[1]);

// Build the overload set.
OverloadCandidateSet CandidateSet(OpLoc, OverloadCandidateSet::CSK_Operator,
OverloadCandidateSet::OperatorRewriteInfo(
Expand Down
2 changes: 1 addition & 1 deletion clang/lib/StaticAnalyzer/Core/CallEvent.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1409,7 +1409,7 @@ CallEventManager::getSimpleCall(const CallExpr *CE, ProgramStateRef State,
if (const auto *OpCE = dyn_cast<CXXOperatorCallExpr>(CE)) {
const FunctionDecl *DirectCallee = OpCE->getDirectCallee();
if (const auto *MD = dyn_cast<CXXMethodDecl>(DirectCallee))
if (MD->isInstance())
if (MD->isImplicitObjectMemberFunction())
return create<CXXMemberOperatorCall>(OpCE, State, LCtx, ElemRef);

} else if (CE->getCallee()->getType()->isBlockPointerType()) {
Expand Down
11 changes: 11 additions & 0 deletions clang/test/Analysis/cxx2b-deducing-this.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,14 @@ void top() {
s.c();
s.c(11);
}


struct S2 {
bool operator==(this auto, S2) {
return true;
}
};
void use_deducing_this() {
int result = S2{} == S2{}; // no-crash
clang_analyzer_dump(result); // expected-warning {{1 S32b}}
}
29 changes: 22 additions & 7 deletions clang/test/CodeGen/LoongArch/intrinsic-la32.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,8 +169,8 @@ unsigned int cpucfg(unsigned int a) {

// LA32-LABEL: @rdtime(
// LA32-NEXT: entry:
// LA32-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
// LA32-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
// LA32-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc [[META2:![0-9]+]]
// LA32-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META3:![0-9]+]]
// LA32-NEXT: ret void
//
void rdtime() {
Expand Down Expand Up @@ -201,13 +201,28 @@ void loongarch_movgr2fcsr(int a) {
__builtin_loongarch_movgr2fcsr(1, a);
}

// CHECK-LABEL: @cacop_w(
// CHECK-NEXT: entry:
// CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A:%.*]], i32 1024)
// CHECK-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A]], i32 1024)
// CHECK-NEXT: ret void
// LA32-LABEL: @cacop_w(
// LA32-NEXT: entry:
// LA32-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A:%.*]], i32 1024)
// LA32-NEXT: tail call void @llvm.loongarch.cacop.w(i32 1, i32 [[A]], i32 1024)
// LA32-NEXT: ret void
//
void cacop_w(unsigned long int a) {
__cacop_w(1, a, 1024);
__builtin_loongarch_cacop_w(1, a, 1024);
}

// LA32-LABEL: @iocsrrd_h_result(
// LA32-NEXT: entry:
// LA32-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
// LA32-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// LA32-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
// LA32-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
// LA32-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
// LA32-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
unsigned short c = __builtin_loongarch_iocsrrd_h(a);
return b+c;
}
21 changes: 18 additions & 3 deletions clang/test/CodeGen/LoongArch/intrinsic-la64.c
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ unsigned int cpucfg(unsigned int a) {

// CHECK-LABEL: @rdtime_d(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect "rdtime.d $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc !2
// CHECK-NEXT: [[TMP0:%.*]] = tail call { i64, i64 } asm sideeffect "rdtime.d $0, $1\0A\09", "=&r,=&r"() #[[ATTR1:[0-9]+]], !srcloc [[META2:![0-9]+]]
// CHECK-NEXT: ret void
//
void rdtime_d() {
Expand All @@ -396,8 +396,8 @@ void rdtime_d() {

// CHECK-LABEL: @rdtime(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !3
// CHECK-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc !4
// CHECK-NEXT: [[TMP0:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimeh.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META3:![0-9]+]]
// CHECK-NEXT: [[TMP1:%.*]] = tail call { i32, i32 } asm sideeffect "rdtimel.w $0, $1\0A\09", "=&r,=&r"() #[[ATTR1]], !srcloc [[META4:![0-9]+]]
// CHECK-NEXT: ret void
//
void rdtime() {
Expand Down Expand Up @@ -427,3 +427,18 @@ void loongarch_movgr2fcsr(int a) {
__movgr2fcsr(1, a);
__builtin_loongarch_movgr2fcsr(1, a);
}

// CHECK-LABEL: @iocsrrd_h_result(
// CHECK-NEXT: entry:
// CHECK-NEXT: [[TMP0:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A:%.*]])
// CHECK-NEXT: [[CONV_I:%.*]] = trunc i32 [[TMP0]] to i16
// CHECK-NEXT: [[TMP1:%.*]] = tail call i32 @llvm.loongarch.iocsrrd.h(i32 [[A]])
// CHECK-NEXT: [[TMP2:%.*]] = trunc i32 [[TMP1]] to i16
// CHECK-NEXT: [[CONV3:%.*]] = add i16 [[TMP2]], [[CONV_I]]
// CHECK-NEXT: ret i16 [[CONV3]]
//
unsigned short iocsrrd_h_result(unsigned int a) {
unsigned short b = __iocsrrd_h(a);
unsigned short c = __builtin_loongarch_iocsrrd_h(a);
return b+c;
}
21 changes: 20 additions & 1 deletion clang/test/CodeGen/fat-lto-objects.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,11 @@
// RUN: llvm-objcopy --dump-section=.llvm.lto=%t.full.split.bc %t.full.split.o
// RUN: llvm-dis %t.full.split.bc -o - | FileCheck %s --check-prefixes=FULL,SPLIT,NOUNIFIED

/// Full LTO always sets EnableSplitLTOUnit when the summary is used.
// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -emit-obj < %s -o %t.full.nosplit.o
// RUN: llvm-readelf -S %t.full.nosplit.o | FileCheck %s --check-prefixes=ELF
// RUN: llvm-objcopy --dump-section=.llvm.lto=%t.full.nosplit.bc %t.full.nosplit.o
// RUN: llvm-dis %t.full.nosplit.bc -o - | FileCheck %s --check-prefixes=FULL,NOSPLIT,NOUNIFIED
// RUN: llvm-dis %t.full.nosplit.bc -o - | FileCheck %s --check-prefixes=FULL,SPLIT,NOUNIFIED

// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=thin -fsplit-lto-unit -ffat-lto-objects -emit-obj < %s -o %t.thin.split.o
// RUN: llvm-readelf -S %t.thin.split.o | FileCheck %s --check-prefixes=ELF
Expand All @@ -34,6 +35,21 @@
// RUN: %clang -cc1 -triple x86_64-unknown-linux-gnu -flto=full -ffat-lto-objects -fsplit-lto-unit -S < %s -o - \
// RUN: | FileCheck %s --check-prefixes=ASM

/// Make sure that FatLTO generates .llvm.lto sections that are the same as the output from normal LTO compilations
// RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=full -ffat-lto-objects -c %s -o %t.fatlto.full.o
// RUN: llvm-objcopy --dump-section=.llvm.lto=%t.fatlto.full.bc %t.fatlto.full.o
// RUN: llvm-dis < %t.fatlto.full.bc -o %t.fatlto.full.ll
// RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=full -c %s -o %t.nofat.full.bc
// RUN: llvm-dis < %t.nofat.full.bc -o %t.nofat.full.ll
// RUN: diff %t.fatlto.full.ll %t.nofat.full.ll

// RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=thin -ffat-lto-objects -c %s -o %t.fatlto.thin.o
// RUN: llvm-objcopy --dump-section=.llvm.lto=%t.fatlto.thin.bc %t.fatlto.thin.o
// RUN: llvm-dis < %t.fatlto.thin.bc -o %t.fatlto.thin.ll
// RUN: %clang -O2 --target=x86_64-unknown-linux-gnu -fPIE -flto=thin -c %s -o %t.nofat.thin.bc
// RUN: llvm-dis < %t.nofat.thin.bc -o %t.nofat.thin.ll
// RUN: diff %t.fatlto.thin.ll %t.nofat.thin.ll

/// Be sure we enable split LTO units correctly under -ffat-lto-objects.
// SPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 1}
// NOSPLIT: ![[#]] = !{i32 1, !"EnableSplitLTOUnit", i32 0}
Expand All @@ -51,6 +67,9 @@
// ASM-NEXT: .asciz "BC
// ASM-NEXT: .size .Lllvm.embedded.object

const char* foo = "foo";

int test(void) {
const char* bar = "bar";
return 0xabcd;
}
Loading