[PATCH] D15208: Patch for inline abort code generation

Alexey Samsonov via cfe-commits cfe-commits at lists.llvm.org
Wed Dec 9 13:22:57 PST 2015


samsonov added a comment.

Please consider adding a test case.


================
Comment at: include/clang/Basic/LangOptions.h:95
@@ -94,1 +94,3 @@
 
+  /// \brief Flag controlling whether or not trap calls are merged
+  /// at the end of each function.
----------------
Why is it a language, not codegen option?

================
Comment at: include/clang/Basic/LangOptions.h:97
@@ +96,3 @@
+  /// at the end of each function.
+  bool mergeTraps;
+
----------------
MergeTraps

================
Comment at: include/clang/Driver/Options.td:614
@@ +613,3 @@
+def fno_sanitize_merge_traps : Flag<["-"], "fno-sanitize-merge-traps">, 
+                               Group<f_clang_Group>,
+                               HelpText<"Generate traps for sanitizers inline to aid in debugging.">; 
----------------
These should probably be CC1Option as well.

================
Comment at: lib/CodeGen/CGExpr.cpp:2543
@@ +2542,3 @@
+  // RE: Bug: 25682
+  if(!getLangOpts().mergeTraps) {
+      llvm::InlineAsm *EmptyAsm = llvm::InlineAsm::get(llvm::FunctionType::get(CGM.VoidTy, false), 
----------------
Note that this will also affect `-ftrapv`, which might be unexpected, as we mention "sanitize" in the flag name.

================
Comment at: lib/CodeGen/CGExpr.cpp:2549
@@ +2548,3 @@
+      EmitBlock(TrapBB);
+      llvm::CallInst *TrapCall = EmitTrapCall(llvm::Intrinsic::trap);
+      TrapCall->setDoesNotReturn();
----------------
Looks like most of this block (everything except for the empty asm statement) is duplicated below.

================
Comment at: lib/Frontend/CompilerInvocation.cpp:1572
@@ -1571,1 +1571,3 @@
 
+  if (Args.hasArg(OPT_fno_sanitize_merge_traps)) {
+    Opts.mergeTraps = false;
----------------
  Args.hasFlag(OPT_fsanitize_merge_traps, OPT_fno_sanitize_merge_traps, true);


Repository:
  rL LLVM

http://reviews.llvm.org/D15208





More information about the cfe-commits mailing list