[PATCH] CFE Knob for: Add a thread-model knob for lowering atomics on baremetal & single threaded systems

Jon Roelofs jonathan at codesourcery.com
Fri Aug 29 10:26:49 PDT 2014


================
Comment at: lib/CodeGen/BackendUtil.cpp:422-429
@@ -421,1 +421,10 @@
 
+  if (CodeGenOpts.ThreadModel == "posix")
+    Options.ThreadModel = llvm::ThreadModel::POSIX;
+  else if (CodeGenOpts.ThreadModel == "single")
+    Options.ThreadModel = llvm::ThreadModel::Single;
+  else {
+    assert(false && "Invalid Thread model!");
+    Options.ThreadModel = llvm::ThreadModel::POSIX;
+  }
+
----------------
majnemer wrote:
> You may want to consider using LLVM's [[ http://llvm.org/docs/doxygen/html/classllvm_1_1StringSwitch.html#details | StringSwitch ]] here.
I considered it, but Stringswitch wouldn't let me assert that every case was handled.

================
Comment at: lib/CodeGen/BackendUtil.cpp:427
@@ +426,3 @@
+  else {
+    assert(false && "Invalid Thread model!");
+    Options.ThreadModel = llvm::ThreadModel::POSIX;
----------------
majnemer wrote:
> This assertion doesn't look too useful.
That's "fail, but don't let users read undefined values if asserts are turned off".

http://reviews.llvm.org/D4985






More information about the cfe-commits mailing list