modocache created this revision.
modocache added reviewers: GorNishanov, vsk, eric_niebler, lewissbaker.

As explained in http://lists.llvm.org/pipermail/llvm-dev/2018-March/121924.html,
the LLVM coroutines transforms are not yet able to move the
instructions for UBSan null checking past coroutine suspend boundaries.
For now, disable all UBSan checks when generating code for coroutines
functions.

I also considered an approach where only '-fsanitize=null' would be disabled,
However in practice this led to other LLVM errors when writing object files:
"Cannot represent a difference across sections". For now, disable all
UBSan checks until coroutine transforms are updated to handle them.

Test Plan:

1. check-clang
2. Compile the program in 
https://gist.github.com/modocache/54a036c3bf9c06882fe85122e105d153 using the 
'-fsanitize=null' option and confirm it does not crash during LLVM IR 
generation.


Repository:
  rC Clang

https://reviews.llvm.org/D44672

Files:
  lib/CodeGen/CodeGenFunction.cpp


Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1298,6 +1298,14 @@
 
   Stmt *Body = FD->getBody();
 
+  // TODO: As mentioned in the TODO added in https://reviews.llvm.org/rL280678,
+  // coro-split is not capable of moving spills whose users' users are not
+  // dominated by 'llvm.coro.begin'. '-fsanitize=null', for example, generates
+  // such code: null checks that occur before 'llvm.coro.begin'. For now,
+  // disable UBSan checks within coroutine function bodies.
+  if (Body && Body->getStmtClass() == Stmt::CoroutineBodyStmtClass)
+    SanOpts.clear();
+
   // Initialize helper which will detect jumps which can cause invalid lifetime
   // markers.
   if (Body && ShouldEmitLifetimeMarkers)


Index: lib/CodeGen/CodeGenFunction.cpp
===================================================================
--- lib/CodeGen/CodeGenFunction.cpp
+++ lib/CodeGen/CodeGenFunction.cpp
@@ -1298,6 +1298,14 @@
 
   Stmt *Body = FD->getBody();
 
+  // TODO: As mentioned in the TODO added in https://reviews.llvm.org/rL280678,
+  // coro-split is not capable of moving spills whose users' users are not
+  // dominated by 'llvm.coro.begin'. '-fsanitize=null', for example, generates
+  // such code: null checks that occur before 'llvm.coro.begin'. For now,
+  // disable UBSan checks within coroutine function bodies.
+  if (Body && Body->getStmtClass() == Stmt::CoroutineBodyStmtClass)
+    SanOpts.clear();
+
   // Initialize helper which will detect jumps which can cause invalid lifetime
   // markers.
   if (Body && ShouldEmitLifetimeMarkers)
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
  • [PATCH] D44672: [CodeGen] Dis... Brian Gesiak via Phabricator via cfe-commits

Reply via email to