[compiler-rt] 797fe59 - [tsan] Fix GCC 8.3 build after D107911

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 16 16:18:50 PDT 2021


Author: Vitaly Buka
Date: 2021-08-16T16:18:42-07:00
New Revision: 797fe59e6b9512652c0ae5a6b69a3c6f5a573fcd

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

LOG: [tsan] Fix GCC 8.3 build after D107911

gcc 8.3 reports:
__tsan::v3::Event::type’ is too small to hold all values of ‘enum class __tsan::v3::EventType’

Added: 
    

Modified: 
    compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
    compiler-rt/lib/tsan/rtl/tsan_trace.h

Removed: 
    


################################################################################
diff  --git a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
index 49e867a63aa92..db5070180442a 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
+++ b/compiler-rt/lib/tsan/rtl/tsan_rtl_report.cpp
@@ -472,7 +472,7 @@ void TraceReplay(Trace *trace, TracePart *last, Event *last_pos, Sid sid,
     for (Event *evp = &part->events[0]; evp < end; evp++) {
       Event *evp0 = evp;
       if (!evp->is_access && !evp->is_func) {
-        switch (evp->type) {
+        switch (evp->GetType()) {
           case EventType::kTime: {
             auto *ev = reinterpret_cast<EventTime *>(evp);
             ev_sid = static_cast<Sid>(ev->sid);
@@ -573,7 +573,7 @@ bool RestoreStack(Tid tid, EventType type, Sid sid, Epoch epoch, uptr addr,
       [&](Sid ev_sid, Epoch ev_epoch, Event *evp) {
         bool match = ev_sid == sid && ev_epoch == epoch;
         if (evp->is_access) {
-          if (evp->is_func == 0 && evp->type == EventType::kAccessExt &&
+          if (evp->is_func == 0 && evp->GetType() == EventType::kAccessExt &&
               evp->_ == 0)  // NopEvent
             return;
           auto *ev = reinterpret_cast<EventAccess *>(evp);
@@ -602,7 +602,7 @@ bool RestoreStack(Tid tid, EventType type, Sid sid, Epoch epoch, uptr addr,
           }
           return;
         }
-        switch (evp->type) {
+        switch (evp->GetType()) {
           case EventType::kAccessExt: {
             auto *ev = reinterpret_cast<EventAccessExt *>(evp);
             uptr ev_addr = RestoreAddr(ev->addr);

diff  --git a/compiler-rt/lib/tsan/rtl/tsan_trace.h b/compiler-rt/lib/tsan/rtl/tsan_trace.h
index a771ad9f52fd3..b48810aa82a1c 100644
--- a/compiler-rt/lib/tsan/rtl/tsan_trace.h
+++ b/compiler-rt/lib/tsan/rtl/tsan_trace.h
@@ -87,13 +87,17 @@ struct Event {
   // Otherwise type denotes the type.
   u64 is_access : 1;
   u64 is_func : 1;
-  EventType type : 3;
+  u64 type : 3;
   u64 _ : 59;
+
+  EventType GetType() const {
+    return static_cast<EventType>(type);
+  }
 };
 static_assert(sizeof(Event) == 8, "bad Event size");
 
 // Nop event used as padding and does not affect state during replay.
-static constexpr Event NopEvent = {1, 0, EventType::kAccessExt, 0};
+static constexpr Event NopEvent = {1, 0, static_cast<u64>(EventType::kAccessExt), 0};
 
 // Compressed memory access can represent only some events with PCs
 // close enough to each other. Otherwise we fall back to EventAccessExt.


        


More information about the llvm-commits mailing list