[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D159167#4651325 , @lhames wrote:

> @vitalybuka If we want to disable this test for now, what's the canonical way 
> to do it? Should we just wrap the whole `add_clang_unittest` block in the 
> conditional?
>
>   # export_executable_symbols triggers Lsan report.   
>   
>   
>
>   if (NOT LLVM_USE_SANITIZER MATCHES ".*Address.*")
>   
> add_clang_unittest(ClangReplInterpreterExceptionTests
>   InterpreterExceptionTest.cpp
>   )
>   
> llvm_update_compile_flags(ClangReplInterpreterExceptionTests)
> target_link_libraries(ClangReplInterpreterExceptionTests PUBLIC
>   clangAST
>   clangBasic
>   clangInterpreter
>   clangFrontend
>   )
> add_dependencies(ClangReplInterpreterExceptionTests 
> clang-resource-headers)
>   
> export_executable_symbols(ClangReplInterpreterExceptionTests)
>   endif()

This should work.

Also you can

  #if LLVM_HWADDRESS_SANITIZER_BUILD || LLVM_ADDRESS_SANITIZER_BUILD
  #  define MAYBE_MyTest DISABLED_MyTest
  #else
  #  define MAYBE_MyTest MyTest
  #endif

But here we have just one test case

Also you can try disable only lsan, link time:

  #if LLVM_ADDRESS_SANITIZER_BUILD || LLVM_HWADDRESS_SANITIZER_BUILD
  #include 
  LLVM_ATTRIBUTE_USED int __lsan_is_turned_off() { return 1; }
  #endif


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159167/new/

https://reviews.llvm.org/D159167

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


[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka resigned from this revision.
vitalybuka added a comment.

I assume we moved to https://github.com/llvm/llvm-project/pull/65972


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148654/new/

https://reviews.llvm.org/D148654

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


[PATCH] D145214: [TSAN] add support for riscv64

2023-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.



Comment at: compiler-rt/lib/tsan/rtl/CMakeLists.txt:5
 append_list_if(COMPILER_RT_HAS_MSSE4_2_FLAG -msse4.2 TSAN_RTL_CFLAGS)
-append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=530
+append_list_if(SANITIZER_LIMIT_FRAME_SIZE -Wframe-larger-than=656
TSAN_RTL_CFLAGS)

Maybe this one is not needed after b31bd6d8046d01a66aa92993bacb56b115a67fc5


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145214/new/

https://reviews.llvm.org/D145214

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


[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-13 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Also maybe it's cleaner just disable a particular test (binary or test case) 
with incompatible sanitizer. Leaving this up to @lkail or @v.g.vassilev


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159167/new/

https://reviews.llvm.org/D159167

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


[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-13 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D159167#4645214 , @vitalybuka 
wrote:

> This breaks https://lab.llvm.org/buildbot/#/builders/5/builds/36614

I landed b4b4d8bd61d8de946e130beff5049a4ab13e155d 
 as 
workaround
We unlikely will have time to figure out what is going on there, but will try 
to help maintainers, if there is an interest in sanitizers support. I know that 
we have other JIT related tests were sanitizers are disabled.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159167/new/

https://reviews.llvm.org/D159167

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


[PATCH] D159167: [clang-repl][Orc] Export executable symbols in ClangReplInterpreterExceptionTests

2023-09-13 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This breaks https://lab.llvm.org/buildbot/#/builders/5/builds/36614


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159167/new/

https://reviews.llvm.org/D159167

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


[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-09-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:47
 #include "llvm/Transforms/Utils/SanitizerStats.h"
 
 #include 

this file and BoundsChecking.cpp belong to different patches



Comment at: clang/lib/CodeGen/CGExpr.cpp:56
+static llvm::cl::opt ClSanitizeDebugDeoptimization(
+"sanitizer-de-opt-traps", llvm::cl::Optional,
+llvm::cl::desc("Deoptimize traps for sanitizers"), llvm::cl::init(false));

this applies only to fsanitize=undefined, and does not apply to llvm level 
sanitizers, like msan, asan
we need better name: maybe ubsan-unique-traps

BTW do we want this as frontend flag?



Comment at: clang/lib/CodeGen/CGExpr.cpp:3581
 
-  if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB ||
-  (CurCodeDecl && CurCodeDecl->hasAttr())) {
+  if (!ClSanitizeDebugDeoptimization &&
+  CGM.getCodeGenOpts().OptimizationLevel && TrapBB &&

so here we have two problems?
1. OptimizationLevel > 0 clang creates only one TrapBB per  check type
2. even if we create multiple bb here, branch-folder will merge them later




Comment at: clang/lib/CodeGen/CGExpr.cpp:3597-3599
+llvm::ConstantInt::get(CGM.Int8Ty, ClSanitizeDebugDeoptimization
+   ? TrapBB->getParent()->size()
+   : CheckHandlerID));

  (TrapBB->getParent()->size() * 
0x1 + CheckHandlerID)




Comment at: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp:196
+  CallInst *TrapCall =
+  IRB.CreateCall(F, ConstantInt::get(IRB.getInt8Ty(), Fn->size()));
+  TrapCall->setDoesNotReturn();

why Fn->size(), to make a counter?





Comment at: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp:202
+} else {
+  if (TrapBB && SingleTrapBB)
+return TrapBB;

can you please create a test where bounds-checking-single-trap=0 and 
setCannotMerge produce invalid result.



Comment at: llvm/lib/Transforms/Instrumentation/BoundsChecking.cpp:189
   auto GetTrapBB = [](BuilderTy ) {
-if (TrapBB && SingleTrapBB)
-  return TrapBB;
-
-Function *Fn = IRB.GetInsertBlock()->getParent();
-// FIXME: This debug location doesn't make a lot of sense in the
-// `SingleTrapBB` case.
-auto DebugLoc = IRB.getCurrentDebugLocation();
-IRBuilder<>::InsertPointGuard Guard(IRB);
-TrapBB = BasicBlock::Create(Fn->getContext(), "trap", Fn);
-IRB.SetInsertPoint(TrapBB);
-
-auto *F = Intrinsic::getDeclaration(Fn->getParent(), Intrinsic::trap);
-CallInst *TrapCall = IRB.CreateCall(F, {});
-TrapCall->setDoesNotReturn();
-TrapCall->setDoesNotThrow();
-TrapCall->setDebugLoc(DebugLoc);
-IRB.CreateUnreachable();
-
+if (DebugTrapBB) {
+  Function *Fn = IRB.GetInsertBlock()->getParent();

smeenai wrote:
> oskarwirga wrote:
> > nlopes wrote:
> > > this seems like code duplication. This pass already has the single-trap 
> > > flag to exactly control if you get a single trap BB or one per check for 
> > > better debug info.
> > Unfortunately, even with the single trap flag it gets optimized out in 
> > later passes because the machine code emitted is the exact same 
> I believe we end up tail merging the trap instructions. A previous iteration 
> of this patch attempted to use the `nomerge` attribute to directly avoid the 
> tail merging, but that only works for function calls, not for the `trap` 
> instruction ultimately emitted here.
branches of `if (DebugTrapBB) ` condition has a lot of code duplication, can 
you try to imrove?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148654/new/

https://reviews.llvm.org/D148654

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


[PATCH] D74094: Reapply: [IRGen] Emit lifetime intrinsics around temporary aggregate argument allocas

2023-09-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D74094#4633785 , @alexfh wrote:

> This commit caused invalid AddressSanitizer: stack-use-after-scope errors in 
> our internal setup. Trying to create a standalone repro, but so far we think 
> that the patch is incorrect. @vitalybuka says "The patch seems wrong, callee 
> can return a reference to temp, so lifetime should be extended to full 
> expression."

I will lazily quote https://en.cppreference.com/w/cpp/language/lifetime, we can 
lookup the standard, all ask experts, if this is wrong:

  All temporary objects are destroyed as the last step in evaluating the 
full-expression that (lexically) contains the point where they were created, 
and if multiple temporary objects were created, they are destroyed in the order 
opposite to the order of creation. This is true even if that evaluation ends in 
throwing an exception.

And full-expression here is:

  const Tensor t3 = round(a.log().exp());




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D74094/new/

https://reviews.llvm.org/D74094

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


[PATCH] D157632: [Profile] Allow online merging with debug info correlation.

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Reverted cd591e02d4563d4b90792ed5f441e1cf5b30443e 



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157632/new/

https://reviews.llvm.org/D157632

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


[PATCH] D159000: Reland "[Profile] Allow online merging with debug info correlation."

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Reverted. Please continue on original review: `arc diff HEAD^ --revision 
D157632`


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159000/new/

https://reviews.llvm.org/D159000

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


[PATCH] D159000: Reland "[Profile] Allow online merging with debug info correlation."

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Could this be related https://lab.llvm.org/buildbot/#/builders/127/builds/54239 
?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159000/new/

https://reviews.llvm.org/D159000

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


[PATCH] D159000: Reland "[Profile] Allow online merging with debug info correlation."

2023-08-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

It's more convenient if you upload new patches into original review and reland 
that one.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D159000/new/

https://reviews.llvm.org/D159000

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


[PATCH] D156042: [clang][Interp] Implement __builtin_strlen

2023-08-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Reverted with D155568 


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D156042/new/

https://reviews.llvm.org/D156042

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


[PATCH] D155568: [clang][Interp] Make sure we push integers of the correct size

2023-08-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Breaks the bot 
https://lab.llvm.org/buildbot/#/builders/74/builds/21336/steps/13/logs/stdio

Please take a look or revert?

Note: msan_track_origins step may have useful details.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D155568/new/

https://reviews.llvm.org/D155568

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-08-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/tools/libclang/CIndex.cpp:3656
+  VisitorWorkList *WL = nullptr;
+  if (!WorkListFreeList.empty()) {
+WL = WorkListFreeList.back();

vitalybuka wrote:
> There is a leak here https://lab.llvm.org/buildbot/#/builders/5/builds/35725
> 
> 
Please ignore the location of this comment.
I don't know which part of the patch is responsible for the leak
Another trace here 
https://lab.llvm.org/buildbot/#/builders/236/builds/5562/steps/13/logs/stdio


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151373/new/

https://reviews.llvm.org/D151373

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-08-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Not sure why the similar code above does not leak, so I will revert and leave 
to author to investigate


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151373/new/

https://reviews.llvm.org/D151373

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


[PATCH] D151373: [libclang] Expose arguments of clang::annotate

2023-08-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/tools/libclang/CIndex.cpp:3656
+  VisitorWorkList *WL = nullptr;
+  if (!WorkListFreeList.empty()) {
+WL = WorkListFreeList.back();

There is a leak here https://lab.llvm.org/buildbot/#/builders/5/builds/35725




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151373/new/

https://reviews.llvm.org/D151373

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D153536#4576683 , @aaron.ballman 
wrote:

> In D153536#4571435 , @vitalybuka 
> wrote:
>
>>> Thanks! We might need someone from clangd to help here. The logs do not 
>>> have any information explaining what's failing with the test, and looking 
>>> at the test code, I struggle to see how these changes would impact that 
>>> test. We've had some significant issues with flaky clangd tests 
>>> (https://github.com/clangd/clangd/issues/1712), so it's possible this is 
>>> happenstance.
>>
>> I tried to debug that, and it looks like false Asan report. Maybe a bug in 
>> FakeStack::GC related code.
>
> Thank you for looking into it! I came to the same general conclusion; and it 
> seems the impacted bot has gone back to green in the meantime: 
> https://lab.llvm.org/buildbot/#/builders/168/builds/15031 so hopefully we're 
> in good shape.

Yes. Fixed by D157552 . It's amusing to see 
this unrelated patch exposing ~10 years old bug, which was never reported 
before.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153536/new/

https://reviews.llvm.org/D153536

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> Thanks! We might need someone from clangd to help here. The logs do not have 
> any information explaining what's failing with the test, and looking at the 
> test code, I struggle to see how these changes would impact that test. We've 
> had some significant issues with flaky clangd tests 
> (https://github.com/clangd/clangd/issues/1712), so it's possible this is 
> happenstance.

I tried to debug that, and it looks like false Asan report. Maybe a bug in 
FakeStack::GC related code.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153536/new/

https://reviews.llvm.org/D153536

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Not a test update

The second line of the test triggers:

RUN: not --crash clangd -lit-test -sync=0 < %s 2> %t.async.err
==

  Signalled while building preamble
Filename: =
  ==2319884==ERROR: AddressSanitizer: stack-use-after-return on address 
0x7f310f6eb210 at pc 0x55a3ecaab9f5 bp 0x7f3115c49920 sp 0x7f3115c49918
  READ of size 1 at 0x7f310f6eb210 thread T3
  #0 0x55a3ecaab9f4 in __is_long 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1734:33
  #1 0x55a3ecaab9f4 in __get_pointer 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1869:17
  #2 0x55a3ecaab9f4 in data 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/libcxx_build_asan/include/c++/v1/string:1559:73
  #3 0x55a3ecaab9f4 in operator<< 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/Support/raw_ostream.h:249:22
  #4 0x55a3ecaab9f4 in clang::clangd::(anonymous 
namespace)::crashDumpCompileCommand(llvm::raw_ostream&, 
clang::tooling::CompileCommand const&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1012:24
  #5 0x55a3ecaab285 in clang::clangd::(anonymous 
namespace)::crashDumpParseInputs(llvm::raw_ostream&, clang::clangd::ParseInputs 
const&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/TUScheduler.cpp:1038:3
  #6 0x55a3ecec1c9d in operator() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/include/llvm/ADT/FunctionExtras.h:382:12
  #7 0x55a3ecec1c9d in 
clang::clangd::ThreadCrashReporter::runCrashHandlers() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/support/ThreadCrashReporter.cpp:30:5
  #8 0x55a3ebacfd78 in operator() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:717:9
  #9 0x55a3ebacfd78 in clang::clangd::clangdMain(int, 
char**)::$_0::__invoke(void*) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang-tools-extra/clangd/tool/ClangdMain.cpp:716:7
  #10 0x55a3e87c27ba in llvm::sys::RunSignalHandlers() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Signals.cpp:103:5
  #11 0x55a3e87cbd01 in SignalHandler(int) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/Unix/Signals.inc:403:3
  #12 0x7f3115a3bcef  (/lib/x86_64-linux-gnu/libc.so.6+0x3bcef) (BuildId: 
d1704d25fbbb72fa95d517b883131828c0883fe9)
  #13 0x7f3115a9226a in pthread_kill 
(/lib/x86_64-linux-gnu/libc.so.6+0x9226a) (BuildId: 
d1704d25fbbb72fa95d517b883131828c0883fe9)
  #14 0x7f3115a3bc45 in raise (/lib/x86_64-linux-gnu/libc.so.6+0x3bc45) 
(BuildId: d1704d25fbbb72fa95d517b883131828c0883fe9)
  #15 0x7f3115a227fb in abort (/lib/x86_64-linux-gnu/libc.so.6+0x227fb) 
(BuildId: d1704d25fbbb72fa95d517b883131828c0883fe9)
  #16 0x55a3e869c429 in llvm::report_fatal_error(llvm::Twine const&, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/ErrorHandling.cpp:123:5
  #17 0x55a3e869c014 in llvm::report_fatal_error(char const*, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/llvm/lib/Support/ErrorHandling.cpp:83:3
  #18 0x55a3e9a2bb12 in (anonymous 
namespace)::PragmaDebugHandler::HandlePragma(clang::Preprocessor&, 
clang::PragmaIntroducer, clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Pragma.cpp:1102:9
  #19 0x55a3e9a0f270 in 
clang::Preprocessor::HandlePragmaDirective(clang::PragmaIntroducer) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Pragma.cpp:178:19
  #20 0x55a3e98e92a1 in clang::Preprocessor::HandleDirective(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/PPDirectives.cpp:1265:14
  #21 0x55a3e98a427a in clang::Lexer::LexTokenInternal(clang::Token&, bool) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Lexer.cpp:4362:7
  #22 0x55a3e989754c in clang::Lexer::Lex(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Lexer.cpp:3578:24
  #23 0x55a3e9a5fb72 in clang::Preprocessor::Lex(clang::Token&) 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Lex/Preprocessor.cpp:886:33
  #24 0x55a3eee8d7ef in ConsumeToken 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/include/clang/Parse/Parser.h:504:8
  #25 0x55a3eee8d7ef in clang::Parser::Initialize() 
/b/sanitizer-x86_64-linux-bootstrap-asan/build/llvm-project/clang/lib/Parse/Parser.cpp:568:3
  #26 0x55a3eee7732f in clang::ParseAST(clang::Sema&, bool, bool) 

[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D153536#4570534 , @aaron.ballman 
wrote:

> In D153536#4570513 , @vitalybuka 
> wrote:
>
>> This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
>> Not sure what is wrong there, probably the test need to be updated. Can you 
>> please take a look?
>
> I'm a bit confused -- the linked bot is green and the failures to either side 
> of the linked run are both failing for the same reason (which seems to be 
> unrelated to the changes in this patch). It looks like this bot went red 
> here: https://lab.llvm.org/buildbot/#/builders/168/builds/14944 and hasn't 
> reliably come back to green.

Sorry copy-pasted wrong url. This green is manual request on revision before 
this patch.

Correct failure https://lab.llvm.org/buildbot/#/builders/168/builds/14944
So it's persistently red after that.

If anyone wondering, I've bisected to this patch on buildbot host.
For whatever reason does not reproduce on my workstation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153536/new/

https://reviews.llvm.org/D153536

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


[PATCH] D153536: [Clang] Implement P2169 A nice placeholder with no name

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This patch brakes https://lab.llvm.org/buildbot/#/builders/168/builds/14997
Not sure what is wrong there, probably the test need to be updated. Can you 
please take a look?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D153536/new/

https://reviews.llvm.org/D153536

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D157119#4569967 , @vitalybuka 
wrote:

> In D157119#4569725 , @jroelofs 
> wrote:
>
>> Flaky test? Here's a later build where it succeeds, but the change has 
>> nothing to do with clangd: 
>> https://lab.llvm.org/buildbot/#/builders/168/builds/14997
>
> No, I manually requested a revision in the blame range.
> I am bisecting on VM forked from the bot. Can reproduce there.
> I will update the bug in a few hours.

Sorry, this patch is not to blame.
D153536  is the cause.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157119/new/

https://reviews.llvm.org/D157119

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D157119#4569725 , @jroelofs wrote:

> Flaky test? Here's a later build where it succeeds, but the change has 
> nothing to do with clangd: 
> https://lab.llvm.org/buildbot/#/builders/168/builds/14997

No, I manually requested a revision in the blame range.
I am bisecting on VM forked from the bot. Can reproduce there.
I will update the bug in a few hours.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157119/new/

https://reviews.llvm.org/D157119

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.



>   How to reproduce locally: 
> https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild

Does not reproduce on my workstation too.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157119/new/

https://reviews.llvm.org/D157119

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D157119#4565993 , @jroelofs wrote:

> In D157119#4564546 , @vitalybuka 
> wrote:
>
>> I suspect one of your recent changes broke 
>> https://lab.llvm.org/buildbot/#/builders/168/builds/14944
>> Can you please take a look?
>
> Happy to take a look, but there are 28 commits in the blame list for that 
> build... what makes you suspect it's the one change that only *adds* build 
> dependencies?  ISTM the `clangd` binary should be bit-identical before/after 
> this change, right?

Just 3 mention clangd

> I can't reproduce the failure locally.

Have you tried instruction in the error report:

  How to reproduce locally: 
https://github.com/google/sanitizers/wiki/SanitizerBotReproduceBuild



> Do we have a way to re-trigger that job for specific commits & bisect the 
> blame list?

Another easy ways are:

1. trigger from buildbot, but I don't know you need special permision for that
2. revert, see if it helps, and reland if it's not.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157119/new/

https://reviews.llvm.org/D157119

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


[PATCH] D157119: cmake: add missing dependencies on ClangDriverOptions tablegen

2023-08-06 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

I suspect one of your recent changes broke 
https://lab.llvm.org/buildbot/#/builders/168/builds/14944
Can you please take a look?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D157119/new/

https://reviews.llvm.org/D157119

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


[PATCH] D148654: Modify BoundsSan to improve debuggability

2023-07-13 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGExpr.cpp:3576-3597
+if (TrapBBs.size() <= CheckHandlerID)
+  TrapBBs.resize(CheckHandlerID + 1);
+llvm::BasicBlock * = TrapBBs[CheckHandlerID];
+
+if (!CGM.getCodeGenOpts().OptimizationLevel || !TrapBB ||
+(CurCodeDecl && CurCodeDecl->hasAttr())) {
+  TrapBB = createBasicBlock("trap");

looks like a lot of code duplication



Comment at: clang/lib/CodeGen/CGExpr.cpp:3594
+TrapCall->addFnAttr(A);
+  }
+  TrapCall->setDoesNotReturn();

wouldn't be you issues solved with
TrapCall->setCannotMerge() here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148654/new/

https://reviews.llvm.org/D148654

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


[PATCH] D152650: [docs] Improve UndefinedBehaviorSanitizer.rst

2023-06-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/docs/UndefinedBehaviorSanitizer.rst:62
+  # -fno-sanitize=undefined nullifies the previous -fsanitize=undefined.
+  % clang -fsanitize=undefined -fno-sanitize=undefined -fsanitize=alignment a.c
+

I guess this is the good example of alignment


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152650/new/

https://reviews.llvm.org/D152650

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


[PATCH] D152412: [clang/test/CodeGen] Add test coverage for VarBypassDetector handling init statements and condition variables in switch clauses

2023-06-09 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGb03abbb537e5: [clang/test/CodeGen] Add test coverage for 
VarBypassDetector handling init… (authored by dwang, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D152412/new/

https://reviews.llvm.org/D152412

Files:
  clang/test/CodeGen/lifetime3.cpp


Index: clang/test/CodeGen/lifetime3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s   | 
FileCheck %s --implicit-check-not="call void @llvm.lifetime" 
--check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+// O2: call void @llvm.lifetime.start.p0(i64 1,
+// O2: call void @llvm.lifetime.end.p0(i64 1,
+char x;
+bar(, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: call void @llvm.lifetime.start.p0(i64 5,
+// O2: call void @llvm.lifetime.end.p0(i64 5,
+char y[5];
+bar(y, 5);
+break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+n = n;
+char x;
+bar(, 1);
+break;
+  case 2:
+bar(, 1);
+break;
+  }
+}


Index: clang/test/CodeGen/lifetime3.cpp
===
--- /dev/null
+++ clang/test/CodeGen/lifetime3.cpp
@@ -0,0 +1,43 @@
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-llvm-passes %s  | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK,O2
+// RUN: %clang_cc1 -S -emit-llvm -o - -O2 -disable-lifetime-markers %s | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK
+// RUN: %clang_cc1 -S -emit-llvm -o - -O0 %s   | FileCheck %s --implicit-check-not="call void @llvm.lifetime" --check-prefixes=CHECK 
+
+extern int bar(char *A, int n);
+
+// CHECK-LABEL: @no_switch_bypass
+extern "C" void no_switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1: {
+// O2: call void @llvm.lifetime.start.p0(i64 1,
+// O2: call void @llvm.lifetime.end.p0(i64 1,
+char x;
+bar(, 1);
+break;
+  }
+  case 2:
+n = n;
+// O2: call void @llvm.lifetime.start.p0(i64 5,
+// O2: call void @llvm.lifetime.end.p0(i64 5,
+char y[5];
+bar(y, 5);
+break;
+  }
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+}
+
+// CHECK-LABEL: @switch_bypass
+extern "C" void switch_bypass(int n) {
+  // O2: call void @llvm.lifetime.start.p0(i64 4,
+  // O2: call void @llvm.lifetime.end.p0(i64 4,
+  switch (n += 1; int b=n) {
+  case 1:
+n = n;
+char x;
+bar(, 1);
+break;
+  case 2:
+bar(, 1);
+break;
+  }
+}
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D151593: [MemProf] Clean up MemProf instrumentation pass invocation

2023-05-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Either way is fine


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151593/new/

https://reviews.llvm.org/D151593

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


[PATCH] D151593: [MemProf] Clean up MemProf instrumentation pass invocation

2023-05-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:995
 
+// TODO: Consider passing the MemoryProfileOutput to the pass builder via
+// the PGOOptions, and set this up there.

tejohnson wrote:
> vitalybuka wrote:
> > if this is registerOptimizerLastEPCallback, it can be next to other 
> > sanitizers, in addSanitizers()
> It could be, but while it uses the sanitizer common support, it isn't 
> logically a sanitizer. Is there an advantage to setting it up there?
no advantages.
it has runtime similar to sanitizer, so I rather thing about this as sanitizer 
:)



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151593/new/

https://reviews.llvm.org/D151593

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


[PATCH] D151593: [MemProf] Clean up MemProf instrumentation pass invocation

2023-05-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/BackendUtil.cpp:995
 
+// TODO: Consider passing the MemoryProfileOutput to the pass builder via
+// the PGOOptions, and set this up there.

if this is registerOptimizerLastEPCallback, it can be next to other sanitizers, 
in addSanitizers()


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D151593/new/

https://reviews.llvm.org/D151593

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


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-25 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG4498663f3de0: [AST] Initialized data after TypeSourceInfo 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3018,7 +3018,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 0, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3018,7 +3018,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 0, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-25 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added reviewers: kstoimenov, thurston.
vitalybuka added a comment.

Oh, I rerun msan bot locally and it looked like issue dissipated, but I 
probably checked wrong logs.
So I enabled -Oz on the bot, to catch more bugs, but the issue is still there 
https://lab.llvm.org/buildbot/#/builders/5/builds/33926

Let's land this trivial fix, and if owners of the AST believe the root-cause is 
different, we can investigate later.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

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


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-24 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

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


[PATCH] D150504: [AST] Construct Capture objects before use

2023-05-24 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rG8826cd57825d: [AST] Construct Capture objects before use 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150504/new/

https://reviews.llvm.org/D150504

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Stmt.cpp


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D148573: Allow -fsanitize=function on all targets

2023-05-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

These bots are broken after the patch
https://lab.llvm.org/buildbot/#/builders/77/builds/26834
https://lab.llvm.org/buildbot/#/builders/18/builds/9073


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148573/new/

https://reviews.llvm.org/D148573

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


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping, any concerns regarding this patch?
i want to make MSAN stricter on our bot by reducing -O level


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

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


[PATCH] D150504: [AST] Construct Capture objects before use

2023-05-19 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping, any concerns regarding this patch?
i want to make MSAN stricter on our bot by reducing -O level


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150504/new/

https://reviews.llvm.org/D150504

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


[PATCH] D150492: [AST] Initialize local counter

2023-05-18 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8cd04624e50: [AST] Initialize local counter (authored by 
vitalybuka).

Changed prior to commit:
  https://reviews.llvm.org/D150492?vs=521819=523292#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150492/new/

https://reviews.llvm.org/D150492

Files:
  clang/lib/Frontend/ASTUnit.cpp


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch  = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@
   /*isysroot=*/"",
   /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique(
   *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
   AST->TargetOpts, AST->Target, Counter));


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,6 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch  = *AST->HeaderInfo;
-  unsigned Counter;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
@@ -846,6 +845,7 @@
   /*isysroot=*/"",
   /*DisableValidationKind=*/disableValid, AllowASTWithCompilerErrors);
 
+  unsigned Counter = 0;
   AST->Reader->setListener(std::make_unique(
   *AST->PP, AST->Ctx.get(), *AST->HSOpts, *AST->PPOpts, *AST->LangOpts,
   AST->TargetOpts, AST->Target, Counter));
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150492: [AST] Initialize local counter

2023-05-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

ping


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150492/new/

https://reviews.llvm.org/D150492

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


[PATCH] D148785: -fsanitize=function: use type hashes instead of RTTI objects

2023-05-16 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Is possible to split the patch into smaller ones?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D148785/new/

https://reviews.llvm.org/D148785

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


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D150499#4341115 , @rjmccall wrote:

> This memory is supposed to be initialized when we copy the `TypeLoc`.  Are 
> you observing that not happening?

Yes. There is the msan report in the description.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

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


[PATCH] D150504: [AST] Construct Capture objects before use

2023-05-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Msan reports https://reviews.llvm.org/P8308
So the reason is if PointerIntPair is not properly
constructed, setPointer uses Info::updatePointer
on uninitialized value.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150504

Files:
  clang/include/clang/AST/Stmt.h
  clang/lib/AST/Stmt.cpp


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///


Index: clang/lib/AST/Stmt.cpp
===
--- clang/lib/AST/Stmt.cpp
+++ clang/lib/AST/Stmt.cpp
@@ -1345,6 +1345,11 @@
   : Stmt(CapturedStmtClass, Empty), NumCaptures(NumCaptures),
 CapDeclAndKind(nullptr, CR_Default) {
   getStoredStmts()[NumCaptures] = nullptr;
+
+  // Construct default capture objects.
+  Capture *Buffer = getStoredCaptures();
+  for (unsigned I = 0, N = NumCaptures; I != N; ++I)
+new (Buffer++) Capture();
 }
 
 CapturedStmt *CapturedStmt::Create(const ASTContext , Stmt *S,
Index: clang/include/clang/AST/Stmt.h
===
--- clang/include/clang/AST/Stmt.h
+++ clang/include/clang/AST/Stmt.h
@@ -3587,8 +3587,11 @@
 llvm::PointerIntPair VarAndKind;
 SourceLocation Loc;
 
+Capture() = default;
+
   public:
 friend class ASTStmtReader;
+friend class CapturedStmt;
 
 /// Create a new capture.
 ///
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 521847.
vitalybuka added a comment.

use 0


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D150499/new/

https://reviews.llvm.org/D150499

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3019,7 +3019,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 0, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3019,7 +3019,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 0, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150499: [AST] Initialized data after TypeSourceInfo

2023-05-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

There is no initialization of the data between allocation
and first getBeginLoc call.

llvm-project/clang/lib/AST/ASTContext.cpp:3022
llvm-project/clang/lib/AST/TypeLoc.cpp:222

Msan report https://reviews.llvm.org/P8306


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150499

Files:
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeLoc.h
  clang/lib/AST/ASTContext.cpp


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3019,7 +3019,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 255, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.


Index: clang/lib/AST/ASTContext.cpp
===
--- clang/lib/AST/ASTContext.cpp
+++ clang/lib/AST/ASTContext.cpp
@@ -3019,7 +3019,7 @@
 
   auto *TInfo =
 (TypeSourceInfo*)BumpAlloc.Allocate(sizeof(TypeSourceInfo) + DataSize, 8);
-  new (TInfo) TypeSourceInfo(T);
+  new (TInfo) TypeSourceInfo(T, DataSize);
   return TInfo;
 }
 
Index: clang/include/clang/AST/TypeLoc.h
===
--- clang/include/clang/AST/TypeLoc.h
+++ clang/include/clang/AST/TypeLoc.h
@@ -240,6 +240,11 @@
   static SourceRange getLocalSourceRangeImpl(TypeLoc TL);
 };
 
+inline TypeSourceInfo::TypeSourceInfo(QualType ty, size_t DataSize) : Ty(ty) {
+  // Init data attached to the object. See getTypeLoc.
+  memset(this + 1, 255, DataSize);
+}
+
 /// Return the TypeLoc for a type source info.
 inline TypeLoc TypeSourceInfo::getTypeLoc() const {
   // TODO: is this alignment already sufficient?
Index: clang/include/clang/AST/Type.h
===
--- clang/include/clang/AST/Type.h
+++ clang/include/clang/AST/Type.h
@@ -6640,7 +6640,7 @@
 
   QualType Ty;
 
-  TypeSourceInfo(QualType ty) : Ty(ty) {}
+  TypeSourceInfo(QualType ty, size_t DataSize); // implemented in TypeLoc.h
 
 public:
   /// Return the type wrapped by this type source info.
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D150492: [AST] Initialized local counter

2023-05-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

I assume it's optional and ReadAST does not have to set the
counter on success.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D150492

Files:
  clang/lib/Frontend/ASTUnit.cpp


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,7 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch  = *AST->HeaderInfo;
-  unsigned Counter;
+  unsigned Counter = 0;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,


Index: clang/lib/Frontend/ASTUnit.cpp
===
--- clang/lib/Frontend/ASTUnit.cpp
+++ clang/lib/Frontend/ASTUnit.cpp
@@ -822,7 +822,7 @@
   // Gather Info for preprocessor construction later on.
 
   HeaderSearch  = *AST->HeaderInfo;
-  unsigned Counter;
+  unsigned Counter = 0;
 
   AST->PP = std::make_shared(
   AST->PPOpts, AST->getDiagnostics(), *AST->LangOpts,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: compiler-rt/lib/asan_abi/asan_abi_shim.cpp:62
+void __asan_init(void) {
+assert(sizeof(uptr) == 8);
+assert(sizeof(u64) == 8);

static_assert


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143675/new/

https://reviews.llvm.org/D143675

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


[PATCH] D143467: [PowerPC] Add target feature requirement to builtins

2023-05-08 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Breaks these bots?
https://lab.llvm.org/buildbot/#/builders/18/builds/8898
https://lab.llvm.org/buildbot/#/builders/19/builds/16412


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143467/new/

https://reviews.llvm.org/D143467

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-05-01 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added 2 blocking reviewer(s): eugenis, MaskRay.
vitalybuka added a comment.

In D143675#4310734 , @rsundahl wrote:

> @kcc @eugenis @MaskRay @vitalybuka Ok to go with this? All new functionality 
> is under the added flag so not expecting any surprises. Rename 
> asabi->asan_abi as suggested.

Thanks, asan_abi LGTM.

I don't have good reasons to object that patch, but I suspect it's sub-optimal. 
But we may get a valuable expirience.

> Rather than adding a lot of conditional code to the LLVM instrumentation phase

We do this for hwasan for Android, and to some extent msan for Chromium. 
@eugenis maybe can share more info.

> Based on previous discussions about this topic, our understanding is that 
> freezing the present ABI would impose an excessive burden on other sanitizer 
> developers and for unrelated platforms.

I guess we just have no way to enforce that. A couple of buildbots with "stable 
clang" + "HEAD runtime" and "HEAD clang" + "stable runtime" which do some 
non-tivial build, e.g. clang bootstrap can enforce that. We can at list to 
enforce default set of flags.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143675/new/

https://reviews.llvm.org/D143675

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


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-04-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D143675#4281673 , @rsundahl wrote:

> @kcc @eugenis @MaskRay @vitalybuka Ok to go with this? All new functionality 
> is under the added flag so not expecting any surprises.

I don't have reasons to block this.




Comment at: clang/include/clang/Driver/Options.td:1785
HelpText<"Use default code 
inlining logic for the address sanitizer">;
+def fsanitize_address_stable_abi : Flag<["-"], "fsanitize-address-stable-abi">,
+Group,

how likely you will need thus for  other sanitizers in future
should this be rather -fsanitize-stable-abi which is ignore for now for other 
sanitizers?



Comment at: compiler-rt/lib/asabi/CMakeLists.txt:2
+# Build for the ASAN Stable ABI runtime support library.
+set(ASABI_SOURCES
+  asabi_shim.cpp

does it need to be asabi?
maybe better asan_abi, files and macro?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143675/new/

https://reviews.llvm.org/D143675

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


[PATCH] D147121: [hwasan] remove requirment for PIE

2023-04-12 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka removed 1 blocking reviewer(s): eugenis.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Feel free to land. It works on my arm linux setup.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147121/new/

https://reviews.llvm.org/D147121

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


[PATCH] D147121: [hwasan] remove requirment for PIE

2023-03-31 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka removed a reviewer: alekseyshl. vitalybuka added 1 blocking 
reviewer(s): eugenis.
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision now requires review to proceed.

I don't know why HWASAN may required pie, but @eugenis seems confident on 
D44745 . Lets give him a chance to take a look.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D147121/new/

https://reviews.llvm.org/D147121

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


[PATCH] D146603: [docs] Document -fomit-frame-pointer

2023-03-22 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: clang/include/clang/Driver/Options.td:2643
+  HelpText<"Omit the frame pointer from functions that don't need it. "
+  "Some stack unwinding cases like profilers and sanitizers may prefer 
specifying -fno-omit-frame-pointer. "
+  "On many targets -O1 and higher omit the frame pointer by default. "

Some stack unwinding cases, such as profilers and sanitizers, may prefer 
specifying the -fno-omit-frame-pointer option. On many targets, -O1 and higher 
omit the frame pointer by default.



Comment at: clang/include/clang/Driver/Options.td:2645
+  "On many targets -O1 and higher omit the frame pointer by default. "
+  "-m[no-]omit-leaf-frame-pointer takes precedence for leaf funcitons">;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,

functions


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D146603/new/

https://reviews.llvm.org/D146603

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


[PATCH] D145840: [Docs] Added -fomit-frame-pointer and -fno-omit-frame-pointer flag documentation

2023-03-21 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/include/clang/Driver/Options.td:2539
+def fno_omit_frame_pointer : Flag<["-"], "fno-omit-frame-pointer">, 
Group,
+  HelpText<"Help to produce better stack traces during debugging">;
 defm operator_names : BoolFOption<"operator-names",





Comment at: clang/include/clang/Driver/Options.td:2643
+def fomit_frame_pointer : Flag<["-"], "fomit-frame-pointer">, Group,
+  HelpText<"Used to instruct the compiler to omit the frame pointer which 
leads to smaller code size and faster execution.">;
 def fopenmp : Flag<["-"], "fopenmp">, Group, Flags<[CC1Option, 
NoArgumentUnused, FlangOption, FC1Option]>,




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145840/new/

https://reviews.llvm.org/D145840

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


[PATCH] D145822: [HWASAN][LSAN] Exclude crash-recovery-modules.m from HWASAN tests

2023-03-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

what is about detect_leaks?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145822/new/

https://reviews.llvm.org/D145822

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


[PATCH] D145822: [HWASAN][LSAN] Exclude crash-recovery-modules.m from HWASAN tests

2023-03-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/test/Index/crash-recovery-modules.m:14
 // REQUIRES: crash-recovery
 // UNSUPPORTED: libstdcxx-safe-mode
 

// UNSUPPORTED: libstdcxx-safe-mode, hwasan


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145822/new/

https://reviews.llvm.org/D145822

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


[PATCH] D145727: [HWASAN][LSAN] Disable tests which don't pass in HWASAN+LSAN mode

2023-03-09 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

non-crash ones are probable worth of investigating later


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145727/new/

https://reviews.llvm.org/D145727

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


[PATCH] D145040: Add test for Flags.data_flow_trace

2023-03-07 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG67f5b05cdcdc: Add test for Flags.data_flow_trace (authored 
by yingcong-wu, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145040/new/

https://reviews.llvm.org/D145040

Files:
  compiler-rt/lib/fuzzer/FuzzerDriver.cpp
  compiler-rt/test/fuzzer/dataflow.test


Index: compiler-rt/test/fuzzer/dataflow.test
===
--- compiler-rt/test/fuzzer/dataflow.test
+++ compiler-rt/test/fuzzer/dataflow.test
@@ -97,6 +97,11 @@
 L20_FUZZM-NEXT: F2 0001{{$}}
 L20_FUZZM-NOT: F
 
+# Don't crash with missing data_flow args.
+RUN: rm -rf %t-DFT
+RUN: %t-ThreeFunctionsTest -collect_data_flow=%t-ThreeFunctionsTestDF
+RUN: %t-ThreeFunctionsTest -data_flow_trace=%t-DFT %t/IN/FUZZMU
+
 # Test libFuzzer's built in DFT collection.
 RUN: rm -rf %t-DFT
 RUN: %t-ThreeFunctionsTest  -collect_data_flow=%t-ThreeFunctionsTestDF 
-data_flow_trace=%t-DFT %t/IN/FUZZMU
Index: compiler-rt/lib/fuzzer/FuzzerDriver.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -797,7 +797,7 @@
   if (Flags.verbosity)
 Printf("INFO: Seed: %u\n", Seed);
 
-  if (Flags.collect_data_flow && !Flags.fork &&
+  if (Flags.collect_data_flow && Flags.data_flow_trace && !Flags.fork &&
   !(Flags.merge || Flags.set_cover_merge)) {
 if (RunIndividualFiles)
   return CollectDataFlow(Flags.collect_data_flow, Flags.data_flow_trace,


Index: compiler-rt/test/fuzzer/dataflow.test
===
--- compiler-rt/test/fuzzer/dataflow.test
+++ compiler-rt/test/fuzzer/dataflow.test
@@ -97,6 +97,11 @@
 L20_FUZZM-NEXT: F2 0001{{$}}
 L20_FUZZM-NOT: F
 
+# Don't crash with missing data_flow args.
+RUN: rm -rf %t-DFT
+RUN: %t-ThreeFunctionsTest -collect_data_flow=%t-ThreeFunctionsTestDF
+RUN: %t-ThreeFunctionsTest -data_flow_trace=%t-DFT %t/IN/FUZZMU
+
 # Test libFuzzer's built in DFT collection.
 RUN: rm -rf %t-DFT
 RUN: %t-ThreeFunctionsTest  -collect_data_flow=%t-ThreeFunctionsTestDF -data_flow_trace=%t-DFT %t/IN/FUZZMU
Index: compiler-rt/lib/fuzzer/FuzzerDriver.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -797,7 +797,7 @@
   if (Flags.verbosity)
 Printf("INFO: Seed: %u\n", Seed);
 
-  if (Flags.collect_data_flow && !Flags.fork &&
+  if (Flags.collect_data_flow && Flags.data_flow_trace && !Flags.fork &&
   !(Flags.merge || Flags.set_cover_merge)) {
 if (RunIndividualFiles)
   return CollectDataFlow(Flags.collect_data_flow, Flags.data_flow_trace,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D145040: Add test for Flags.data_flow_trace

2023-03-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 503231.
vitalybuka added a comment.

test


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D145040/new/

https://reviews.llvm.org/D145040

Files:
  compiler-rt/lib/fuzzer/FuzzerDriver.cpp
  compiler-rt/test/fuzzer/dataflow.test


Index: compiler-rt/test/fuzzer/dataflow.test
===
--- compiler-rt/test/fuzzer/dataflow.test
+++ compiler-rt/test/fuzzer/dataflow.test
@@ -97,6 +97,11 @@
 L20_FUZZM-NEXT: F2 0001{{$}}
 L20_FUZZM-NOT: F
 
+# Don't crash with missing data_flow args.
+RUN: rm -rf %t-DFT
+RUN: %t-ThreeFunctionsTest -collect_data_flow=%t-ThreeFunctionsTestDF
+RUN: %t-ThreeFunctionsTest -data_flow_trace=%t-DFT %t/IN/FUZZMU
+
 # Test libFuzzer's built in DFT collection.
 RUN: rm -rf %t-DFT
 RUN: %t-ThreeFunctionsTest  -collect_data_flow=%t-ThreeFunctionsTestDF 
-data_flow_trace=%t-DFT %t/IN/FUZZMU
Index: compiler-rt/lib/fuzzer/FuzzerDriver.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -797,7 +797,7 @@
   if (Flags.verbosity)
 Printf("INFO: Seed: %u\n", Seed);
 
-  if (Flags.collect_data_flow && !Flags.fork &&
+  if (Flags.collect_data_flow && Flags.data_flow_trace && !Flags.fork &&
   !(Flags.merge || Flags.set_cover_merge)) {
 if (RunIndividualFiles)
   return CollectDataFlow(Flags.collect_data_flow, Flags.data_flow_trace,


Index: compiler-rt/test/fuzzer/dataflow.test
===
--- compiler-rt/test/fuzzer/dataflow.test
+++ compiler-rt/test/fuzzer/dataflow.test
@@ -97,6 +97,11 @@
 L20_FUZZM-NEXT: F2 0001{{$}}
 L20_FUZZM-NOT: F
 
+# Don't crash with missing data_flow args.
+RUN: rm -rf %t-DFT
+RUN: %t-ThreeFunctionsTest -collect_data_flow=%t-ThreeFunctionsTestDF
+RUN: %t-ThreeFunctionsTest -data_flow_trace=%t-DFT %t/IN/FUZZMU
+
 # Test libFuzzer's built in DFT collection.
 RUN: rm -rf %t-DFT
 RUN: %t-ThreeFunctionsTest  -collect_data_flow=%t-ThreeFunctionsTestDF -data_flow_trace=%t-DFT %t/IN/FUZZMU
Index: compiler-rt/lib/fuzzer/FuzzerDriver.cpp
===
--- compiler-rt/lib/fuzzer/FuzzerDriver.cpp
+++ compiler-rt/lib/fuzzer/FuzzerDriver.cpp
@@ -797,7 +797,7 @@
   if (Flags.verbosity)
 Printf("INFO: Seed: %u\n", Seed);
 
-  if (Flags.collect_data_flow && !Flags.fork &&
+  if (Flags.collect_data_flow && Flags.data_flow_trace && !Flags.fork &&
   !(Flags.merge || Flags.set_cover_merge)) {
 if (RunIndividualFiles)
   return CollectDataFlow(Flags.collect_data_flow, Flags.data_flow_trace,
___
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits


[PATCH] D143675: Discussion: Darwin Sanitizers Stable ABI

2023-02-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Usually freezing signatures is not a big concern, we can agree to preserve 
existing functions.
The stuff like ASanStackFrameLayout is the concern. compiler and runtime must 
agree on data layout. The same for global.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D143675/new/

https://reviews.llvm.org/D143675

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


[PATCH] D142890: [clangd] Add config option for fast diagnostics mode

2023-02-23 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added subscribers: kstoimenov, vitalybuka.
vitalybuka added a comment.

One of your patches likely introduced UB 
https://lab.llvm.org/buildbot/#/builders/85/builds/14558
Can you please take a look?

FYI, @kstoimenov


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142890/new/

https://reviews.llvm.org/D142890

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG890146b19206: [WebAssembly] Initial support for reference 
type externref in clang (authored by pmatos, committed by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function ) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree  = getAnalysis().getDomTree();
@@ -111,6 +115,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,15 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM =
+  static_cast(TM);
+  const WebAssemblySubtarget *Subtarget =
+  WasmTM->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if (Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type 

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-02-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 498550.
vitalybuka added a comment.

clang-format


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function ) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree  = getAnalysis().getDomTree();
@@ -111,6 +115,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,15 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM =
+  static_cast(TM);
+  const WebAssemblySubtarget *Subtarget =
+  WasmTM->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if (Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext ) {
+  // opaque pointer in addrspace(10)
+  static PointerType *Ty = PointerType::get(C, 10);
+  return Ty;
+}
+
+Type *Type::getWasm_FuncrefTy(LLVMContext ) {
+  // 

[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-02-10 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D122215#4118516 , @asb wrote:

> @pmatos and I have tried and failed to reproduce the assert in the stage3 
> msan build locally (both of us on separate machines, different environments). 
> We've reached out to @vitalybuka via email for any help in reproducing, 
> because we're somewhat stumped at the moment.

I will try to reproduce on fresh VM and reply to you with details.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

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


[PATCH] D122215: [WebAssembly] Initial support for reference type externref in clang

2023-02-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 494999.
vitalybuka added a comment.

as reverted


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D122215/new/

https://reviews.llvm.org/D122215

Files:
  clang/include/clang/AST/ASTContext.h
  clang/include/clang/AST/Type.h
  clang/include/clang/AST/TypeProperties.td
  clang/include/clang/Basic/BuiltinsWebAssembly.def
  clang/include/clang/Basic/DiagnosticSemaKinds.td
  clang/include/clang/Basic/WebAssemblyReferenceTypes.def
  clang/include/clang/Sema/Sema.h
  clang/include/clang/Serialization/ASTBitCodes.h
  clang/include/clang/module.modulemap
  clang/lib/AST/ASTContext.cpp
  clang/lib/AST/ASTImporter.cpp
  clang/lib/AST/ExprConstant.cpp
  clang/lib/AST/ItaniumMangle.cpp
  clang/lib/AST/MicrosoftMangle.cpp
  clang/lib/AST/NSAPI.cpp
  clang/lib/AST/PrintfFormatString.cpp
  clang/lib/AST/Type.cpp
  clang/lib/AST/TypeLoc.cpp
  clang/lib/CodeGen/CGBuiltin.cpp
  clang/lib/CodeGen/CGDebugInfo.cpp
  clang/lib/CodeGen/CGDebugInfo.h
  clang/lib/CodeGen/CodeGenTypes.cpp
  clang/lib/CodeGen/ItaniumCXXABI.cpp
  clang/lib/CodeGen/TargetInfo.cpp
  clang/lib/CodeGen/TargetInfo.h
  clang/lib/Index/USRGeneration.cpp
  clang/lib/Sema/Sema.cpp
  clang/lib/Sema/SemaChecking.cpp
  clang/lib/Sema/SemaDecl.cpp
  clang/lib/Sema/SemaExpr.cpp
  clang/lib/Sema/SemaType.cpp
  clang/lib/Serialization/ASTCommon.cpp
  clang/lib/Serialization/ASTReader.cpp
  clang/test/CodeGen/WebAssembly/wasm-externref.c
  clang/test/CodeGen/builtins-wasm.c
  clang/test/CodeGenCXX/wasm-reftypes-mangle.cpp
  clang/test/CodeGenCXX/wasm-reftypes-typeinfo.cpp
  clang/test/Sema/wasm-refs.c
  clang/test/SemaCXX/wasm-refs.cpp
  clang/test/SemaTemplate/address_space-dependent.cpp
  clang/tools/libclang/CIndex.cpp
  llvm/include/llvm/IR/Type.h
  llvm/include/llvm/Transforms/Utils.h
  llvm/lib/CodeGen/ValueTypes.cpp
  llvm/lib/IR/Type.cpp
  llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
  llvm/lib/Transforms/Utils/Mem2Reg.cpp

Index: llvm/lib/Transforms/Utils/Mem2Reg.cpp
===
--- llvm/lib/Transforms/Utils/Mem2Reg.cpp
+++ llvm/lib/Transforms/Utils/Mem2Reg.cpp
@@ -74,15 +74,19 @@
 struct PromoteLegacyPass : public FunctionPass {
   // Pass identification, replacement for typeid
   static char ID;
+  bool ForcePass; /// If true, forces pass to execute, instead of skipping.
 
-  PromoteLegacyPass() : FunctionPass(ID) {
+  PromoteLegacyPass() : FunctionPass(ID), ForcePass(false) {
+initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
+  }
+  PromoteLegacyPass(bool IsForced) : FunctionPass(ID), ForcePass(IsForced) {
 initializePromoteLegacyPassPass(*PassRegistry::getPassRegistry());
   }
 
   // runOnFunction - To run this pass, first we calculate the alloca
   // instructions that are safe for promotion, then we promote each one.
   bool runOnFunction(Function ) override {
-if (skipFunction(F))
+if (!ForcePass && skipFunction(F))
   return false;
 
 DominatorTree  = getAnalysis().getDomTree();
@@ -111,6 +115,6 @@
 false, false)
 
 // createPromoteMemoryToRegister - Provide an entry point to create this pass.
-FunctionPass *llvm::createPromoteMemoryToRegisterPass() {
-  return new PromoteLegacyPass();
+FunctionPass *llvm::createPromoteMemoryToRegisterPass(bool IsForced) {
+  return new PromoteLegacyPass(IsForced);
 }
Index: llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
===
--- llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
+++ llvm/lib/Target/WebAssembly/WebAssemblyTargetMachine.cpp
@@ -16,6 +16,7 @@
 #include "TargetInfo/WebAssemblyTargetInfo.h"
 #include "Utils/WebAssemblyUtilities.h"
 #include "WebAssembly.h"
+#include "WebAssemblyISelLowering.h"
 #include "WebAssemblyMachineFunctionInfo.h"
 #include "WebAssemblyTargetObjectFile.h"
 #include "WebAssemblyTargetTransformInfo.h"
@@ -464,6 +465,14 @@
 }
 
 void WebAssemblyPassConfig::addISelPrepare() {
+  WebAssemblyTargetMachine *WasmTM = static_cast(TM);
+  const WebAssemblySubtarget *Subtarget = WasmTM
+->getSubtargetImpl(std::string(WasmTM->getTargetCPU()),
+   std::string(WasmTM->getTargetFeatureString()));
+  if(Subtarget->hasReferenceTypes()) {
+// We need to remove allocas for reference types
+addPass(createPromoteMemoryToRegisterPass(true));
+  }
   // Lower atomics and TLS if necessary
   addPass(new CoalesceFeaturesAndStripAtomics(()));
 
Index: llvm/lib/IR/Type.cpp
===
--- llvm/lib/IR/Type.cpp
+++ llvm/lib/IR/Type.cpp
@@ -306,6 +306,18 @@
   return getInt64Ty(C)->getPointerTo(AS);
 }
 
+Type *Type::getWasm_ExternrefTy(LLVMContext ) {
+  // opaque pointer in addrspace(10)
+  static PointerType *Ty = PointerType::get(C, 10);
+  return Ty;
+}
+
+Type *Type::getWasm_FuncrefTy(LLVMContext ) {
+  // 

[PATCH] D142233: [Clang][OpenMP] Bail out early if `Scope` is nullptr in case of any crash

2023-01-20 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Fails on this bot 
https://lab.llvm.org/buildbot/#/builders/5/builds/30884/steps/13/logs/stdio
https://reviews.llvm.org/D142233


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D142233/new/

https://reviews.llvm.org/D142233

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


[PATCH] D139114: [Clang][Sema] Enabled implicit conversion warning for CompoundAssignment operator.

2023-01-13 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

https://lab.llvm.org/buildbot/#/builders/37/builds/19499


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139114/new/

https://reviews.llvm.org/D139114

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


[PATCH] D137838: [Support] Move TargetParsers to new component

2022-12-28 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

This bot is broken after the patch 
https://lab.llvm.org/buildbot/#/builders/236/builds/1480


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137838/new/

https://reviews.llvm.org/D137838

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


[PATCH] D140543: [clang-format] Add an option to format integer literal separators

2022-12-25 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka reopened this revision.
vitalybuka added a comment.
This revision is now accepted and ready to land.

Introduces memory bugs:
https://lab.llvm.org/buildbot/#/builders/5/builds/30234
https://lab.llvm.org/buildbot/#/builders/236/builds/1556


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D140543/new/

https://reviews.llvm.org/D140543

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


[PATCH] D129448: [CodeGen][Asan] Emit lifetime intrinsic for bypassed label

2022-12-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added a comment.
This revision now requires changes to proceed.

Abandon?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D129448/new/

https://reviews.llvm.org/D129448

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


[PATCH] D115103: Leak Sanitizer port to Windows

2022-12-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

You probably can try to finish pure lsan, and then get back to lsan+asan.
So if you continue to work please send smaller and ready pieces for review?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

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


[PATCH] D125195: [asan][ARMCXXABI] Added missing asan poison array cookie hooks.

2022-12-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: Enna1.

Is this still relevant?
If so, I would recommend to split ItaniumCXXABI from asan changes.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D125195/new/

https://reviews.llvm.org/D125195

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


[PATCH] D115103: Leak Sanitizer port to Windows

2022-12-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: Enna1.

Is this still relevant?


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D115103/new/

https://reviews.llvm.org/D115103

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


[PATCH] D119621: [SanitizerCoverage] Add instrumentation callbacks for FP cmp instructions

2022-12-07 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka requested changes to this revision.
vitalybuka added a comment.
This revision now requires changes to proceed.
Herald added a subscriber: Enna1.

Please update if it's still relevant


CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119621/new/

https://reviews.llvm.org/D119621

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


[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Vitaly Buka via Phabricator via cfe-commits
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
vitalybuka marked an inline comment as done.
Closed by commit rG166c8cccde01: [msan][CodeGen] Set noundef for C return value 
(authored by vitalybuka).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139296/new/

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule , QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)
@@ -1818,7 +1825,6 @@
   // Try to respect what the programmer intended.
   return Module.getCodeGenOpts().StrictReturn ||
  !Module.MayDropFunctionReturn(Module.getContext(), RetTy) ||
- Module.getLangOpts().Sanitize.has(SanitizerKind::Memory) ||
  Module.getLangOpts().Sanitize.has(SanitizerKind::Return);
 }
 


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ 

[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka marked an inline comment as done.
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGCall.cpp:1828
  !Module.MayDropFunctionReturn(Module.getContext(), RetTy) ||
  Module.getLangOpts().Sanitize.has(SanitizerKind::Memory) ||
  Module.getLangOpts().Sanitize.has(SanitizerKind::Return);

aeubanks wrote:
> should this be dropped? and maybe also move up `SanitizerKind::Return`?
Documentation for SanitizerKind::Return explicitly states that it's C++ check.
So I will leave it as is.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139296/new/

https://reviews.llvm.org/D139296

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


[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 480335.
vitalybuka added a comment.

remove redundant check


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139296/new/

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule , QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)
@@ -1818,7 +1825,6 @@
   // Try to respect what the programmer intended.
   return Module.getCodeGenOpts().StrictReturn ||
  !Module.MayDropFunctionReturn(Module.getContext(), RetTy) ||
- Module.getLangOpts().Sanitize.has(SanitizerKind::Memory) ||
  Module.getLangOpts().Sanitize.has(SanitizerKind::Return);
 }
 


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg [[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 

[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-05 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D139296#3972142 , @kda wrote:

> Is there a risk of this being too strict for standard C?
>
> Should there be a test case for our specific problem?  (C calling C++)

Probably not. It's cross module mismatch. To reproduce we need two module and 
one of them will do about the same as the current msan-param-retval.c.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139296/new/

https://reviews.llvm.org/D139296

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


[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 479992.
vitalybuka added a comment.

new line


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139296/new/

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule , QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
-// CHECK: }
\ No newline at end of file
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
+// CHECK: }
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg [[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull [[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull [[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, !dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg [[DBG23:![0-9]+]]
+// 

[PATCH] D139296: [msan][CodeGen] Set noundef for C return value

2022-12-04 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka created this revision.
Herald added a project: All.
vitalybuka requested review of this revision.
Herald added a project: clang.
Herald added a subscriber: cfe-commits.

Msan needs noundef consistency between interface and implementation. If
we call C++ from C we can have noundef on C++ size, and no noundef on
caller C side, noundef implementation will not set TLS for return value,
no noundef caller will expect it. Then we have false reports in msan.

The workaround could be set TLS to zero even for noundef return values.
However if we do that always it will increase binary size by about 10%.
If we do that selectively we need to handle "address is taken"
functions, any non local functions, and probably all function which have
musttail callers. Which is still a lot.

The existing implemetation of HasStrictReturn refers to C standard as
the reason not enforcing noundef. I believe it applies only to the case
when return statement is omited. Testing on Google codebase I never see
such cases, however I've see tens of cases where C code returns actual
uninitialized variables, but we ignore that it because of "omited
return" case.

So this patch will:

1. fix false-positives with TLS missmatch.
2. detect bugs returning uninitialized variables for C as well.
3. report "omited return" cases stricted than C, which is alredy a warning and 
very likely a bug in a code anyway.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D139296

Files:
  clang/lib/CodeGen/CGCall.cpp
  clang/test/CodeGen/cleanup-destslot-simple.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
 
 int noret() {
 }
 
-// CHECK: define dso_local i32 @noret() #0 {
+// CLEAN:   define dso_local i32 @noret() #0 {   
+// NOUNDEF: define dso_local noundef i32 @noret() #0 {
 // CHECK:   %retval = alloca
+// CLEAN:@__msan_retval_tls
+// NOUNDEF_ONLY: @__msan_retval_tls
+// EAGER-NOT:@__msan_retval_tls
 // CHECK: }
\ No newline at end of file
Index: clang/test/CodeGen/cleanup-destslot-simple.c
===
--- clang/test/CodeGen/cleanup-destslot-simple.c
+++ clang/test/CodeGen/cleanup-destslot-simple.c
@@ -64,7 +64,12 @@
 // CHECK-MSAN-NEXT:[[_MSLD1:%.*]] = load i32, ptr [[TMP11]], align 4, !dbg 
[[DBG20]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 8, ptr nonnull 
[[P]]), !dbg [[DBG22:![0-9]+]]
 // CHECK-MSAN-NEXT:call void @llvm.lifetime.end.p0(i64 4, ptr nonnull 
[[X]]) #[[ATTR2]], !dbg [[DBG22]]
-// CHECK-MSAN-NEXT:store i32 [[_MSLD1]], ptr @__msan_retval_tls, align 8, 
!dbg [[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:[[_MSCMP2_NOT:%.*]] = icmp eq i32 [[_MSLD1]], 0, !dbg 
[[DBG23:![0-9]+]]
+// CHECK-MSAN-NEXT:br i1 [[_MSCMP2_NOT]], label [[TMP13:%.*]], label 
[[TMP12:%.*]], !dbg [[DBG23]], !prof [[PROF21]]
+// CHECK-MSAN:   12:
+// CHECK-MSAN-NEXT:call void @__msan_warning_noreturn() #[[ATTR3]], !dbg 
[[DBG23]]
+// CHECK-MSAN-NEXT:unreachable, !dbg [[DBG23]]
+// CHECK-MSAN:   13:
 // CHECK-MSAN-NEXT:ret i32 [[TMP8]], !dbg [[DBG23]]
 //
 // CHECK-KMSAN-LABEL: @test(
Index: clang/lib/CodeGen/CGCall.cpp
===
--- clang/lib/CodeGen/CGCall.cpp
+++ clang/lib/CodeGen/CGCall.cpp
@@ -1798,6 +1798,13 @@
 
 static bool HasStrictReturn(const CodeGenModule , QualType RetTy,
 const Decl *TargetDecl) {
+  // As-is msan can not tolerate noundef mismatch between caller and
+  // implementation. Mismatch is possible for e.g. indirect calls from C-caller
+  // into C++. Such mismatches lead to confusing false reports. To avoid
+  // expensive workaround on msan we enforce initialization event in uncommon
+  // cases where it's allowed.
+  if (Module.getLangOpts().Sanitize.has(SanitizerKind::Memory))
+return true;
   // C++ explicitly makes returning undefined values UB. C's rule only applies
   // to used values, so we never mark them noundef for now.
   if (!Module.getLangOpts().CPlusPlus)


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -23,13 +23,20 @@
   return 1;
 }
 
-// CHECK: define dso_local i32 @foo() #0 {
-// CHECK:   @__msan_retval_tls
+// CLEAN:   define dso_local i32 @foo() #0 {
+// NOUNDEF: define dso_local noundef i32 @foo() #0 {
+// CLEAN:

[PATCH] D138157: Make -fsanitize=scudo use scudo_standalone. Delete check-scudo.

2022-11-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka accepted this revision.
vitalybuka added inline comments.
This revision is now accepted and ready to land.



Comment at: llvm/docs/GwpAsan.rst:174
 
++-++
-| PerfectlyRightAlign| false   | When allocations are right-aligned, 
should we perfectly align them up to the   |
-|| | page boundary? By default (false), we 
round up allocation size to the nearest  |

how this related to the patch?



Comment at: llvm/docs/GwpAsan.rst:180
 | SampleRate | 5000| The probability (1 / SampleRate) that 
a page is selected for GWP-ASan  |
-|| | sampling. Sample rates up to (2^31 - 
1) are supported. |
+|| | sampling. Sample rates up to (2^30 - 
1) are supported. |
 
++-++

unrelated?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D138157/new/

https://reviews.llvm.org/D138157

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


[PATCH] D137992: [asan] -fsanitize-address-outline-instrumentation -> -asan-max-inline-poisoning-size=0

2022-11-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a subscriber: kstoimenov.
vitalybuka added inline comments.



Comment at: clang/lib/Driver/SanitizerArgs.cpp:1256
 
   if (AsanOutlineInstrumentation) {
 CmdArgs.push_back("-mllvm");

CC @kstoimenov 

it's maybe not the best name for flag, but the point of 
AsanOutlineInstrumentation was to reduce binary size.

for -asan-instrumentation-with-call-threshold=0 sizeof(check+asan_report) > 
sizeof(outlined_check_report), so it helps with size
for -asan-max-inline-poisoning-size=0: usually sizeof(small store/load) < 
sizeof(poisoning_callbac). It usually increases the size.

Out internal setup expects the current size saving behavior of this flag.

So to move forward we can do the following instead:
1. Create a new flag for -asan-max-inline-poisoning-size=0, e.g. 
AsanOutlinePoisoning
1. Create a clone flag for -asan-instrumentation-with-call-threshold=0, e.g. 
AsanOutlineChecks
1. We switch out build system to the clone
1. Extend (or delete) AsanOutlineInstrumentation as in this patch






Comment at: clang/lib/Driver/SanitizerArgs.cpp:1260
+CmdArgs.push_back("-mllvm");
+CmdArgs.push_back("-asan-max-inline-poisoning-size=0");
   }

For changes like this we need to update 
llvm-project/clang/test/Driver/fsanitize.c


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137992/new/

https://reviews.llvm.org/D137992

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


[PATCH] D137381: [clang][compiler-rt] Exception escape out of an non-unwinding function is an undefined behaviour

2022-11-14 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D137381#3924698 , @lebedev.ri 
wrote:

> Can someone from @Sanitizers please comment? :) @vitalybuka ? @glider ? 
> @rsmith  ?
>
> In D137381#3923911 , @MaskRay wrote:
>
>> I think improving diagnostic is useful but `-fsanitize=` is probably not a 
>> good place.

@MaskRay Seems find to me. Why do you think so?

>> Instrumenting call sites with `callq   __ubsan_handle_exception_escape@PLT` 
>> wastes code size.
>
> Can you please explain why replacing one call with another somehow makes 
> things worse?

Would be nice to see some measuraments? E.g. CTMark.

>> The functionality is better handled somewhere in libc++abi personality 
>> related code
>
> That would not be helpful, i'm not using libc++.
> It seems obviously wrong to me to require every used C++ ABI library
> to implement "some improvements", instead, you know,
> the clang irgen + clang ubsan lib.
>
> If we do this, we have native source location info for the location of the 
> call site
> out of which the exception has escaped, that causes the "abort".
> I do not know if that will be possible with less native approach.
>
> The reason i'm doing this, is because recently i had to deal with a few of 
> these bugs,
> and i never got any kind of backtrace, so the situation can't not be made 
> better.
>
>> with possible improvement to exception handling related LLVM IR.
>
>
>
>>   void bar(); void foo() { bar(); }
>>
>> `clang++ -fno-exceptions -fsanitize=exception-escape -c b.cc` does not 
>> instrument the potentially-throwing-and-propagating `bar()` so an error 
>> cannot be caught.
>
> i'm only looking at `-fexceptions` side of things, i'm not sure how
> mixing `-fno-exceptions` and `-fexceptions` code is supposed to work.

Handling this case would be usefull.

> It is not oblivious to me why not dealing with some other situation
> means we can't deal with the situation we can deal with.
>
>> However, for `-fno-exceptions` code, instrumenting every call site is going 
>> to greatly increase code size and suppress optimizations.
>
> Citation needed/define "greatly"?
> We have a single "termination" landing pad per function,
> and we seem to end up with just a single extra `jmp` per call.
> https://godbolt.org/z/Td3jWM1oh
>
> But yes, that's the known and expected nature of sanitization.
>
>> I wish that I capture the compiler and runtime behavior well in 
>> https://maskray.me/blog/2020-12-12-c++-exception-handling-abi#compiler-behavior.
>>  
>> https://discourse.llvm.org/t/catching-exceptions-while-unwinding-through-fno-exceptions-code/57151
>>  is a proposal to improve the diagnostics.
>
> Thanks. That explains current behavior, but does not tell why it must be 
> enshrined and never changed.






Comment at: clang/docs/ReleaseNotes.rst:806
+- A new Undefined Behavior Sanitizer check has been implemented:
+  ``-fsanitize-exception-escape`` (part of ``-fsanitize=undefined``),
+  which catches cases of C++ exceptions trying to unwind




Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137381/new/

https://reviews.llvm.org/D137381

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


[PATCH] D137227: [asan] Default to -fsanitize-address-use-odr-indicator for non-Windows

2022-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: llvm/lib/Transforms/Instrumentation/AddressSanitizer.cpp:777
 // Enable aliases as they should have no downside with ODR indicators.
-UsePrivateAlias(UseOdrIndicator || ClUsePrivateAlias),
-UseOdrIndicator(UseOdrIndicator || ClUseOdrIndicator),
+UsePrivateAlias(UseOdrIndicator && ClUsePrivateAlias),
+UseOdrIndicator(UseOdrIndicator && ClUseOdrIndicator),

It should be 
```
UseOdrIndicator(ClUseOdrIndicator.getNumOccurrences() > 0 ? ClUseOdrIndicator : 
UseOdrIndicator),
ClUsePrivateAlias(ClUsePrivateAlias.getNumOccurrences() > 0 ? ClUsePrivateAlias 
: UseOdrIndicator),
```

My rule of thumb is Cl flags, which are mostly for testing, must be direct and 
do exactly what was asked, even if it's not useful, and they should override 
fronted parameters.



Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D137227/new/

https://reviews.llvm.org/D137227

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


[PATCH] D136007: [clang][modules][deps] System module maps might not be affecting

2022-11-02 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added subscribers: fmayer, vitalybuka.
vitalybuka added a comment.

FYI @fmayer

Probably this patch
https://lab.llvm.org/buildbot/#/builders/237/builds/350/steps/13/logs/stdio

  -- Testing: 66920 tests, 48 workers --
  Testing:  0.. 10.. 20
  FAIL: Clang :: SemaCXX/sugar-common-types.cpp (14838 of 66920)
   TEST 'Clang :: SemaCXX/sugar-common-types.cpp' FAILED 

  Script:
  --
  : 'RUN: at line 1';   
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/bin/clang -cc1 
-internal-isystem 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/lib/clang/16.0.0/include
 -nostdsysteminc -fsyntax-only -verify 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/test/SemaCXX/sugar-common-types.cpp
 -std=c++20 -fenable-matrix -triple i686-pc-win32
  --
  Exit Code: 1
  Command Output (stderr):
  --
  ==3367002==WARNING: MemorySanitizer: use-of-uninitialized-value
  #0 0xd3ed5664 in 
clang::TemplateArgument::Profile(llvm::FoldingSetNodeID&, clang::ASTContext 
const&) const 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/TemplateBase.cpp:310:3
  #1 0xd3f77740 in clang::AutoType::Profile(llvm::FoldingSetNodeID&, 
clang::ASTContext const&, clang::QualType, clang::AutoTypeKeyword, bool, 
clang::ConceptDecl*, llvm::ArrayRef) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/Type.cpp:4532:9
  #2 0xd34ac920 in Profile 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:268:7
  #3 0xd34ac920 in Equals 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:420:3
  #4 0xd34ac920 in llvm::ContextualFoldingSet::NodeEquals(llvm::FoldingSetBase const*, 
llvm::FoldingSetBase::Node*, llvm::FoldingSetNodeID const&, unsigned int, 
llvm::FoldingSetNodeID&) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:600:12
  #5 0xcd221610 in 
llvm::FoldingSetBase::FindNodeOrInsertPos(llvm::FoldingSetNodeID const&, 
void*&, llvm::FoldingSetBase::FoldingSetInfo const&) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/lib/Support/FoldingSet.cpp:288:9
  #6 0xd3450850 in FindNodeOrInsertPos 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/llvm/include/llvm/ADT/FoldingSet.h:490:45
  #7 0xd3450850 in 
clang::ASTContext::getAutoTypeInternal(clang::QualType, clang::AutoTypeKeyword, 
bool, bool, clang::ConceptDecl*, llvm::ArrayRef, bool) 
const 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/ASTContext.cpp:5804:32
  #8 0xd3450e34 in clang::ASTContext::getAutoType(clang::QualType, 
clang::AutoTypeKeyword, bool, bool, clang::ConceptDecl*, 
llvm::ArrayRef) const 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/AST/ASTContext.cpp:5846:10
  #9 0xd2e44934 in (anonymous 
namespace)::SubstituteDeducedTypeTransform::TransformAutoType(clang::TypeLocBuilder&,
 clang::AutoTypeLoc) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4618:41
  #10 0xd2e407e4 in clang::TreeTransform<(anonymous 
namespace)::SubstituteDeducedTypeTransform>::TransformType(clang::TypeLocBuilder&,
 clang::TypeLoc) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm_build_msan/tools/clang/include/clang/AST/TypeNodes.inc:37:1
  #11 0xd2e22d94 in (anonymous 
namespace)::SubstituteDeducedTypeTransform::Apply(clang::TypeLoc) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4650:14
  #12 0xd2e225cc in clang::Sema::DeduceAutoType(clang::TypeLoc, 
clang::Expr*, clang::QualType&, clang::sema::TemplateDeductionInfo&, bool, 
bool) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaTemplateDeduction.cpp:4867:63
  #13 0xd1fd7c14 in 
clang::Sema::deduceVarTypeFromInitializer(clang::VarDecl*, 
clang::DeclarationName, clang::QualType, clang::TypeSourceInfo*, 
clang::SourceRange, bool, clang::Expr*) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12481:7
  #14 0xd1fd85d8 in 
clang::Sema::DeduceVariableDeclarationType(clang::VarDecl*, bool, clang::Expr*) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12517:26
  #15 0xd1fd99f8 in clang::Sema::AddInitializerToDecl(clang::Decl*, 
clang::Expr*, bool) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Sema/SemaDecl.cpp:12868:9
  #16 0xd1a605a8 in 
clang::Parser::ParseDeclarationAfterDeclaratorAndAttributes(clang::Declarator&, 
clang::Parser::ParsedTemplateInfo const&, clang::Parser::ForRangeInit*) 
/b/sanitizer-aarch64-linux-bootstrap-msan/build/llvm-project/clang/lib/Parse/ParseDecl.cpp:2491:17
  #17 0xd1a5a844 in 

[PATCH] D136601: [OpenMP] [OMPIRBuilder] Create a new datatype to hold the unique target region info

2022-10-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/lib/CodeGen/CGOpenMPRuntime.cpp:3031
+OrderedEntries[E.getOrder()] =
+std::make_tuple(, Loc, EntryInfo.ParentName);
+ParentFunctions[E.getOrder()] = EntryInfo.ParentName;

mikerice wrote:
> Needed StringRef(EntryInfo.ParentName) for this to compile for me.
StringRef(EntryInfo.ParentName) is ref to the scope-local EntryInfo info, so 
you have HWASAN report here


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D136601/new/

https://reviews.llvm.org/D136601

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.






Comment at: clang/lib/CodeGen/CGExpr.cpp:1746
 
+  if (auto TyPtr = Ty.getTypePtrOrNull()) {
+if (!(TyPtr->isSpecificBuiltinType(BuiltinType::UChar) ||

Taking into account potantial risks from pre-existing UB, I believe we need 
clang switch to be able to shutdown this branch, similar to 
enable_noundef_analysis.
User with large code bases maybe need some time for transition.

I have no opinion if this should be ON or OFF by default


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-17 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D134410#3860646 , @xbolva00 wrote:

>> I assume with this patch landed, many such cases may change code behavior. 
>> So we will need to update msan to have a tool to detect cases like this 
>> anyway.
>
> I believe that updated msan should come first.

Yes, we can do that.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-10-15 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a reviewer: vitalybuka.
vitalybuka added a comment.

In D134410#3817190 , @vitalybuka 
wrote:

>> Also I applied this patch with D134698  
>> and used on our large test set, expecting significant number of pre-existing 
>> reports. To my surprise I see not many of them.
>
> Something wrong with my msan experiment, I'll re-evaluate size and reports 
> tomorrow.

Finally I had a time to fix my msan experiment D134698 

It's about 5.5% .text savings for Msan, and 10% for msan with "track origins", 
which is pretty good.
For context, for msan it's usually cheaper to report uninitialized ASAP, then 
propagating and report it later. With this metadata it will happen immediately 
after load.

However cleanup looks scary. Msan reports maybe 20% of unique tests on our code 
base. Many a of them share root cause, but still many unique root causes.
On quick looks I see no false report. A lot of stuff like this 
https://stackoverflow.com/questions/60112841/copying-structs-with-uninitialized-members
 which is technically is UB.
I assume with this patch landed, many such cases may change code behavior. So 
we will need to update msan to have a tool to detect cases like this anyway.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D135713: [cmake][Fuchsia] Add -ftrivial-auto-var-init=zero to runtimes build

2022-10-11 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

It may help with some cases, but still does not guarantee that pointer will not 
survive in paddings or red-zones.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D135713/new/

https://reviews.llvm.org/D135713

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

> Also I applied this patch with D134698  and 
> used on our large test set, expecting significant number of pre-existing 
> reports. To my surprise I see not many of them.

Something wrong with my msan experiment, I'll re-evaluate size and reports 
tomorrow.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-27 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D134410#3817070 , @xbolva00 wrote:

> In D134410#3816918 , @vitalybuka 
> wrote:
>
>> I tried to hook this patch into MemorySanitizer and it reduces instrumented 
>> code by ~30% !
>
> Wow, amazing results!

Also I applied this patch with D134698  and 
used on out large test set, expecting significant number of pre-existing 
reports. To my surprise I see not many of them.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

I tried to hook this patch into MemorySanitizer and it reduces instrumented 
code by ~30% !


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134410: [clang][CodeGen] Add noundef metadata to load instructions (preliminary)

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

Are there patches uploaded with arc tool?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134410/new/

https://reviews.llvm.org/D134410

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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

  diff --git a/clang/test/Driver/fsanitize-memory-param-retval.c 
b/clang/test/Driver/fsanitize-memory-param-retval.c
  index d82d20812186..79ade32178b6 100644
  --- a/clang/test/Driver/fsanitize-memory-param-retval.c
  +++ b/clang/test/Driver/fsanitize-memory-param-retval.c
  @@ -1,14 +1,14 @@
  -// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  -// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  -// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  -// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  -// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target i386-gnu-linux %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target aarch64-linux-gnu %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target riscv32-linux-gnu %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target riscv64-linux-gnu %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
  +// RUN: %clang -target x86_64-linux-gnu %s -fsanitize=kernel-memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck %s
   
  -// CHECK: "-fsanitize-memory-param-retval"
  +// CHECK: "-fno-sanitize-memory-param-retval"
   
  -// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory 
-fsanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
  -// 11: "-fsanitize-memory-param-retval"
  +// RUN: %clang -target aarch64-linux-gnu -fsyntax-only %s -fsanitize=memory 
-fno-sanitize-memory-param-retval -c -### 2>&1 | FileCheck --check-prefix=11 %s
  +// 11: "-fno-sanitize-memory-param-retval"
   
  -// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s 
-fsanitize=memory -fsanitize-memory-param-retval=1 2>&1 | FileCheck 
--check-prefix=EXCESS %s
  -// EXCESS: error: unknown argument: '-fsanitize-memory-param-retval=
  +// RUN: not %clang -target x86_64-linux-gnu -fsyntax-only %s 
-fsanitize=memory -fno-sanitize-memory-param-retval=1 2>&1 | FileCheck 
--check-prefix=EXCESS %s
  +// EXCESS: error: unknown argument: '-fno-sanitize-memory-param-retval=


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134669/new/

https://reviews.llvm.org/D134669

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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka updated this revision to Diff 463058.
vitalybuka added a comment.
Herald added a subscriber: MaskRay.

Update


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134669/new/

https://reviews.llvm.org/D134669

Files:
  clang/include/clang/Driver/Options.td
  clang/include/clang/Driver/SanitizerArgs.h
  clang/lib/Driver/SanitizerArgs.cpp
  clang/test/CodeGen/kmsan-param-retval.c
  clang/test/CodeGen/msan-param-retval.c


Index: clang/test/CodeGen/msan-param-retval.c
===
--- clang/test/CodeGen/msan-param-retval.c
+++ clang/test/CodeGen/msan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o 
- %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-fno-sanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-mllvm -msan-eager-checks -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-no-enable-noundef-analysis -fsanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory 
-fsanitize-memory-param-retval -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -fsanitize=memory -o 
- %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 
 void bar(int x) {
Index: clang/test/CodeGen/kmsan-param-retval.c
===
--- clang/test/CodeGen/kmsan-param-retval.c
+++ clang/test/CodeGen/kmsan-param-retval.c
@@ -1,12 +1,12 @@
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -no-enable-noundef-analysis -o - %s | \
 // RUN: FileCheck %s --check-prefix=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -fno-sanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,NOUNDEF_ONLY
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -mllvm -msan-eager-checks -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 // RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -no-enable-noundef-analysis 
-fsanitize-memory-param-retval -o - %s | \
 // RUN: FileCheck %s --check-prefixes=CLEAN
-// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -fsanitize-memory-param-retval -o - %s | \
+// RUN: %clang_cc1 -triple x86_64-linux-gnu -S -emit-llvm -O2 
-fsanitize=kernel-memory -o - %s | \
 // RUN: FileCheck %s --check-prefixes=NOUNDEF,EAGER
 
 void foo();
Index: clang/lib/Driver/SanitizerArgs.cpp
===
--- clang/lib/Driver/SanitizerArgs.cpp
+++ clang/lib/Driver/SanitizerArgs.cpp
@@ -1184,8 +1184,8 @@
   if (MsanUseAfterDtor)
 CmdArgs.push_back("-fsanitize-memory-use-after-dtor");
 
-  if (MsanParamRetval)
-CmdArgs.push_back("-fsanitize-memory-param-retval");
+  if (!MsanParamRetval)
+CmdArgs.push_back("-fno-sanitize-memory-param-retval");
 
   // FIXME: Pass these parameters as function attributes, not as -llvm flags.
   if (!TsanMemoryAccess) {
Index: clang/include/clang/Driver/SanitizerArgs.h
===
--- clang/include/clang/Driver/SanitizerArgs.h
+++ clang/include/clang/Driver/SanitizerArgs.h
@@ -34,7 +34,7 @@
   int BinaryMetadataFeatures = 0;
   int MsanTrackOrigins = 0;
   bool MsanUseAfterDtor = true;
-  bool MsanParamRetval = false;
+  bool MsanParamRetval = true;
   bool CfiCrossDso = false;
   bool CfiICallGeneralizePointers = false;
   bool CfiCanonicalJumpTables = false;
Index: clang/include/clang/Driver/Options.td
===
--- clang/include/clang/Driver/Options.td
+++ clang/include/clang/Driver/Options.td
@@ -1767,7 +1767,7 @@
 defm sanitize_memory_param_retval
 : BoolFOption<"sanitize-memory-param-retval",
 CodeGenOpts<"SanitizeMemoryParamRetval">,
-DefaultFalse,
+DefaultTrue,
 PosFlag, NegFlag,
 BothFlags<[], " detection of uninitialized parameters and return 
values">>;
  Note: This flag was introduced when it was necessary to distinguish 
between


Index: clang/test/CodeGen/msan-param-retval.c
===
--- 

[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added inline comments.



Comment at: clang/include/clang/Driver/Options.td:1767
   MarshallingInfoEnum, "Global">;
 defm sanitize_memory_param_retval
 : BoolFOption<"sanitize-memory-param-retval",

you need to update SanitizerArgs::MsanParamRetval

SanitizerArgs.cpp:1187
```
if (!MsanParamRetval)
CmdArgs.push_back("-fno-sanitize-memory-param-retval");
```

without that option.td is no-op


Then D134683 works with and without your patch


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134669/new/

https://reviews.llvm.org/D134669

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


[PATCH] D134669: [clang][msan] Turn on -fsanitize-memory-param-retval by default

2022-09-26 Thread Vitaly Buka via Phabricator via cfe-commits
vitalybuka added a comment.

In D134669#3816519 , @aeubanks wrote:

> do you want the tests to all properly work with 
> -fsanitize-memory-param-retval, or just pin them to 
> -fno-sanitize-memory-param-retval if they're failing?

I have some draft patch for D134683 .


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D134669/new/

https://reviews.llvm.org/D134669

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


  1   2   3   4   5   6   7   8   >