[PATCH] D34299: [ubsan] Improve diagnostics for return value checks (clang)

Filipe Cabecinhas via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Jun 22 05:35:10 PDT 2017


filcab added a comment.

Splitting the attrloc from the useloc might make sense since we would be able to emit attrloc just once. But I don't see why we need to store/load those pointers in runtime instead of just caching the `Constant*` in `CodeGenFunction`.
I'd also like to have some asserts and explicit resets to `nullptr` after use on the `ReturnLocation` variable, if possible.



================
Comment at: lib/CodeGen/CGStmt.cpp:1035
+    assert(ReturnLocation.isValid() && "No valid return location");
+    Builder.CreateStore(Builder.CreateBitCast(SLocPtr, Int8PtrTy),
+                        ReturnLocation);
----------------
Can't you just keep the `Constant*` around and use it later for the static data? Instead of creating a global var and have runtime store/load?


================
Comment at: lib/CodeGen/CodeGenFunction.h:1412
+  /// source location for diagnostics.
+  Address ReturnLocation = Address::invalid();
+
----------------
Maybe `CurrentReturnLocation`?


https://reviews.llvm.org/D34299





More information about the cfe-commits mailing list