[PATCH] D118712: [HWASan] Properly handle musttail calls.
Matt Morehouse via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 1 11:17:17 PST 2022
morehouse updated this revision to Diff 405014.
morehouse marked an inline comment as done.
morehouse added a comment.
- Use a single `isa<Type0, Type1>`.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D118712/new/
https://reviews.llvm.org/D118712
Files:
compiler-rt/test/hwasan/TestCases/musttail.cpp
llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
Index: llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
===================================================================
--- llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
+++ llvm/lib/Transforms/Instrumentation/HWAddressSanitizer.cpp
@@ -1531,9 +1531,14 @@
}
}
- if (isa<ReturnInst>(Inst) || isa<ResumeInst>(Inst) ||
- isa<CleanupReturnInst>(Inst))
+ if (isa<ReturnInst>(Inst)) {
+ if (CallInst *CI = Inst.getParent()->getTerminatingMustTailCall())
+ RetVec.push_back(CI);
+ else
+ RetVec.push_back(&Inst);
+ } else if (isa<ResumeInst, CleanupReturnInst>(Inst)) {
RetVec.push_back(&Inst);
+ }
if (auto *DVI = dyn_cast<DbgVariableIntrinsic>(&Inst)) {
for (Value *V : DVI->location_ops()) {
Index: compiler-rt/test/hwasan/TestCases/musttail.cpp
===================================================================
--- /dev/null
+++ compiler-rt/test/hwasan/TestCases/musttail.cpp
@@ -0,0 +1,13 @@
+// RUN: %clangxx_hwasan -mllvm -hwasan-use-stack-safety=0 %s -o %t
+// RUN: %run %t
+//
+// REQUIRES: pointer-tagging
+
+__attribute__((noinline)) int bar(int X) { return X; }
+
+__attribute__((noinline)) int foo(int X) {
+ volatile int A = 5;
+ [[clang::musttail]] return bar(X + A);
+}
+
+int main(int Argc, char *Argv[]) { return foo(Argc) != 6; }
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118712.405014.patch
Type: text/x-patch
Size: 1379 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220201/960ba213/attachment.bin>
More information about the llvm-commits
mailing list