[clang] [C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #109167)

2024-10-04 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

ah there's a stack trace in an asserts build of clang
```
F 00:00:1728077756.9778713296 logging.cc:62] assert.h assertion failed 
at 
third_party/llvm/llvm-project/clang/lib/Sema/SemaTemplateInstantiate.cpp:4602 
in llvm::PointerUnion 
*clang::LocalInstantiationScope::findInstantiationOf(const Decl *): isa<
LabelDecl>(D) && "declaration not instantiated in this scope"   


  
@ 0x563ef889e824  __assert_fail 


   
@ 0x563ef47a3bf4  clang::LocalInstantiationScope::findInstantiationOf() 


   
@ 0x563ef4836942  clang::Sema::FindInstantiatedDecl()   


   
@ 0x563ef4810491  clang::TreeTransform<>::TransformLambdaExpr() 


   
@ 0x563ef47ffb91  (anonymous 
namespace)::TemplateInstantiator::TransformLambdaExpr() 


  
@ 0x563ef47a1dc2  clang::TreeTransform<>::TransformExprs()  


   
@ 0x563ef480293d  clang::TreeTransform<>::TransformCallExpr()   


   
@ 0x563ef479f7fa  clang::TreeTransform<>::TransformStmt()   


   
@ 0x563ef4809f34  clang::TreeTransform<>::TransformCompoundStmt()   


   
@ 0x563ef479f788  clang::Sema::SubstStmt()  


   
@ 0x563ef484a01d  clang::Sema::InstantiateFunctionDefinition()  


   
@ 0x563ef484d0bf  clang::Sema::PerformPendingInstantiations()   


   
@ 0x563ef484a108  clang::Sema::InstantiateFunctionDefinition()  


   
@ 0x563ef484d0bf  clang::Sema::PerformPendingInstantiations()   


   
@ 0x563ef484a10

[clang] [C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #109167)

2024-10-04 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

this has also caused the following issue to pop up in our modules build

```
error: variable 'param' cannot be implicitly captured in a lambda with no 
capture-default specified
```

hopefully the error provides some guidance for where to look, but I can try to 
get a reduced repro

https://github.com/llvm/llvm-project/pull/109167
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

I see that MMI really is a Codegen concept and not a Target concept, so that's 
why it takes an LLVMTargetMachine instead of TargetMachine. However, the 
`static_cast`s everywhere are extremely unfortunate. And it doesn't make sense 
to make the return type of `Target::createTargetMachine()` `LLVMTargetMachine` 
instead of `TargetMachine`. Perhaps alternatively we make the MMI constructor 
take `TargetMachine` and cast it inside the constructor to `LLVMTargetMachine`, 
so we only pay the cost of this weird distinction in one place rather than 
everywhere? wdyt?

https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

ah there's more context in https://reviews.llvm.org/D123964

https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits


@@ -1162,6 +1165,7 @@ void EmitAssemblyHelper::RunCodegenPipeline(
   // does not work with the codegen pipeline.
   // FIXME: make the new PM work with the codegen pipeline.
   legacy::PassManager CodeGenPasses;
+  std::unique_ptr MMI;

aeubanks wrote:

can this just be `MachineModuleInfo MMI;` below?

https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits


@@ -106,16 +106,18 @@ class MachineModuleInfo {
   const Function *LastRequest = nullptr; ///< Used for shortcut/cache.
   MachineFunction *LastResult = nullptr; ///< Used for shortcut/cache.
 
-  MachineModuleInfo &operator=(MachineModuleInfo &&MMII) = delete;
+  /// Deleted copy constructor

aeubanks wrote:

comment is not useful, I'd either say why it's deleted or just remove the 
comment

https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make Ownership of MachineModuleInfo in Its Wrapper Pass External (PR #110443)

2024-10-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

I'm still trying to wrap my head around LLVMTargetMachine vs TargetMachine, let 
me do some reading

https://github.com/llvm/llvm-project/pull/110443
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make MMIWP not have ownership over MMI + Make MMI Only Use an External MCContext (PR #105541)

2024-09-23 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

hmm yeah it does seem that `MCContext` is hard to unentangle from 
`MMI`/`MachineFunction`

is it possible to split out the "MMIWP doesn't own MMI" change? that seems less 
controversial and easier to review/merge and makes the `MCContext` changes 
easier to look at

https://github.com/llvm/llvm-project/pull/105541
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [flang] [llvm] [mlir] Make MMIWP not have ownership over MMI + Make MMI Only Use an External MCContext (PR #105541)

2024-09-17 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

sorry for the delay

after looking at MMI/MCContext, I agree that MMI shouldn't own MCContext, but 
do we even need a reference from MMI to MCContext? they are different layers of 
codegen IIUC. if it's possible to completely separate them we should do that 
(please correct me if this doesn't make sense since I haven't spent too much 
time in codegen)

https://github.com/llvm/llvm-project/pull/105541
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-12 Thread Arthur Eubanks via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 


aeubanks wrote:

here's something reduced, let me know if you need the command to create the pch 
file as well

```

https://github.com/llvm/llvm-project/pull/104512
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang][test] Fix some windows driver tests with legacy runtime dir layout (PR #108452)

2024-09-12 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/108452

With the legacy runtime directory layout, the runtime libraries are under 
`lib/clang/20/lib/windows` and have an arch suffix.

>From c45f5df3c0ba7afd6c5e14e8e49ffa853abc7147 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Thu, 12 Sep 2024 20:52:20 +
Subject: [PATCH] [clang][test] Fix some windows driver tests with legacy
 runtime dir layout

With the legacy runtime directory layout, the runtime libraries are under 
`lib/clang/20/lib/windows` and have an arch suffix.
---
 clang/test/Driver/cl-link.c   | 12 ++--
 clang/test/Driver/windows-cross.c |  2 +-
 2 files changed, 7 insertions(+), 7 deletions(-)

diff --git a/clang/test/Driver/cl-link.c b/clang/test/Driver/cl-link.c
index f5260442760452..9bf8a8137926de 100644
--- a/clang/test/Driver/cl-link.c
+++ b/clang/test/Driver/cl-link.c
@@ -13,17 +13,17 @@
 // ASAN: link.exe
 // ASAN: "-debug"
 // ASAN: "-incremental:no"
-// ASAN: "{{[^"]*}}clang_rt.asan_dynamic.lib"
-// ASAN: "-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk.lib"
+// ASAN: "{{[^"]*}}clang_rt.asan_dynamic{{(-i386)?}}.lib"
+// ASAN: 
"-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk{{(-i386)?}}.lib"
 // ASAN: "{{.*}}cl-link{{.*}}.obj"
 
 // RUN: %clang_cl -m32 -arch:IA32 --target=i386-pc-win32 /MD /Tc%s 
-fuse-ld=link -### -fsanitize=address 2>&1 | FileCheck --check-prefix=ASAN-MD %s
 // ASAN-MD: link.exe
 // ASAN-MD: "-debug"
 // ASAN-MD: "-incremental:no"
-// ASAN-MD: "{{.*}}clang_rt.asan_dynamic.lib"
+// ASAN-MD: "{{.*}}clang_rt.asan_dynamic{{(-i386)?}}.lib"
 // ASAN-MD: "-include:___asan_seh_interceptor"
-// ASAN-MD: "-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk.lib"
+// ASAN-MD: 
"-wholearchive:{{.*}}clang_rt.asan_dynamic_runtime_thunk{{(-i386)?}}.lib"
 // ASAN-MD: "{{.*}}cl-link{{.*}}.obj"
 
 // RUN: %clang_cl /LD -fuse-ld=link -### /Tc%s 2>&1 | FileCheck 
--check-prefix=DLL %s
@@ -37,8 +37,8 @@
 // ASAN-DLL: "-dll"
 // ASAN-DLL: "-debug"
 // ASAN-DLL: "-incremental:no"
-// ASAN-DLL: "{{.*}}clang_rt.asan_dynamic.lib"
-// ASAN-DLL: "-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk.lib"
+// ASAN-DLL: "{{.*}}clang_rt.asan_dynamic{{(-i386)?}}.lib"
+// ASAN-DLL: 
"-wholearchive:{{.*}}clang_rt.asan_static_runtime_thunk{{(-i386)?}}.lib"
 // ASAN-DLL: "{{.*}}cl-link{{.*}}.obj"
 
 // RUN: %clang_cl /Zi /Tc%s -fuse-ld=link -### 2>&1 | FileCheck 
--check-prefix=DEBUG %s
diff --git a/clang/test/Driver/windows-cross.c 
b/clang/test/Driver/windows-cross.c
index f6e831f00e13a6..096358d306323a 100644
--- a/clang/test/Driver/windows-cross.c
+++ b/clang/test/Driver/windows-cross.c
@@ -64,7 +64,7 @@
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-ADDRESS-EXE-X86
 
 // CHECK-SANITIZE-ADDRESS-EXE-X86: "-fsanitize=address"
-// CHECK-SANITIZE-ADDRESS-EXE-X86: "{{.*}}clang_rt.asan_dynamic.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk.lib" "--undefined" 
"___asan_seh_interceptor"
+// CHECK-SANITIZE-ADDRESS-EXE-X86: 
"{{.*}}clang_rt.asan_dynamic{{(-i386)?}}.lib" 
"{{.*}}clang_rt.asan_dynamic_runtime_thunk{{(-i386)?}}.lib" "--undefined" 
"___asan_seh_interceptor"
 
 // RUN: not %clang -### --target=armv7-windows-itanium --sysroot 
%S/Inputs/Windows/ARM/8.1 -B %S/Inputs/Windows/ARM/8.1/usr/bin 
-fuse-ld=lld-link2 -shared -o shared.dll -fsanitize=tsan -x c++ %s 2>&1 \
 // RUN:| FileCheck %s --check-prefix CHECK-SANITIZE-TSAN

___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-12 Thread Arthur Eubanks via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw==?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 


aeubanks wrote:

let me try to come up with a reduced repro

https://github.com/llvm/llvm-project/pull/104512
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Diagnose dangling issues for the "Container" case. (PR #107213)

2024-09-11 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

this looks like it has false positives: https://crbug.com/366074092

can we revert in the meantime?

https://github.com/llvm/llvm-project/pull/107213
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Reland [asan][windows] Eliminate the static asan runtime on windows (PR #107899)

2024-09-11 Thread Arthur Eubanks via cfe-commits


@@ -136,7 +160,7 @@ append_list_if(MINGW "${MINGW_LIBRARIES}" ASAN_DYNAMIC_LIBS)
 add_compiler_rt_object_libraries(RTAsan_dynamic
   OS ${SANITIZER_COMMON_SUPPORTED_OS}
   ARCHS ${ASAN_SUPPORTED_ARCH}
-  SOURCES ${ASAN_SOURCES} ${ASAN_CXX_SOURCES}
+  SOURCES ${ASAN_SOURCES}

aeubanks wrote:

this line seems to be the problem, reverting it fixes the tests

https://github.com/llvm/llvm-project/pull/107899
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Reland [asan][windows] Eliminate the static asan runtime on windows (PR #107899)

2024-09-11 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

previous passing output

```
2: = 
3: ==7382==ERROR: AddressSanitizer: requested allocation size 0x101 
(0x1001008 after adjustments for alignment, red zones etc.) exceeds maximum 
supported size of 0x100 (thread T0) 
4:  #0 0x0001032a9268 in _Znwm+0x6c 
(libclang_rt.asan_osx_dynamic.dylib:arm64+0x61268) 
5:  #1 0x000102cd775c in main allocator_returns_null.cpp:82 
6:  #2 0x00018cc07150 () 
7:  #3 0x3a08fffc () 
8:  
9: ==7382==HINT: if you don't care about these errors you may set 
allocator_may_return_null=1 
   10: SUMMARY: AddressSanitizer: allocation-size-too-big 
allocator_returns_null.cpp:82 in main 
   11: ==7382==ABORTING 
```

failing output with this PR

```
 2: 
= 
 3: ==6635==ERROR: AddressSanitizer: requested allocation size 
0x101 (0x1001008 after adjustments for alignment, red zones etc.) 
exceeds maximum supported size of 0x100 (thread T0) 
 4:  #0 0x0001029b60ec in malloc+0x70 
(libclang_rt.asan_osx_dynamic.dylib:arm64+0x520ec) 
 5:  #1 0x00018cf4abd0 in operator new(unsigned long)+0x1c 
(libc++abi.dylib:arm64+0x16bd0) 
 6:  #2 0xde678001023f375c () 
 7:  #3 0x00018cc07150 () 
 8:  #4 0x9c0d7ffc () 
 9:  
10: ==6635==HINT: if you don't care about these errors you may set 
allocator_may_return_null=1 
11: SUMMARY: AddressSanitizer: allocation-size-too-big 
(libc++abi.dylib:arm64+0x16bd0) in operator new(unsigned long)+0x1c 
12: ==6635==ABORTING 
```

https://github.com/llvm/llvm-project/pull/107899
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] Reland [asan][windows] Eliminate the static asan runtime on windows (PR #107899)

2024-09-11 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

I think this is also somehow affecting asan tests on macos: 
https://green.lab.llvm.org/job/llvm.org/job/clang-stage1-RA/2034/

was able to reproduce locally 
`build/cmake/runtimes/runtimes-bins/compiler-rt/test/sanitizer_common/asan-arm64-Darwin/allocator_returns_null.cpp`
 failing at this commit and succeeding at the previous

https://github.com/llvm/llvm-project/pull/107899
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [RFC][C++20][Modules] Fix crash when function and lambda inside loaded from different modules (PR #104512)

2024-09-11 Thread Arthur Eubanks via cfe-commits
Valentin Clement =?utf-8?b?KOODkOODrOODsw=?=,Kyungwoo Lee 
,Dmitry
 Polukhin ,Dmitry Polukhin
 
Message-ID:
In-Reply-To: 


aeubanks wrote:

this is causing a crash with precompiled headers. I can try to reduce, but 
hopefully the problem is obvious from this assert/stack trace?

```
clang++: ../../llvm/include/llvm/ADT/SmallVector.h:295: const_reference 
llvm::SmallVectorTemplateCommon>::operator[](size_type)
 const [T = std::unique_ptr]: Assertion `idx 
< size()' failed.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and 
include the crash backtrace, preprocessed source, and associated run script.
Stack dump:
0.  Program arguments: ../../../../llvm-project/build/rel/bin/clang++ -MMD 
-MF 
obj/third_party/blink/renderer/core/probe/instrumentation_probes/core_probes_impl.o.d
 -DDCHECK_ALWAYS_ON=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS 
-D_FORTIFY_SOURCE=2 -DCR_XCODE_VERSION=1500 
-D_LIBCPP_HARDENING_MODE=_LIBCPP_HARDENING_MODE_EXTENSIVE -DCOMPONENT_BUILD 
-DCR_LIBCXX_REVISION=6ae6f38d10eda881c16d91932348fc6d4ee98332 
-DTEMP_REBUILD_HACK -DNDEBUG -DNVALGRIND -DDYNAMIC_ANNOTATIONS_ENABLED=0 
-DBLINK_CORE_IMPLEMENTATION=1 -DSK_ENABLE_SKSL 
-DSK_UNTIL_CRBUG_1187654_IS_FIXED 
-DSK_USER_CONFIG_HEADER=\"../../skia/config/SkUserConfig.h\" 
-DSK_WIN_FONTMGR_NO_SIMULATIONS -DSK_DISABLE_LEGACY_INIT_DECODERS 
-DSK_DISABLE_LEGACY_BACKEND_TEXTURE_FUNCS 
-DSK_DISABLE_LEGACY_TEXTURE_INFO_FUNCS 
-DSK_DISABLE_LEGACY_BACKEND_SEMAPHORE_FUNCS -DSK_DISABLE_LEGACY_GRAPHITE_IMAGES 
-DSK_DISABLE_LEGACY_DAWN_TEXTURE_INFO_FUNCS 
-DSK_DISABLE_LEGACY_DAWN_BACKEND_TEXTURE_FUNCS -DSK_CODEC_DECODES_JPEG 
-DSK_ENCODE_JPEG -DSK_ENCODE_PNG -DSK_ENCODE_WEBP -DSKIA_DLL 
-DSKCMS_API=__attribute__((visibility(\"default\"))) -DSK_BUILD_FOR_MAC 
-DSK_GANESH 
-DSK_GPU_WORKAROUNDS_HEADER=\"gpu/config/gpu_driver_bug_workaround_autogen.h\" 
-DSK_GL -DSK_GRAPHITE -DSK_DAWN -DSK_METAL -DCHROMIUM -DLIBYUV_DISABLE_NEON 
-DLIBYUV_DISABLE_SVE -DLIBYUV_DISABLE_SME -DLIBYUV_DISABLE_LSX 
-DLIBYUV_DISABLE_LASX -DBLINK_IMPLEMENTATION=1 -DINSIDE_BLINK 
-DABSL_CONSUME_DLL -DABSL_FLAGS_STRIP_NAMES=0 
-DCR_CXX_INCLUDE=\"third_party/rust/chromium_crates_io/vendor/cxx-1.0.128/include/cxx.h\"
 -DBORINGSSL_SHARED_LIBRARY -DU_USING_ICU_NAMESPACE=0 -DU_ENABLE_DYLOAD=0 
-DUSE_CHROMIUM_ICU=1 -DU_ENABLE_TRACING=1 -DU_ENABLE_RESOURCE_TRACING=0 
-DICU_UTIL_DATA_IMPL=ICU_UTIL_DATA_FILE -DGOOGLE_PROTOBUF_NO_RTTI 
-DGOOGLE_PROTOBUF_NO_STATIC_INITIALIZER 
-DGOOGLE_PROTOBUF_INTERNAL_DONATE_STEAL_INLINE=0 -DHAVE_PTHREAD 
-DPROTOBUF_USE_DLLS -DWEBRTC_ENABLE_SYMBOL_EXPORT -DWEBRTC_ENABLE_AVX2 
-DWEBRTC_CHROMIUM_BUILD -DWEBRTC_POSIX -DWEBRTC_MAC -DABSL_ALLOCATOR_NOTHROW=1 
-DLOGGING_INSIDE_WEBRTC -DWGPU_SHARED_LIBRARY -DUSING_V8_SHARED 
-DUSING_V8_SHARED_PRIVATE -DV8_ARRAY_BUFFER_INTERNAL_FIELD_COUNT=0 
-DV8_ARRAY_BUFFER_VIEW_INTERNAL_FIELD_COUNT=0 
-DV8_PROMISE_INTERNAL_FIELD_COUNT=0 -DV8_COMPRESS_POINTERS 
-DV8_COMPRESS_POINTERS_IN_SHARED_CAGE -DV8_31BIT_SMIS_ON_64BIT_ARCH 
-DV8_ENABLE_SANDBOX -DV8_DEPRECATION_WARNINGS -DV8_USE_PERFETTO 
-DV8_HAVE_TARGET_OS -DV8_TARGET_OS_MACOS -DCPPGC_CAGED_HEAP 
-DCPPGC_YOUNG_GENERATION -DCPPGC_POINTER_COMPRESSION -DCPPGC_ENABLE_LARGER_CAGE 
-DCPPGC_SLIM_WRITE_BARRIER -DLEVELDB_PLATFORM_CHROMIUM=1 
-DLEVELDB_SHARED_LIBRARY -DCRASHPAD_ZLIB_SOURCE_EXTERNAL -DUSE_LIBJPEG_TURBO=1 
-DMANGLE_JPEG_NAMES -DWEBP_EXTERN=extern -DUSING_V8_BASE_SHARED 
-DUSING_V8_PLATFORM_SHARED -DLIBXSLT_STATIC -I../.. -Igen 
-I../../buildtools/third_party/libc++ -I../../third_party/perfetto/include 
-Igen/third_party/perfetto/build_config -Igen/third_party/perfetto 
-I../../third_party/skia -Igen/third_party/skia 
-I../../third_party/wuffs/src/release/c -Igen/third_party/dawn/include 
-I../../third_party/dawn/include -I../../third_party/khronos -I../../gpu 
-I../../net/third_party/quiche/overrides 
-I../../net/third_party/quiche/src/quiche/common/platform/default 
-I../../net/third_party/quiche/src -I../../third_party/libyuv/include 
-I../../base/allocator/partition_allocator/src 
-Igen/base/allocator/partition_allocator/src -I../../third_party/abseil-cpp 
-I../../third_party/boringssl/src/include -I../../third_party/protobuf/src 
-Igen/protoc_out -I../../third_party/ipcz/include -I../../third_party/ced/src 
-I../../third_party/icu/source/common -I../../third_party/icu/source/i18n 
-Igen/net/third_party/quiche/src -I../../third_party/webrtc_overrides 
-I../../third_party/webrtc -Igen/third_party/webrtc -I../../v8/include 
-I../../third_party/libwebm/source -I../../third_party/angle/include 
-I../../third_party/mesa_headers -I../../third_party/leveldatabase 
-I../../third_party/leveldatabase/src 
-I../../third_party/leveldatabase/src/include 
-I../../third_party/crashpad/crashpad 
-I../../third_party/crashpad/crashpad/compat/mac 
-I../../third_party/crashpad/crashpad/compat/non_win -I../../third_party/zlib 
-I../../third_party/libaom/source/libaom 
-I../../third_party/libaom/source/config/linux/x64 
-I../../third_party/libjpeg_turbo -

[clang] [clang] Respect the lifetimebound in assignment operator. (PR #106997)

2024-09-05 Thread Arthur Eubanks via cfe-commits


@@ -326,24 +326,11 @@ static bool shouldTrackFirstArgument(const FunctionDecl 
*FD) {
   return false;
 }
 
-static bool implicitObjectParamIsLifetimeBound(const FunctionDecl *FD) {
-  const TypeSourceInfo *TSI = FD->getTypeSourceInfo();
-  if (!TSI)
-return false;
-  // Don't declare this variable in the second operand of the for-statement;
-  // GCC miscompiles that by ending its lifetime before evaluating the
-  // third operand. See gcc.gnu.org/PR86769.
-  AttributedTypeLoc ATL;
-  for (TypeLoc TL = TSI->getTypeLoc();
-   (ATL = TL.getAsAdjusted());
-   TL = ATL.getModifiedLoc()) {
-if (ATL.getAttrAs())
-  return true;
-  }
-
-  // Assume that all assignment operators with a "normal" return type return
-  // *this, that is, an lvalue reference that is the same type as the implicit
-  // object parameter (or the LHS for a non-member operator$=).
+// Return true if this is an "normal" assignment operator.
+// We assuments that a normal assingment operator always returns *this, that 
is,
+// an lvalue reference that is the same type as the implicit object parameter
+// (or the LHS for a non-member operator$=).
+static bool isNormalAsisgnmentOperator(const FunctionDecl *FD) {

aeubanks wrote:

nit: "Assignment" is spelled incorrectly here and also below

https://github.com/llvm/llvm-project/pull/106997
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [-Wunsafe-buffer-usage] Warning Libc functions (PR #101583)

2024-09-04 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

There needs to be a flag to opt out of this to not break everybody who is 
currently using unsafe-buffer-usage. #105383 seems to do that, but it really 
should be in this same PR. Can this be reverted and relanded with the flag?

https://github.com/llvm/llvm-project/pull/101583
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PGO][Pipeline] Enable PGOForceFunctionAttrs in PGO optimization pipelines (PR #106790)

2024-09-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks closed 
https://github.com/llvm/llvm-project/pull/106790
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [PGO][Pipeline] Enable PGOForceFunctionAttrs in PGO optimization pipelines (PR #106790)

2024-09-03 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks updated 
https://github.com/llvm/llvm-project/pull/106790

>From a469c523921c3bcb3a8e2a6ad5eaa856a6035449 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Fri, 30 Aug 2024 20:14:18 +
Subject: [PATCH 1/2] [PGO][Pipeline] Enable PGOForceFunctionAttrs in PGO
 optimization pipelines

Remove flag that turns on the PGOForceFunctionAttrs pass and always add it to 
default pipelines when using PGO.

This is NFC by default since PGOOpt->ColdOptType is by default 
ColdFuncOpt::Default.

Remove -O2 RUN line in basic.ll since we now have the pipeline tests.
---
 llvm/lib/Passes/PassBuilderPipelines.cpp | 9 ++---
 llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll | 1 -
 .../Other/new-pm-thinlto-postlink-samplepgo-defaults.ll  | 1 +
 llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll   | 1 +
 .../Other/new-pm-thinlto-prelink-samplepgo-defaults.ll   | 1 +
 5 files changed, 5 insertions(+), 8 deletions(-)

diff --git a/llvm/lib/Passes/PassBuilderPipelines.cpp 
b/llvm/lib/Passes/PassBuilderPipelines.cpp
index 9c3d49cabbd38c..1fd7ef929c87d5 100644
--- a/llvm/lib/Passes/PassBuilderPipelines.cpp
+++ b/llvm/lib/Passes/PassBuilderPipelines.cpp
@@ -227,12 +227,6 @@ static cl::opt
cl::desc("Enable DFA jump threading"),
cl::init(false), cl::Hidden);
 
-// TODO: turn on and remove flag
-static cl::opt EnablePGOForceFunctionAttrs(
-"enable-pgo-force-function-attrs",
-cl::desc("Enable pass to set function attributes based on PGO profiles"),
-cl::init(false));
-
 static cl::opt
 EnableHotColdSplit("hot-cold-split",
cl::desc("Enable hot-cold splitting pass"));
@@ -1222,7 +1216,8 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   if (EnableSyntheticCounts && !PGOOpt)
 MPM.addPass(SyntheticCountsPropagation());
 
-  if (EnablePGOForceFunctionAttrs && PGOOpt)
+  if (PGOOpt && (PGOOpt->Action == PGOOptions::IRUse ||
+ PGOOpt->Action == PGOOptions::SampleUse))
 MPM.addPass(PGOForceFunctionAttrsPass(PGOOpt->ColdOptType));
 
   MPM.addPass(AlwaysInlinerPass(/*InsertLifetimeIntrinsics=*/true));
diff --git a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll 
b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
index 55bdb2f69ad16a..bc966f39fda148 100644
--- a/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
+++ b/llvm/test/Instrumentation/PGOForceFunctionAttrs/basic.ll
@@ -5,7 +5,6 @@
 
 ; Should be no changes without profile data
 ; RUN: opt < %s -passes=pgo-force-function-attrs   
   -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=NONE,CHECK
-; RUN: opt < %s -passes='default' -enable-pgo-force-function-attrs 
   -S -pgo-cold-func-opt=minsize | FileCheck %s --check-prefixes=O2
 
 ; NONE-NOT: Function Attrs:
 ; OPTSIZE: Function Attrs: optsize{{$}}
diff --git a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
index e5aebc4850e6db..9c2025f7d1ec39 100644
--- a/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-postlink-samplepgo-defaults.ll
@@ -59,6 +59,7 @@
 ; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo
 
+; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
 ; CHECK-O-NEXT: Running pass: ModuleInlinerWrapperPass
 ; CHECK-O-NEXT: Running analysis: InlineAdvisorAnalysis
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
index cb49cbd22d60c0..c5fc4d57539c5f 100644
--- a/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-prelink-pgo-defaults.ll
@@ -84,6 +84,7 @@
 ; CHECK-O-NEXT: Running pass: PGOIndirectCallPromotion on
 ; CHECK-O-NEXT: Running analysis: InnerAnalysisManagerProxy
 ; CHECK-O-NEXT: Running analysis: OptimizationRemarkEmitterAnalysis on foo
+; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
 ; CHECK-O-NEXT: Running pass: ModuleInlinerWrapperPass
 ; CHECK-O-NEXT: Running analysis: InlineAdvisorAnalysis
diff --git a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll 
b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
index 96e83493504426..096110f775b04f 100644
--- a/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
+++ b/llvm/test/Other/new-pm-thinlto-prelink-samplepgo-defaults.ll
@@ -64,6 +64,7 @@
 ; CHECK-O-NEXT: Running analysis: LoopAnalysis on foo
 ; CHECK-O-NEXT: Running analysis: PostDominatorTreeAnalysis on foo
 ; CHECK-O-NEXT: Running pass: SimplifyCFGPass on foo
+; CHECK-O-NEXT: Running pass: PGOForceFunctionAttrsPass
 ; CHECK-O-NEXT: Running pass: AlwaysInlinerPass
 ; CHECK-O-NEXT: Running pass: 

[clang] [flang] [llvm] [mlir] Make MMIWP not have ownership over MMI + Remove Move Constructor of MMI + Make MMI Only Use and Externally-Created MCContext (PR #105541)

2024-08-28 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

I'm just back from vacation, taking a look

looks like this has merge conflicts

could you simplify the commit title (maybe move some details into the 
description)

https://github.com/llvm/llvm-project/pull/105541
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [inline] Clone return range attribute on the callsite into inlined call (PR #92666)

2024-06-17 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

for future reference, 
https://github.com/llvm/llvm-project/commit/3cd67eeca28ab1084d02b7976de1af4c4c8d37d5
 fixes a miscompile that this patch uncovered

https://github.com/llvm/llvm-project/pull/92666
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [analyzer] Refine invalidation caused by `fread` (PR #93408)

2024-06-13 Thread Arthur Eubanks via cfe-commits


@@ -907,6 +945,76 @@ void StreamChecker::preWrite(const FnDescription *Desc, 
const CallEvent &Call,
   C.addTransition(State);
 }
 
+static std::optional getPointeeType(const MemRegion *R) {
+  if (!R)
+return std::nullopt;
+  if (const auto *ER = dyn_cast(R))
+return ER->getElementType();
+  if (const auto *TR = dyn_cast(R))
+return TR->getValueType();
+  if (const auto *SR = dyn_cast(R))
+return SR->getPointeeStaticType();
+  return std::nullopt;
+}
+
+static std::optional getStartIndex(SValBuilder &SVB,
+   const MemRegion *R) {
+  if (!R)
+return std::nullopt;
+
+  auto Zero = [&SVB] {
+BasicValueFactory &BVF = SVB.getBasicValueFactory();
+return nonloc::ConcreteInt(BVF.getIntValue(0, /*isUnsigned=*/false));
+  };
+
+  if (const auto *ER = dyn_cast(R))
+return ER->getIndex();
+  if (const auto *TR = dyn_cast(R))

aeubanks wrote:

unused variable (and ditto below), please use `isa<>`

https://github.com/llvm/llvm-project/pull/93408
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-13 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

@alexey-bataev 

https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

SLPVectorizer can introduce `llvm.tan.v2f32`. For example, running `opt -O3` on 
the following introduces `llvm.tan.v2f32`
```
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7-unknown-linux-android26"

; Function Attrs: null_pointer_is_valid
define void @foo() #0 {
bb:
  %call = call float @pluto(float 1.00e+00)
  %call1 = call i1 @ham(float %call)
  %call2 = call float @pluto(float 0.00e+00)
  %call3 = call i1 @ham(float %call2)
  %select = select i1 %call3, float 0.00e+00, float 1.00e+00
  %select4 = select i1 %call1, float 0.00e+00, float 1.00e+00
  store float %select, ptr null, align 4
  %call5 = call ptr null(ptr null, float %select4, float 0.00e+00, float 
0.00e+00, float 0.00e+00)
  ret void
}

define float @pluto(float %arg) {
bb:
  %call = call float @llvm.tan.f32(float %arg)
  ret float %call
}

define i1 @ham(float %arg) {
bb:
  %fcmp = fcmp ole float %arg, 0.00e+00
  ret i1 %fcmp
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn 
memory(none)
declare float @llvm.tan.f32(float) #1

attributes #0 = { null_pointer_is_valid }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn 
memory(none) }
```

https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

> @aeubanks I'll revert. Is this example C or C++?

C++

https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

reduced:
```
struct Lock {};
struct A {
Lock lock;
union {
bool b __attribute__((guarded_by(lock)));
};
};
```

seems like a regression, can we revert for now?

https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Support [[guarded_by(mutex)]] attribute inside C struct (PR #94216)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

this seems to have broken code like 
[this](https://crsrc.org/c/base/allocator/partition_allocator/src/partition_alloc/random.cc;drc=36293863bf9bbc8131797eb8f4d2bafe8af3de79;l=33)
 with
```
../../base/allocator/partition_allocator/src/partition_alloc/random.cc:33:69: 
error: invalid use of non-static data member 'lock_'
   33 | internal::base::InsecureRandomGenerator instance_ 
PA_GUARDED_BY(lock_);
  | 
^
../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:59:70:
 note: expanded from macro 'PA_GUARDED_BY'
   59 | #define PA_GUARDED_BY(x) PA_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
  |  ^
../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:44:60:
 note: expanded from macro 'PA_THREAD_ANNOTATION_ATTRIBUTE__'
   44 | #define PA_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
  |^
../../base/allocator/partition_allocator/src/partition_alloc/random.cc:35:65: 
error: invalid use of non-static data member 'lock_'
   35 | internal::base::InsecureRandomGenerator)] PA_GUARDED_BY(lock_) 
= {};
  | ^
../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:59:70:
 note: expanded from macro 'PA_GUARDED_BY'
   59 | #define PA_GUARDED_BY(x) PA_THREAD_ANNOTATION_ATTRIBUTE__(guarded_by(x))
  |  ^
../../base/allocator/partition_allocator/src/partition_alloc/partition_alloc_base/thread_annotations.h:44:60:
 note: expanded from macro 'PA_THREAD_ANNOTATION_ATTRIBUTE__'
   44 | #define PA_THREAD_ANNOTATION_ATTRIBUTE__(x) __attribute__((x))
  |^
```

is that intentional?

https://github.com/llvm/llvm-project/pull/94216
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

This was with `-DLLVM_ENABLE_LLD=ON`, so probably not? I'm guessing there's 
some CMake logic that doesn't fit with clang-repl's expectation of symbol 
availability, but that may be wrong.

https://github.com/llvm/llvm-project/pull/89811
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang] Reland Add tanf16 builtin and support for tan constrained intrinsic (PR #94559)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

I believe this has exposed a preexisting issue in isel with tan:

```
$ cat /tmp/b.ll
target datalayout = "e-m:e-p:32:32-Fi8-i64:64-v128:64:128-a:0:32-n32-S64"
target triple = "thumbv7-unknown-linux-android26"

define <2 x float> @g() {
entry:
  %0 = call <2 x float> @llvm.tan.v2f32(<2 x float> zeroinitializer)
  ret <2 x float> %0
}
$ llc /tmp/b.ll -o /dev/null
LLVM ERROR: Cannot select: t3: v2f32 = ftan t15 


   
  t15: v2f32 = bitcast t14  


   
t14: v2i32 = ARMISD::VMOVIMM TargetConstant:i32<0>  
 
  t13: i32 = TargetConstant<0>  


   
```

https://github.com/llvm/llvm-project/pull/94559
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang-repl] Lay the foundation of pretty printing for C. (PR #89811)

2024-06-12 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

So actually even the `export_executable_symbols_for_plugins` doesn't fix our 
bots. I've narrowed it down to `-DLLVM_ENABLE_PIC=ON/OFF`. Perhaps we're not 
exporting symbols when `-DLLVM_ENABLE_PIC=OFF`.

https://github.com/llvm/llvm-project/pull/89811
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ConstantFold] Drop gep of gep fold entirely (PR #95126)

2024-06-11 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/95126
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-31 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks closed 
https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-31 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

thanks for doing this!

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-31 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ConstantFold] Remove non-trivial gep-of-gep fold (PR #93823)

2024-05-30 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.

this PR looks good, and further dropping the fold is also good

https://github.com/llvm/llvm-project/pull/93823
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-30 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

looks like `CodeGen/AMDGPU/llc-pipeline.ll` is failing

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-30 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [mlir] [ConstantFold] Remove notional over-indexing fold (PR #93697)

2024-05-29 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/93697
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-28 Thread Arthur Eubanks via cfe-commits


@@ -1030,6 +1036,12 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
 MPM.addPass(SampleProfileProbePass(TM));
 
+  // Instrument function entry and exit before all inlining.
+  if (!isLTOPostLink(Phase)) {
+MPM.addPass(createModuleToFunctionPassAdaptor(

aeubanks wrote:

if you have a small local repro, you can pass `-Wl,-mllvm,-print-after-all` to 
the link command to have it print IR after every pass and see where the calls 
are getting added. or to see changes in the pre-link optimization pipeline, 
`-mllvm=-print-after-all` (or `-mllvm=-print-changed=quiet`, which doesn't work 
with the IR parts of the codegen pipeline for *reasons*)

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines (PR #92171)

2024-05-28 Thread Arthur Eubanks via cfe-commits


@@ -1030,6 +1036,12 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
 MPM.addPass(SampleProfileProbePass(TM));
 
+  // Instrument function entry and exit before all inlining.
+  if (!isLTOPostLink(Phase)) {
+MPM.addPass(createModuleToFunctionPassAdaptor(

aeubanks wrote:

the check for `Phase != ThinOrFullLTOPhase::FullLTOPostLink` is unnecessary, 
`buildModuleSimplificationPipeline` isn't called for FullLTO post link

I'm not sure why you're seeing that behavior if we're only running the 
post-inline instrumenter once in the codegen pipeline

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] Run ObjCContractPass in Default Codegen Pipeline (PR #92331)

2024-05-28 Thread Arthur Eubanks via cfe-commits


@@ -31,6 +31,10 @@
 ; CHECK-NEXT:   AArch64 Stack Tagging
 ; CHECK-NEXT:   SME ABI Pass
 ; CHECK-NEXT:   Exception handling preparation
+; CHECK-NEXT:   Dominator Tree Construction
+; CHECK-NEXT:   Basic Alias Analysis (stateless AA impl)
+; CHECK-NEXT:   Function Alias Analysis Results

aeubanks wrote:

this is where having the new pass manager for codegen would be nice

https://github.com/llvm/llvm-project/pull/92331
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1030,6 +1036,12 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
 MPM.addPass(SampleProfileProbePass(TM));
 
+  // Instrument function entry and exit before all inlining.
+  if (!isLTOPostLink(Phase)) {
+MPM.addPass(createModuleToFunctionPassAdaptor(

aeubanks wrote:

actually is it possible to add this into `EarlyFPM` below? it's nice to have 
fewer module->function adaptors. (e.g. in `EarlyFPM` we run all the function 
passes on a single function before moving to the next one which is nice for 
memory locality)

sorry for suggesting this so late, since it'll require updating all the 
pipeline tests... but first check that none of the other tests fail

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1,5 +1,5 @@
 // RUN: %clang_cc1 -triple x86_64-apple-darwin10 -debug-info-kind=standalone 
-emit-llvm -o - %s -finstrument-functions | FileCheck %s

aeubanks wrote:

this should also not be testing the pass and should have -disable-llvm-passes

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

looks pretty good, can you update the commit title to something like 
`[EntryExitInstrumenter] Move passes out of clang into LLVM default pipelines`

I've added test coverage for mcount-aix in 
3ec57a7ed60a19c5e3e18655e19c997a469d10ec, can you merge that in?

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1,25 +1,13 @@
 // RUN: %clang_cc1 -pg -triple powerpc-ibm-aix7.2.0.0 -emit-llvm %s -o - | 
FileCheck %s

aeubanks wrote:

also -disable-llvm-passes here

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1,37 +1,27 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O0 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O2 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O0 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O2 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
 
 __attribute__((always_inline)) int leaf(int x) {
   return x;
 // CHECK-LABEL: define {{.*}} @leaf
-// CHECK: call void @__cyg_profile_func_enter
-// CHECK-NOT: cyg_profile
-// CHECK: call void @__cyg_profile_func_exit
 // CHECK-NOT: cyg_profile
 // CHECK: ret
 }
 
 int root(int x) {
   return leaf(x);
 // CHECK-LABEL: define {{.*}} @root
-// CHECK: call void @__cyg_profile_func_enter
-// CHECK-NOT: cyg_profile
-
-// Inlined from leaf():
-// CHECK: call void @__cyg_profile_func_enter
-// CHECK-NOT: cyg_profile
-// CHECK: call void @__cyg_profile_func_exit
 // CHECK-NOT: cyg_profile
-
-// CHECK: call void @__cyg_profile_func_exit
 // CHECK: ret
 
 // NOINLINE-LABEL: define {{.*}} @root
-// NOINLINE: call void @__cyg_profile_func_enter
-// NOINLINE-NOT: cyg_profile
-// NOINLINE: call void @__cyg_profile_func_exit
 // NOINLINE-NOT: cyg_profile
 // NOINLINE: ret
 }
+
+// CHECK: attributes #0 = { alwaysinline {{.*}} 
"instrument-function-entry"="__cyg_profile_func_enter" 
"instrument-function-exit"="__cyg_profile_func_exit"
+// CHECK: attributes #1 = { {{.*}} 
"instrument-function-entry"="__cyg_profile_func_enter" 
"instrument-function-exit"="__cyg_profile_func_exit"
+// NOINLINE: attributes #0 = { alwaysinline {{.*}} 
"instrument-function-entry-inlined"="__cyg_profile_func_enter" 
"instrument-function-exit-inlined"="__cyg_profile_func_exit"

aeubanks wrote:

drop the `alwaysinline` check since that's not relevant (we can also remove it 
from the source), and check ` { {{.*}}"instrument-function-entry"=...` in case 
`"instrument-function-entry"` is the first attribute in the group and there's 
only one space before it

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1,37 +1,27 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O0 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O2 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O0 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O2 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
 
 __attribute__((always_inline)) int leaf(int x) {
   return x;
 // CHECK-LABEL: define {{.*}} @leaf
-// CHECK: call void @__cyg_profile_func_enter
-// CHECK-NOT: cyg_profile
-// CHECK: call void @__cyg_profile_func_exit
 // CHECK-NOT: cyg_profile

aeubanks wrote:

no need to CHECK the IR here

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

forgot to hit "submit review"...

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-24 Thread Arthur Eubanks via cfe-commits


@@ -1,37 +1,27 @@
 // REQUIRES: x86-registered-target
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O0 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown -finstrument-functions -O2 
-o - -emit-llvm %s | FileCheck %s
-// RUN: %clang_cc1 -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O0 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions -O2 -o - -emit-llvm %s | FileCheck %s
+// RUN: %clang_cc1 -disable-llvm-passes -triple x86_64-unknown-unknown 
-finstrument-functions-after-inlining -O2 -o - -emit-llvm %s | FileCheck 
-check-prefix=NOINLINE %s
 
 __attribute__((always_inline)) int leaf(int x) {
   return x;
 // CHECK-LABEL: define {{.*}} @leaf

aeubanks wrote:

check `#0` here

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-22 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,29 @@
+; RUN: llc -mtriple=x86_64-- -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-- -O1 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-- -O2 < %s | FileCheck %s
+
+; The codegen should insert post-inlining instrumentation calls and should not
+; insert pre-inlining instrumentation.
+
+; CHECK-NOT:   callq __cyg_profile_func_enter
+
+define void @leaf_function() #0 {
+; CHECK-LABEL: leaf_function:
+; CHECK:   callq __cyg_profile_func_enter_bare
+; CHECK:   movqleaf_function@GOTPCREL(%rip), %rdi

aeubanks wrote:

checking the specifics of how the function is called shouldn't be in this test 
that tests the pipeline, the point of this test is just a quick end-to-end test 
testing we inserted instrumentation. if we want to test this we should have a 
separate test focused on the exact instruction sequence. but I don't think we 
need to add that test coverage in this PR

so I'd remove the `%rdi` CHECK line

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-22 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,44 @@
+; RUN: opt -passes="default" -S < %s | FileCheck -check-prefix=PRELTO %s
+; RUN: opt -passes="default" -S < %s | FileCheck -check-prefix=PRELTO %s
+; RUN: opt -passes="thinlto-pre-link,thinlto" -S < %s | FileCheck 
-check-prefix=PRELTO %s
+; RUN: opt -passes="thinlto-pre-link" -S < %s | FileCheck 
-check-prefix=PRELTO %s
+; RUN: opt -passes="thinlto" -S < %s | FileCheck -check-prefix=LTO %s
+; RUN: opt -passes="lto" -S < %s | FileCheck -check-prefix=LTO %s
+
+; Pre-inline instrumentation should be inserted, but not by LTO/ThinLTO passes.
+
+target triple = "x86_64-unknown-linux"
+
+define void @leaf_function() #0 {
+entry:
+  ret void
+; PRELTO-LABEL: entry:
+; PRELTO-NEXT:  %0 ={{( tail)?}} call ptr @llvm.returnaddress(i32 0)

aeubanks wrote:

no need to add `{{( tail)?}}` if it's at the very beginning. for this specific 
CHECK line I'd simplify to `{{.*}}`

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-22 Thread Arthur Eubanks via cfe-commits


@@ -1,41 +0,0 @@
-// REQUIRES: arm-registered-target,aarch64-registered-target
-
-// RUN: %clang -target armv7-unknown-none-eabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang -target armv7-unknown-none-eabi -pg -meabi gnu -S -emit-llvm -o 
- %s | FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang --target=aarch64-unknown-none-gnu -pg -S -emit-llvm -o - %s | 
FileCheck %s --check-prefixes=CHECK,MCOUNT
-// RUN: %clang -target armv7-unknown-linux-gnueabi -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
-// RUN: %clang -target armv7-unknown-linux-gnueabi -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang --target=aarch64-unknown-linux -pg -S -emit-llvm -o - %s | 
FileCheck %s --check-prefixes=CHECK,UNDER
-// RUN: %clang -target armv7-unknown-linux-gnueabihf -pg -S -emit-llvm -o - %s 
| FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM-EABI
-// RUN: %clang -target armv7-unknown-linux-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix 
CHECK-ARM-EABI-MEABI-GNU
-// RUN: %clang -target armv7-unknown-freebsd-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s --check-prefixes=CHECK,UNDER_UNDER
-// RUN: %clang -target armv7-unknown-freebsd-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,UNDER_UNDER
-// RUN: %clang --target=aarch64-unknown-freebsd -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix CHECK-ARM64-EABI-FREEBSD
-// RUN: %clang -target armv7-unknown-openbsd-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s -check-prefix CHECK -check-prefix UNDER_UNDER
-// RUN: %clang -target armv7-unknown-openbsd-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s -check-prefix CHECK -check-prefix UNDER_UNDER
-// RUN: %clang --target=aarch64-unknown-openbsd -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefix CHECK -check-prefix UNDER_UNDER
-// RUN: %clang -target armv7-unknown-netbsd-gnueabihf -pg -S -emit-llvm -o - 
%s | FileCheck %s --check-prefixes=CHECK,UNDER_UNDER
-// RUN: %clang -target armv7-unknown-netbsd-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,UNDER_UNDER
-// RUN: %clang --target=aarch64-unknown-netbsd -pg -S -emit-llvm -o - %s | 
FileCheck %s --check-prefixes=CHECK,UNDER_UNDER
-// RUN: %clang -target armv7-apple-ios -pg -S -emit-llvm -o - %s | FileCheck 
%s --check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang -target armv7-apple-ios -pg -meabi gnu -S -emit-llvm -o - %s | 
FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang -target arm64-apple-ios -pg -S -emit-llvm -o - %s | FileCheck 
%s --check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang -target arm64-apple-ios -pg -meabi gnu -S -emit-llvm -o - %s | 
FileCheck %s --check-prefixes=CHECK,UNSUPPORTED
-// RUN: %clang -target armv7-unknown-rtems-gnueabihf -pg -S -emit-llvm -o - %s 
| FileCheck %s --check-prefixes=CHECK,MCOUNT
-// RUN: %clang -target armv7-unknown-rtems-gnueabihf -meabi gnu -pg -S 
-emit-llvm -o - %s | FileCheck %s --check-prefixes=CHECK,MCOUNT
-// RUN: %clang --target=aarch64-unknown-rtems -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefixes=CHECK,MCOUNT
-// RUN: %clang --target=aarch64-unknown-rtems -pg -S -emit-llvm -o - %s | 
FileCheck %s -check-prefixes=CHECK,MCOUNT
-
-int f() {
-  return 0;
-}
-
-// CHECK-LABEL: f
-// TODO: add profiling support for arm-baremetal

aeubanks wrote:

we should keep both these tests you're deleting to ensure that we're emitting 
the correct function attributes. add `-Xclang -disable-llvm-passes` to the 
clang invocations to not run any passes and check the function attributes.

this test is important to check that we're calling the correct `mcount`, and 
the other test is important to test that 
`-finstrument-functions-after-inlining` is emitting the correct function 
attribute (that test is the only instance of 
`-finstrument-functions-after-inlining`)

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-22 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,44 @@
+; RUN: opt -passes="default" -S < %s | FileCheck -check-prefix=PRELTO %s

aeubanks wrote:

`PRELTO` isn't quite accurate since we also instrument in the default 
pipelines, I'd use `INSTRUMENT`/`NOINSTRUMENT` or even just `YES`/`NO` :)

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-22 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,44 @@
+; RUN: opt -passes="default" -S < %s | FileCheck -check-prefix=PRELTO %s
+; RUN: opt -passes="default" -S < %s | FileCheck -check-prefix=PRELTO %s
+; RUN: opt -passes="thinlto-pre-link,thinlto" -S < %s | FileCheck 
-check-prefix=PRELTO %s

aeubanks wrote:

don't run two pipelines in a single `opt` invocation, and we need tests for 
`thinlto`/`lto` 

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lldb] [llvm] Remove some `try_compile` CMake checks for compiler flags (PR #92953)

2024-05-21 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.

awesome, thanks!

https://github.com/llvm/llvm-project/pull/92953
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-21 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,29 @@
+; RUN: llc -mtriple=x86_64-- -O0 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-- -O1 < %s | FileCheck %s
+; RUN: llc -mtriple=x86_64-- -O2 < %s | FileCheck %s
+
+; The codegen should insert post-inlining instrumentation calls and should not
+; insert pre-inlining instrumentation.
+
+; CHECK-NOT:   callq __cyg_profile_func_enter
+
+define void @leaf_function() #0 {
+; CHECK-LABEL: leaf_function:
+; CHECK:   callq __cyg_profile_func_enter_bare
+; CHECK:   movqleaf_function@GOTPCREL(%rip), %rdi

aeubanks wrote:

probably don't need this CHECK line, it just makes the test more brittle

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-21 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,31 @@
+; RUN: opt -passes="default" -S < %s | FileCheck %s
+; RUN: opt -passes="thinlto-pre-link" -S < %s | FileCheck %s
+; RUN: opt -passes="thinlto-pre-link,thinlto" -S < %s | FileCheck %s
+
+target triple = "x86_64-unknown-linux"
+
+define void @leaf_function() #0 {

aeubanks wrote:

mark this function as `alwaysinline` so testing `-O0` works

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-21 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,31 @@
+; RUN: opt -passes="default" -S < %s | FileCheck %s

aeubanks wrote:

should also test `O0` versions of these, plus `lto-pre-link`

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-21 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,31 @@
+; RUN: opt -passes="default" -S < %s | FileCheck %s
+; RUN: opt -passes="thinlto-pre-link" -S < %s | FileCheck %s
+; RUN: opt -passes="thinlto-pre-link,thinlto" -S < %s | FileCheck %s

aeubanks wrote:

no need to run `thinlto` here, but we should test that `thinlto`/`lto` 
don't run this pass by adding different RUN lines with a different `FileCheck 
%s --checkprefix=NO`

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [lld] [llvm] Run ObjCContractPass in Distributed Thin-LTO Pipeline (PR #92331)

2024-05-17 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

it seems like this should just be in the default codegen pipeline? you'd need 
to change the pass to bail out early if there are no relevant intrinsics (by 
checking if the module contains the intrinsic declaration) to not affect 
compile times

https://github.com/llvm/llvm-project/pull/92331
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)

2024-05-16 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.

we've resolved the performance regression from the previous patch internally, 
thanks for waiting!

https://github.com/llvm/llvm-project/pull/89872
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Add getelementptr nusw and nuw flags (PR #90824)

2024-05-15 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,86 @@
+//===-- llvm/GEPNoWrapFlags.h - NoWrap flags for GEPs ---*- 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
+//
+//===--===//
+//
+// This file defines the nowrap flags for getelementptr operators.
+//
+//===--===//
+
+#ifndef LLVM_IR_GEPNOWRAPFLAGS_H
+#define LLVM_IR_GEPNOWRAPFLAGS_H
+
+namespace llvm {
+
+class GEPNoWrapFlags {
+  enum : unsigned{
+InBoundsFlag = (1 << 0),
+NUSWFlag = (1 << 1),
+NUWFlag = (1 << 2),
+  };
+
+  unsigned Flags;
+  GEPNoWrapFlags(unsigned Flags) : Flags(Flags) {
+assert((!isInBounds() || hasNoUnsignedSignedWrap()) &&
+   "inbounds implies nusw");
+  }
+
+public:
+  GEPNoWrapFlags() : Flags(0) {}
+  // For historical reasons, interpret plain boolean as InBounds.

aeubanks wrote:

TODO: remove?

https://github.com/llvm/llvm-project/pull/90824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Add getelementptr nusw and nuw flags (PR #90824)

2024-05-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.

thanks, I think abstracting out GEPNoWrapFlags is good

https://github.com/llvm/llvm-project/pull/90824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Add getelementptr nusw and nuw flags (PR #90824)

2024-05-15 Thread Arthur Eubanks via cfe-commits


@@ -0,0 +1,86 @@
+//===-- llvm/GEPNoWrapFlags.h - NoWrap flags for GEPs ---*- 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
+//
+//===--===//
+//
+// This file defines the nowrap flags for getelementptr operators.
+//
+//===--===//
+
+#ifndef LLVM_IR_GEPNOWRAPFLAGS_H
+#define LLVM_IR_GEPNOWRAPFLAGS_H
+
+namespace llvm {
+
+class GEPNoWrapFlags {
+  enum : unsigned{

aeubanks wrote:

clang-format

https://github.com/llvm/llvm-project/pull/90824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [IR] Add getelementptr nusw and nuw flags (PR #90824)

2024-05-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/90824
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-15 Thread Arthur Eubanks via cfe-commits


@@ -1028,6 +1029,14 @@ 
PassBuilder::buildModuleSimplificationPipeline(OptimizationLevel Level,
   Phase != ThinOrFullLTOPhase::ThinLTOPostLink)
 MPM.addPass(SampleProfileProbePass(TM));
 
+  // Instrument function entry and exit before all inlining.
+  if (Phase != ThinOrFullLTOPhase::ThinLTOPostLink &&
+  Phase != ThinOrFullLTOPhase::FullLTOPostLink &&
+  Phase != ThinOrFullLTOPhase::None) {

aeubanks wrote:

we need this pass when `Phase == ThinOrFullLTOPhase::None` right?

I'd extract out `isLTOPostLink` to mirror the existing `isLTOPreLink`

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks commented:

looks pretty good to me

for testing the pre-inliner one, we should add some tests in 
`llvm/test/Transforms/EntryExitInstrumenter/` that invoke things like `opt 
-passes='default'`, `opt -passes='thinlto-pre-link'`, `opt 
-passes='thinlto'` to make sure that the pass did/didn't insert the call 
given some IR with the appropriate function attribute

for testing the post-inliner one, an `llc` x86-64 test that checks that a call 
to the function was generated in the assembly given some IR with the 
appropriate function attribute is enough

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-15 Thread Arthur Eubanks via cfe-commits


@@ -101,6 +101,7 @@ void initializeEarlyMachineLICMPass(PassRegistry&);
 void initializeEarlyTailDuplicatePass(PassRegistry&);
 void initializeEdgeBundlesPass(PassRegistry&);
 void initializeEHContGuardCatchretPass(PassRegistry &);
+void initializeEntryExitInstrumenterPass(PassRegistry&);

aeubanks wrote:

not necessary

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-14 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

can you add links to https://reviews.llvm.org/D97608, 
https://github.com/rust-lang/rust/issues/92109, 
https://github.com/llvm/llvm-project/issues/52853

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-14 Thread Arthur Eubanks via cfe-commits


@@ -135,6 +138,65 @@ static bool runOnFunction(Function &F, bool PostInlining) {
   return Changed;
 }
 
+namespace {
+struct EntryExitInstrumenter : public FunctionPass {
+  static char ID;
+  EntryExitInstrumenter() : FunctionPass(ID) {
+initializeEntryExitInstrumenterPass(*PassRegistry::getPassRegistry());
+  }
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+AU.addPreserved();
+AU.addPreserved();
+  }
+  bool runOnFunction(Function &F) override { return ::runOnFunction(F, false); 
}
+};
+char EntryExitInstrumenter::ID = 0;
+
+struct PostInlineEntryExitInstrumenter : public FunctionPass {
+  static char ID;
+  PostInlineEntryExitInstrumenter() : FunctionPass(ID) {
+initializePostInlineEntryExitInstrumenterPass(
+*PassRegistry::getPassRegistry());
+  }
+  void getAnalysisUsage(AnalysisUsage &AU) const override {
+AU.addPreserved();
+AU.addPreserved();
+  }
+  bool runOnFunction(Function &F) override { return ::runOnFunction(F, true); }
+};
+char PostInlineEntryExitInstrumenter::ID = 0;
+}
+
+INITIALIZE_PASS_BEGIN(
+EntryExitInstrumenter, "ee-instrument",
+"Instrument function entry/exit with calls to e.g. mcount() (pre 
inlining)",
+false, false)
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
+INITIALIZE_PASS_END(
+EntryExitInstrumenter, "ee-instrument",
+"Instrument function entry/exit with calls to e.g. mcount() (pre 
inlining)",
+false, false)
+
+INITIALIZE_PASS_BEGIN(
+PostInlineEntryExitInstrumenter, "post-inline-ee-instrument",
+"Instrument function entry/exit with calls to e.g. mcount() "
+"(post inlining)",
+false, false)
+INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
+INITIALIZE_PASS_END(
+PostInlineEntryExitInstrumenter, "post-inline-ee-instrument",
+"Instrument function entry/exit with calls to e.g. mcount() "
+"(post inlining)",
+false, false)
+
+FunctionPass *llvm::createEntryExitInstrumenterPass() {

aeubanks wrote:

we don't need this one since we're adding it in the optimization pipeline which 
only works with the new pass manager

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-14 Thread Arthur Eubanks via cfe-commits


@@ -670,9 +670,6 @@ void CodeGenPassBuilder::addIRPasses(
   !Opt.DisablePartialLibcallInlining)
 addPass(PartiallyInlineLibCallsPass());
 
-  // Instrument function entry and exit, e.g. with calls to mcount().
-  addPass(EntryExitInstrumenterPass(/*PostInlining=*/true));

aeubanks wrote:

don't touch this one, this is the WIP port of the codegen pipeline to the new 
pass manager (and this is actually what we want, that the codegen pipeline does 
this)

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] wip: Move instrumentation passes (PR #92171)

2024-05-14 Thread Arthur Eubanks via cfe-commits


@@ -1016,6 +1000,11 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 if (!IsThinLTOPostLink) {
   addSanitizers(TargetTriple, CodeGenOpts, LangOpts, PB);
   addKCFIPass(TargetTriple, LangOpts, PB);
+  PB.registerPipelineStartEPCallback(

aeubanks wrote:

we should be consistent and make both entry exit instrumenters part of the 
default pipelines, not a clang-specific add-on

this would probably be somewhere in `buildModuleSimplificationPipeline`, 
checking `Phase` (and make sure -O0 works by modifying `buildO0DefaultPipeline`)

https://github.com/llvm/llvm-project/pull/92171
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CodeGen] Revert "Generate assume loads only with -fstrict-vtable-pointers" (PR #91900)

2024-05-13 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

> -fstrict-vtable-pointers IS experimental, but if you recall, this particular 
> optimization was added to -fstrict-vtable-pointers because of the effects it 
> had on compile-time, not because of correctness issues.

can you clarify what you mean by "this particular optimization"? you mean 
adding or not adding assume loads?

when I said "regress", I meant runtime performance, not compile times, I should 
have been clearer

https://github.com/llvm/llvm-project/pull/91900
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [CodeGen] Revert "Generate assume loads only with -fstrict-vtable-pointers" (PR #91900)

2024-05-13 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

adding assumes in general has issues: 
https://discourse.llvm.org/t/llvm-assume-blocks-optimization/71609

do you have proof that this change helps binaries and doesn't regress things? I 
have a feeling this will regress many things. `-fstrict-vtable-pointers` is 
still somewhat experimental

https://github.com/llvm/llvm-project/pull/91900
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] Revert "[Clang][Sema] Fix lookup of dependent operator= outside of complete-class contexts (#91498)" (PR #91620)

2024-05-09 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

should be fine to revert as much as you want in a single PR, just make sure to 
mention what you're reverting in the description

https://github.com/llvm/llvm-project/pull/91620
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Clang][Sema] Fix lookup of dependent operator= outside of complete-class contexts (PR #91498)

2024-05-09 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

Chromium is also seeing similar breakages. @sdkrystian is this breaking valid 
code? I can't tell from your latest comment. (if it is breaking valid code we 
should revert)

https://github.com/llvm/llvm-project/pull/91498
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)

2024-04-28 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

btw we're still looking into a performance regression caused by #68882 that 
still repros with LLVM head, even after the SROA enhancements. this patch looks 
good, but can we hold off a bit on submitting this?

https://github.com/llvm/llvm-project/pull/89872
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [compiler-rt] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)

2024-04-28 Thread Arthur Eubanks via cfe-commits


@@ -944,43 +943,18 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
 return ConstantExpr::getIntToPtr(C, ResTy);
   }
 
-  // Otherwise form a regular getelementptr. Recompute the indices so that
-  // we eliminate over-indexing of the notional static type array bounds.
-  // This makes it easy to determine if the getelementptr is "inbounds".
-
-  // For GEPs of GlobalValues, use the value type, otherwise use an i8 GEP.
-  if (auto *GV = dyn_cast(Ptr))
-SrcElemTy = GV->getValueType();
-  else
-SrcElemTy = Type::getInt8Ty(Ptr->getContext());
-
-  if (!SrcElemTy->isSized())
-return nullptr;
-
-  Type *ElemTy = SrcElemTy;
-  SmallVector Indices = DL.getGEPIndicesForOffset(ElemTy, Offset);
-  if (Offset != 0)
-return nullptr;
-
-  // Try to add additional zero indices to reach the desired result element
-  // type.
-  // TODO: Should we avoid extra zero indices if ResElemTy can't be reached and
-  // we'll have to insert a bitcast anyway?
-  while (ElemTy != ResElemTy) {
-Type *NextTy = GetElementPtrInst::getTypeAtIndex(ElemTy, (uint64_t)0);
-if (!NextTy)
-  break;
-
-Indices.push_back(APInt::getZero(isa(ElemTy) ? 32 : BitWidth));
-ElemTy = NextTy;
+  // Try to infer inbounds for GEPs of globals.
+  if (!InBounds && Offset.isNonNegative()) {

aeubanks wrote:

is there a test for the case where `!Offset.isNonNegative()`?

https://github.com/llvm/llvm-project/pull/89872
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [ConstantFolding] Canonicalize constexpr GEPs to i8 (PR #89872)

2024-04-24 Thread Arthur Eubanks via cfe-commits


@@ -944,43 +943,18 @@ Constant *SymbolicallyEvaluateGEP(const GEPOperator *GEP,
 return ConstantExpr::getIntToPtr(C, ResTy);
   }
 
-  // Otherwise form a regular getelementptr. Recompute the indices so that
-  // we eliminate over-indexing of the notional static type array bounds.
-  // This makes it easy to determine if the getelementptr is "inbounds".
-
-  // For GEPs of GlobalValues, use the value type, otherwise use an i8 GEP.
-  if (auto *GV = dyn_cast(Ptr))
-SrcElemTy = GV->getValueType();
-  else
-SrcElemTy = Type::getInt8Ty(Ptr->getContext());
-
-  if (!SrcElemTy->isSized())
-return nullptr;
-
-  Type *ElemTy = SrcElemTy;
-  SmallVector Indices = DL.getGEPIndicesForOffset(ElemTy, Offset);
-  if (Offset != 0)
-return nullptr;
-
-  // Try to add additional zero indices to reach the desired result element
-  // type.
-  // TODO: Should we avoid extra zero indices if ResElemTy can't be reached and
-  // we'll have to insert a bitcast anyway?
-  while (ElemTy != ResElemTy) {
-Type *NextTy = GetElementPtrInst::getTypeAtIndex(ElemTy, (uint64_t)0);
-if (!NextTy)
-  break;
-
-Indices.push_back(APInt::getZero(isa(ElemTy) ? 32 : BitWidth));
-ElemTy = NextTy;
+  // Try to infer inbounds for GEPs of globals.
+  if (!InBounds && Offset.isNonNegative()) {
+bool CanBeNull, CanBeFreed;
+uint64_t DerefBytes =
+Ptr->getPointerDereferenceableBytes(DL, CanBeNull, CanBeFreed);
+InBounds = DerefBytes != 0 && !CanBeNull && Offset.sle(DerefBytes);

aeubanks wrote:

can we remove the other constant folding?

https://github.com/llvm/llvm-project/pull/89872
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add flag to experiment with cold function attributes (PR #89298)

2024-04-19 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks closed 
https://github.com/llvm/llvm-project/pull/89298
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [clang] Add flag to experiment with cold function attributes (PR #89298)

2024-04-18 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/89298

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

For now, this can be experimented with `-mllvm 
-pgo-cold-func-opt=[optsize|minsize|optnone|default] -mllvm 
-enable-pgo-force-function-attrs`.

Original LLVM patch for this functionality: #69030

>From 1c69510ab5a92998cc443100ecfb551776fc03a0 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Mon, 15 Apr 2024 20:40:43 +
Subject: [PATCH] [clang] Add flag to experiment with cold function attributes

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

For now, this can be experimented with `-mllvm 
-pgo-cold-func-opt=[optsize|minsize|optnone|default] -mllvm 
-enable-pgo-force-function-attrs`.

Original LLVM patch for this functionality: #69030
---
 clang/lib/CodeGen/BackendUtil.cpp | 57 ---
 .../test/CodeGen/pgo-force-function-attrs.ll  | 12 
 2 files changed, 47 insertions(+), 22 deletions(-)
 create mode 100644 clang/test/CodeGen/pgo-force-function-attrs.ll

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6cc00b85664f41..22c3f8642ad8eb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -104,6 +104,21 @@ static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
 cl::desc("Insert sanitizers on OptimizerEarlyEP."));
 
+// Experiment to mark cold functions as optsize/minsize/optnone.
+// TODO: remove once this is exposed as a proper driver flag.
+static cl::opt ClPGOColdFuncAttr(
+"pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), 
cl::Hidden,
+cl::desc(
+"Function attribute to apply to cold functions as determined by PGO"),
+cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
+  "Default (no attribute)"),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
+  "Mark cold functions with optsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
+  "Mark cold functions with minsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
+  "Mark cold functions with optnone.")));
+
 extern cl::opt ProfileCorrelate;
 
 // Re-link builtin bitcodes after optimization
@@ -768,42 +783,41 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
 auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
 : PGOOptions::NoCSAction;
-PGOOpt = PGOOptions(
-CodeGenOpts.ProfileInstrumentUsePath, "",
-CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
+CodeGenOpts.ProfileRemappingFile,
+CodeGenOpts.MemoryProfileUsePath, VFS,
+PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
-PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction,
-  

[clang] [clang] Add flag to experiment with cold function attributes (PR #88793)

2024-04-15 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/88793

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

Original LLVM patch for this functionality: #69030

>From 52cd9974be908bf693832012e56e945e9e34f389 Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Mon, 15 Apr 2024 20:40:43 +
Subject: [PATCH] [clang] Add flag to experiment with cold function attributes

To be removed and promoted to a proper driver flag if experiments turn out 
fruitful.

Original LLVM patch for this functionality: #69030
---
 clang/lib/CodeGen/BackendUtil.cpp | 57 +++
 1 file changed, 35 insertions(+), 22 deletions(-)

diff --git a/clang/lib/CodeGen/BackendUtil.cpp 
b/clang/lib/CodeGen/BackendUtil.cpp
index 6cc00b85664f41..22c3f8642ad8eb 100644
--- a/clang/lib/CodeGen/BackendUtil.cpp
+++ b/clang/lib/CodeGen/BackendUtil.cpp
@@ -104,6 +104,21 @@ static cl::opt ClSanitizeOnOptimizerEarlyEP(
 "sanitizer-early-opt-ep", cl::Optional,
 cl::desc("Insert sanitizers on OptimizerEarlyEP."));
 
+// Experiment to mark cold functions as optsize/minsize/optnone.
+// TODO: remove once this is exposed as a proper driver flag.
+static cl::opt ClPGOColdFuncAttr(
+"pgo-cold-func-opt", cl::init(PGOOptions::ColdFuncOpt::Default), 
cl::Hidden,
+cl::desc(
+"Function attribute to apply to cold functions as determined by PGO"),
+cl::values(clEnumValN(PGOOptions::ColdFuncOpt::Default, "default",
+  "Default (no attribute)"),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptSize, "optsize",
+  "Mark cold functions with optsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::MinSize, "minsize",
+  "Mark cold functions with minsize."),
+   clEnumValN(PGOOptions::ColdFuncOpt::OptNone, "optnone",
+  "Mark cold functions with optnone.")));
+
 extern cl::opt ProfileCorrelate;
 
 // Re-link builtin bitcodes after optimization
@@ -768,42 +783,41 @@ void EmitAssemblyHelper::RunOptimizationPipeline(
 CodeGenOpts.InstrProfileOutput.empty() ? getDefaultProfileGenName()
: 
CodeGenOpts.InstrProfileOutput,
 "", "", CodeGenOpts.MemoryProfileUsePath, nullptr, PGOOptions::IRInstr,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling,
 /*PseudoProbeForProfiling=*/false, CodeGenOpts.AtomicProfileUpdate);
   else if (CodeGenOpts.hasProfileIRUse()) {
 // -fprofile-use.
 auto CSAction = CodeGenOpts.hasProfileCSIRUse() ? PGOOptions::CSIRUse
 : PGOOptions::NoCSAction;
-PGOOpt = PGOOptions(
-CodeGenOpts.ProfileInstrumentUsePath, "",
-CodeGenOpts.ProfileRemappingFile, CodeGenOpts.MemoryProfileUsePath, 
VFS,
-PGOOptions::IRUse, CSAction, PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+PGOOpt = PGOOptions(CodeGenOpts.ProfileInstrumentUsePath, "",
+CodeGenOpts.ProfileRemappingFile,
+CodeGenOpts.MemoryProfileUsePath, VFS,
+PGOOptions::IRUse, CSAction, ClPGOColdFuncAttr,
+CodeGenOpts.DebugInfoForProfiling);
   } else if (!CodeGenOpts.SampleProfileFile.empty())
 // -fprofile-sample-use
 PGOOpt = PGOOptions(
 CodeGenOpts.SampleProfileFile, "", CodeGenOpts.ProfileRemappingFile,
 CodeGenOpts.MemoryProfileUsePath, VFS, PGOOptions::SampleUse,
-PGOOptions::NoCSAction, PGOOptions::ColdFuncOpt::Default,
+PGOOptions::NoCSAction, ClPGOColdFuncAttr,
 CodeGenOpts.DebugInfoForProfiling, 
CodeGenOpts.PseudoProbeForProfiling);
   else if (!CodeGenOpts.MemoryProfileUsePath.empty())
 // -fmemory-profile-use (without any of the above options)
 PGOOpt = PGOOptions("", "", "", CodeGenOpts.MemoryProfileUsePath, VFS,
 PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling);
+ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling);
   else if (CodeGenOpts.PseudoProbeForProfiling)
 // -fpseudo-probe-for-profiling
-PGOOpt = PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
-PGOOptions::NoAction, PGOOptions::NoCSAction,
-PGOOptions::ColdFuncOpt::Default,
-CodeGenOpts.DebugInfoForProfiling, true);
+PGOOpt =
+PGOOptions("", "", "", /*MemoryProfile=*/"", nullptr,
+   PGOOptions::NoAction, PGOOptions::NoCSAction,
+   ClPGOColdFuncAttr, CodeGenOpts.DebugInfoForProfiling, true);
   else if (CodeGenOpts.DebugInfoForProfiling)
 // -fdebug-info-for-

[clang] [flang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #88661)

2024-04-14 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.

lg, but update the commit message `Pull Request: 
https://github.com/llvm/llvm-project/pull/87866`, that's obsolete

https://github.com/llvm/llvm-project/pull/88661
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-11 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks closed 
https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-11 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

yeah that patch makes those test pass with this PR, lgtm

(you could also test locally by touching the files I mentioned above, e.g. even 
just `touch lib/clang/19/lib/linux/libclang_rt.builtins-aarch64-android.a` 
repro'd the test failure on my machine)

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] be10070 - Revert "[Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin"

2024-04-10 Thread Arthur Eubanks via cfe-commits

Author: Arthur Eubanks
Date: 2024-04-10T23:41:51Z
New Revision: be10070f91b86a6f126d2451852242bfcb2cd366

URL: 
https://github.com/llvm/llvm-project/commit/be10070f91b86a6f126d2451852242bfcb2cd366
DIFF: 
https://github.com/llvm/llvm-project/commit/be10070f91b86a6f126d2451852242bfcb2cd366.diff

LOG: Revert "[Driver] Ensure ToolChain::LibraryPaths is not empty for 
non-Darwin"

This reverts commit ccdebbae4d77d3efc236af92c22941de5d437e01.

Causes test failures in the presence of Android runtime libraries in 
resource-dir.
See comments on https://github.com/llvm/llvm-project/pull/87866.

Added: 


Modified: 
clang/lib/Driver/ToolChain.cpp
clang/test/Driver/arm-compiler-rt.c
clang/test/Driver/cl-link.c
clang/test/Driver/compiler-rt-unwind.c
clang/test/Driver/coverage-ld.c
clang/test/Driver/instrprof-ld.c
clang/test/Driver/linux-ld.c
clang/test/Driver/mingw-sanitizers.c
clang/test/Driver/msp430-toolchain.c
clang/test/Driver/print-libgcc-file-name-clangrt.c
clang/test/Driver/print-runtime-dir.c
clang/test/Driver/riscv32-toolchain-extra.c
clang/test/Driver/riscv32-toolchain.c
clang/test/Driver/riscv64-toolchain-extra.c
clang/test/Driver/riscv64-toolchain.c
clang/test/Driver/sanitizer-ld.c
clang/test/Driver/wasm-toolchain.c
clang/test/Driver/wasm-toolchain.cpp
clang/test/Driver/windows-cross.c
clang/test/Driver/zos-ld.c
flang/test/Driver/msvc-dependent-lib-flags.f90

Removed: 




diff  --git a/clang/lib/Driver/ToolChain.cpp b/clang/lib/Driver/ToolChain.cpp
index 237092ed07e5dc..03450fc0f57b93 100644
--- a/clang/lib/Driver/ToolChain.cpp
+++ b/clang/lib/Driver/ToolChain.cpp
@@ -796,13 +796,7 @@ ToolChain::getTargetSubDirPath(StringRef BaseDir) const {
 std::optional ToolChain::getRuntimePath() const {
   SmallString<128> P(D.ResourceDir);
   llvm::sys::path::append(P, "lib");
-  if (auto Ret = getTargetSubDirPath(P))
-return Ret;
-  // Darwin does not use per-target runtime directory.
-  if (Triple.isOSDarwin())
-return {};
-  llvm::sys::path::append(P, Triple.str());
-  return std::string(P);
+  return getTargetSubDirPath(P);
 }
 
 std::optional ToolChain::getStdlibPath() const {

diff  --git a/clang/test/Driver/arm-compiler-rt.c 
b/clang/test/Driver/arm-compiler-rt.c
index cb6c29f48a7814..5e9e528400d08e 100644
--- a/clang/test/Driver/arm-compiler-rt.c
+++ b/clang/test/Driver/arm-compiler-rt.c
@@ -10,47 +10,47 @@
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI
-// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins.a"
+// ARM-GNUEABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
 
 // RUN: %clang -target arm-linux-gnueabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=hard -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABI-ABI
-// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
+// ARM-GNUEABI-ABI: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF
-// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins.a"
+// ARM-GNUEABIHF: "{{.*[/\\]}}libclang_rt.builtins-armhf.a"
 
 // RUN: %clang -target arm-linux-gnueabihf \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -mfloat-abi=soft -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-GNUEABIHF-ABI
-// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins.a"
+// ARM-GNUEABIHF-ABI: "{{.*[/\\]}}libclang_rt.builtins-arm.a"
 
 // RUN: %clang -target arm-windows-itanium \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-WINDOWS
-// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins.lib"
+// ARM-WINDOWS: "{{.*[/\\]}}clang_rt.builtins-arm.lib"
 
 // RUN: %clang -target arm-linux-androideabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -rtlib=compiler-rt -### %s 2>&1 \
 // RUN:   | FileCheck %s -check-prefix ARM-ANDROID
-// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins.a"
+// ARM-ANDROID: "{{.*[/\\]}}libclang_rt.builtins-arm-android.a"
 
 // RUN: not %clang --target=arm-linux-androideabi \
 // RUN: --sysroot=%S/Inputs/resource_dir_with_arch_subdir \
 // RUN: -resource-dir=%S/Inputs/r

[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-10 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

it seems that the test depends on if certain android runtime libraries are 
present or not in the resource dir (without per-target runtime directory since 
that's still an issue on Android). perhaps the tests need `-resource-dir` to 
make them more hermetic?

anyway, will revert, feel free to reland once the tests are fixed. this is 
what's in my resource dir if it's helpful for reproducing

```
$ ls lib/clang/19/lib/linux/
aarch64  libclang_rt.asan_cxx-aarch64-android.a 
 libclang_rt.builtins-aarch64-android.a  libclang_rt.tsan_cxx-aarch64-android.a 
 libclang_rt.ubsan_standalone-aarch64-android.so
libclang_rt.asan-aarch64-android.a   libclang_rt.asan-preinit-aarch64-android.a 
 libclang_rt.profile-aarch64-android.a   
libclang_rt.ubsan_minimal-aarch64-android.a 
libclang_rt.ubsan_standalone_cxx-aarch64-android.a
libclang_rt.asan-aarch64-android.so  libclang_rt.asan_static-aarch64-android.a  
 libclang_rt.tsan-aarch64-android.a  
libclang_rt.ubsan_standalone-aarch64-android.a
```

https://github.com/llvm/llvm-project/pull/87866
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [Driver] Ensure ToolChain::LibraryPaths is not empty for non-Darwin (PR #87866)

2024-04-10 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

this seemes to be causing some test failures for us: 
https://logs.chromium.org/logs/chromium/buildbucket/cr-buildbucket/8751043232043110529/+/u/package_clang/stdout?format=raw

```
  TEST 'Clang :: Driver/linux-ld.c' FAILED 


RUN: at line 92: ...

 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/linux-ld.c:102:25:
 error: CHECK-LD-RT-ANDROID: expected string not found in input
 // CHECK-LD-RT-ANDROID: libclang_rt.builtins.a"
 ^
 :6:331: note: scanning from here
  
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/ld.lld" 
"--sysroot=/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot"
 "-EL" "-z" "now" "-z" "relro" "-z" "max-page-size=4096" "-X" 
"--hash-style=both" "--eh-frame-hdr" "-m" "armelf_linux_eabi" "-dynamic-linker" 
"/system/bin/linker" "-o" "a.out" 
"/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib/crtbegin_dynamic.o"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib"
 "/b/s/w/ir/x/t/lit-tmp-jnv32xv9/linux-ld-60ec02.o" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a"
 "-l:libunwind.a" "-ldl" "-lc" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a"
 "-l:libunwind.a" "-ldl" 
"/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib/crtend_android.o"




   ^
 :6:866: note: possible intended match here
  
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/ld.lld" 
"--sysroot=/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot"
 "-EL" "-z" "now" "-z" "relro" "-z" "max-page-size=4096" "-X" 
"--hash-style=both" "--eh-frame-hdr" "-m" "armelf_linux_eabi" "-dynamic-linker" 
"/system/bin/linker" "-o" "a.out" 
"/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib/crtbegin_dynamic.o"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib"
 "/b/s/w/ir/x/t/lit-tmp-jnv32xv9/linux-ld-60ec02.o" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a"
 "-l:libunwind.a" "-ldl" "-lc" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a"
 "-l:libunwind.a" "-ldl" 
"/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib/crtend_android.o"


  TEST 'Clang :: Driver/sanitizer-ld.c' FAILED 


RUN: at line 177: ...

 
/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/sanitizer-ld.c:187:24:
 error: CHECK-ASAN-ANDROID: expected string not found in input
 // CHECK-ASAN-ANDROID: libclang_rt.asan.so"
^
 :6:320: note: scanning from here
  
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/bin/ld.lld" 
"--sysroot=/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot"
 "-EL" "-z" "now" "-z" "relro" "-z" "max-page-size=4096" "-X" 
"--hash-style=both" "--eh-frame-hdr" "-m" "armelf_linux_eabi" "-pie" 
"-dynamic-linker" "/system/bin/linker" "-o" "a.out" 
"/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib/crtbegin_dynamic.o"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib/../lib"
 
"-L/b/s/w/ir/cache/builder/src/third_party/llvm/clang/test/Driver/Inputs/basic_android_tree/sysroot/usr/lib"
 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.asan-arm-android.so"
 "--whole-archive" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.asan_static-arm-android.a"
 "--no-whole-archive" "/b/s/w/ir/x/t/lit-tmp-jnv32xv9/sanitizer-ld-d1ddb3.o" 
"/b/s/w/ir/cache/builder/src/third_party/llvm-build/Release+Asserts/lib/clang/19/lib/linux/libclang_rt.builtins-arm-android.a"

[clang] Reland "[Win32][ELF] Make CodeView a DebugInfoFormat only for COFF format" (PR #87987)

2024-04-09 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks approved this pull request.


https://github.com/llvm/llvm-project/pull/87987
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks edited 
https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

> I'd suggest adding bitcode upgrade if it isn't too hard (I don't think it 
> should be?)

done



https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-08 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks updated 
https://github.com/llvm/llvm-project/pull/87906

>From 7a9df42b4c4f4f1b02dc3158d24800f3d4b68d8f Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Sun, 7 Apr 2024 05:29:36 +
Subject: [PATCH 1/2] [clang][llvm] Remove "implicit-section-name" attribute

D33412/D33413 introduced this to support a clang pragma to set section
names for a symbol depending on if it would be placed in
bss/data/rodata/text, which may not be known until the backend. However,
for text we know that only functions will go there, so just
directly set the section in clang instead of going through a
completely separate attribute.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  2 +-
 clang/test/CodeGen/clang-sections-attribute.c |  3 ---
 clang/test/CodeGenCXX/clang-sections.cpp  | 18 ++---
 llvm/lib/CodeGen/TargetInstrInfo.cpp  |  3 +--
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 11 +---
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  5 
 .../CodeGen/AArch64/clang-section-macho.ll| 22 ---
 llvm/test/CodeGen/ARM/clang-section.ll| 24 -
 .../Generic/machine-function-splitter.ll  | 27 +++
 .../basic-block-sections-pragma-sections.ll   |  4 +--
 10 files changed, 15 insertions(+), 104 deletions(-)
 delete mode 100644 llvm/test/CodeGen/AArch64/clang-section-macho.ll

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 00b3bfcaa0bc25..f4dbfe7a21f83c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2627,7 +2627,7 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
 addUsedGlobal(F);
   if (auto *SA = D->getAttr())
 if (!D->getAttr())
-  F->addFnAttr("implicit-section-name", SA->getName());
+  F->setSection(SA->getName());
 
   llvm::AttrBuilder Attrs(F->getContext());
   if (GetCPUAndFeaturesAttributes(GD, Attrs)) {
diff --git a/clang/test/CodeGen/clang-sections-attribute.c 
b/clang/test/CodeGen/clang-sections-attribute.c
index 70ed24ed07a280..768bdd4d87649e 100644
--- a/clang/test/CodeGen/clang-sections-attribute.c
+++ b/clang/test/CodeGen/clang-sections-attribute.c
@@ -69,8 +69,5 @@ static int int_zvar;
 // CHECK: define internal void @int_fun() #0 section ".int_fun_attr"
 // CHECK: define internal void @int_fun2() #0 section ".int_fun2_attr"
 //
-// Function attributes should not include implicit-section-name.
-// CHECK-NOT: attributes #0 = {{.*}}implicit-section-name
-//
 // No other attribute group should be present in the file.
 // CHECK-NOT: attributes #1
diff --git a/clang/test/CodeGenCXX/clang-sections.cpp 
b/clang/test/CodeGenCXX/clang-sections.cpp
index a444f2d0cae59c..aa159e552b1b3c 100644
--- a/clang/test/CodeGenCXX/clang-sections.cpp
+++ b/clang/test/CodeGenCXX/clang-sections.cpp
@@ -81,24 +81,22 @@ int hoo(void) {
 //CHECK: @p ={{.*}} constant i32 7, align 4
 //CHECK: @_ZL5fptrs = internal constant [2 x ptr] [ptr @foo, ptr @goo], align 
{{4|8}} #3
 
-//CHECK: define{{.*}} i32 @foo() #5 {
-//CHECK: define{{.*}} i32 @goo() #6 {
-//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #7
-//CHECK: define{{.*}} i32 @hoo() #8 {
+//ELF: define{{.*}} i32 @foo(){{.*}} section "my_text.1" {
+//ELF: define{{.*}} i32 @goo(){{.*}} section "my_text.2" {
+//MACHO: define{{.*}} i32 @foo(){{.*}} section "__TEXT,__mytext1" {
+//MACHO: define{{.*}} i32 @goo(){{.*}} section "__TEXT,__mytext2" {
+
+// ensure zoo/hoo don't have a section
+//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #6{{$}}
+//CHECK: define{{.*}} i32 @hoo() #5 {
 
 //ELF: attributes #0 = { "bss-section"="my_bss.1" "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #1 = { "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #2 = { "bss-section"="my_bss.2" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #3 = { "bss-section"="my_bss.2" "data-section"="my_data.2" 
"relro-section"="my_relro.2" "rodata-section"="my_rodata.2" }
 //ELF: attributes #4 = { "relro-section"="my_relro.2" }
-//ELF: attributes #5 = { {{.*"implicit-section-name"="my_text.1".*}} }
-//ELF: attributes #6 = { {{.*"implicit-section-name"="my_text.2".*}} }
 //MACHO: attributes #0 = { "bss-section"="__BSS,__mybss1" 
"data-section"="__DATA,__mydata1" "rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #1 = { "data-section"="__DATA,__mydata1" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #2 = { "bss-section"="__BSS,__mybss2" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #3 = { "bss-section"="__BSS,__mybss2" 
"data-section"="__DATA,__mydata2" "relro-section"="__RELRO,__myrelro2" 
"rodata-section"="__RODATA,__myrodata2" }
 //MACHO: attributes #4 = { "relro-section"="__RELRO,__myrelro2" }
-//MACHO: attributes #5 = { {{.*"implicit-section-name"="__TEXT,__mytext1".*}} }
-//MACHO: attributes #6 = { {{.*"implicit-section-name"="__TEXT,__mytext2".

[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-06 Thread Arthur Eubanks via cfe-commits

aeubanks wrote:

this probably needs bitcode upgrade?

https://github.com/llvm/llvm-project/pull/87906
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[clang] [llvm] [clang][llvm] Remove "implicit-section-name" attribute (PR #87906)

2024-04-06 Thread Arthur Eubanks via cfe-commits

https://github.com/aeubanks created 
https://github.com/llvm/llvm-project/pull/87906

D33412/D33413 introduced this to support a clang pragma to set section names 
for a symbol depending on if it would be placed in bss/data/rodata/text, which 
may not be known until the backend. However, for text we know that only 
functions will go there, so just directly set the section in clang instead of 
going through a completely separate attribute.

>From 7a9df42b4c4f4f1b02dc3158d24800f3d4b68d8f Mon Sep 17 00:00:00 2001
From: Arthur Eubanks 
Date: Sun, 7 Apr 2024 05:29:36 +
Subject: [PATCH] [clang][llvm] Remove "implicit-section-name" attribute

D33412/D33413 introduced this to support a clang pragma to set section
names for a symbol depending on if it would be placed in
bss/data/rodata/text, which may not be known until the backend. However,
for text we know that only functions will go there, so just
directly set the section in clang instead of going through a
completely separate attribute.
---
 clang/lib/CodeGen/CodeGenModule.cpp   |  2 +-
 clang/test/CodeGen/clang-sections-attribute.c |  3 ---
 clang/test/CodeGenCXX/clang-sections.cpp  | 18 ++---
 llvm/lib/CodeGen/TargetInstrInfo.cpp  |  3 +--
 .../CodeGen/TargetLoweringObjectFileImpl.cpp  | 11 +---
 llvm/lib/Target/TargetLoweringObjectFile.cpp  |  5 
 .../CodeGen/AArch64/clang-section-macho.ll| 22 ---
 llvm/test/CodeGen/ARM/clang-section.ll| 24 -
 .../Generic/machine-function-splitter.ll  | 27 +++
 .../basic-block-sections-pragma-sections.ll   |  4 +--
 10 files changed, 15 insertions(+), 104 deletions(-)
 delete mode 100644 llvm/test/CodeGen/AArch64/clang-section-macho.ll

diff --git a/clang/lib/CodeGen/CodeGenModule.cpp 
b/clang/lib/CodeGen/CodeGenModule.cpp
index 00b3bfcaa0bc25..f4dbfe7a21f83c 100644
--- a/clang/lib/CodeGen/CodeGenModule.cpp
+++ b/clang/lib/CodeGen/CodeGenModule.cpp
@@ -2627,7 +2627,7 @@ void CodeGenModule::setNonAliasAttributes(GlobalDecl GD,
 addUsedGlobal(F);
   if (auto *SA = D->getAttr())
 if (!D->getAttr())
-  F->addFnAttr("implicit-section-name", SA->getName());
+  F->setSection(SA->getName());
 
   llvm::AttrBuilder Attrs(F->getContext());
   if (GetCPUAndFeaturesAttributes(GD, Attrs)) {
diff --git a/clang/test/CodeGen/clang-sections-attribute.c 
b/clang/test/CodeGen/clang-sections-attribute.c
index 70ed24ed07a280..768bdd4d87649e 100644
--- a/clang/test/CodeGen/clang-sections-attribute.c
+++ b/clang/test/CodeGen/clang-sections-attribute.c
@@ -69,8 +69,5 @@ static int int_zvar;
 // CHECK: define internal void @int_fun() #0 section ".int_fun_attr"
 // CHECK: define internal void @int_fun2() #0 section ".int_fun2_attr"
 //
-// Function attributes should not include implicit-section-name.
-// CHECK-NOT: attributes #0 = {{.*}}implicit-section-name
-//
 // No other attribute group should be present in the file.
 // CHECK-NOT: attributes #1
diff --git a/clang/test/CodeGenCXX/clang-sections.cpp 
b/clang/test/CodeGenCXX/clang-sections.cpp
index a444f2d0cae59c..aa159e552b1b3c 100644
--- a/clang/test/CodeGenCXX/clang-sections.cpp
+++ b/clang/test/CodeGenCXX/clang-sections.cpp
@@ -81,24 +81,22 @@ int hoo(void) {
 //CHECK: @p ={{.*}} constant i32 7, align 4
 //CHECK: @_ZL5fptrs = internal constant [2 x ptr] [ptr @foo, ptr @goo], align 
{{4|8}} #3
 
-//CHECK: define{{.*}} i32 @foo() #5 {
-//CHECK: define{{.*}} i32 @goo() #6 {
-//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #7
-//CHECK: define{{.*}} i32 @hoo() #8 {
+//ELF: define{{.*}} i32 @foo(){{.*}} section "my_text.1" {
+//ELF: define{{.*}} i32 @goo(){{.*}} section "my_text.2" {
+//MACHO: define{{.*}} i32 @foo(){{.*}} section "__TEXT,__mytext1" {
+//MACHO: define{{.*}} i32 @goo(){{.*}} section "__TEXT,__mytext2" {
+
+// ensure zoo/hoo don't have a section
+//CHECK: declare i32 @zoo(ptr noundef, ptr noundef) #6{{$}}
+//CHECK: define{{.*}} i32 @hoo() #5 {
 
 //ELF: attributes #0 = { "bss-section"="my_bss.1" "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #1 = { "data-section"="my_data.1" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #2 = { "bss-section"="my_bss.2" 
"rodata-section"="my_rodata.1" }
 //ELF: attributes #3 = { "bss-section"="my_bss.2" "data-section"="my_data.2" 
"relro-section"="my_relro.2" "rodata-section"="my_rodata.2" }
 //ELF: attributes #4 = { "relro-section"="my_relro.2" }
-//ELF: attributes #5 = { {{.*"implicit-section-name"="my_text.1".*}} }
-//ELF: attributes #6 = { {{.*"implicit-section-name"="my_text.2".*}} }
 //MACHO: attributes #0 = { "bss-section"="__BSS,__mybss1" 
"data-section"="__DATA,__mydata1" "rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #1 = { "data-section"="__DATA,__mydata1" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #2 = { "bss-section"="__BSS,__mybss2" 
"rodata-section"="__RODATA,__myrodata1" }
 //MACHO: attributes #3 = { "bss-section"="

  1   2   3   4   5   >