This revision was automatically updated to reflect the committed changes. Closed by commit rG9e1ccec8d529: tsan: don't instrument __attribute__((naked)) functions (authored by AntonBikineev).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D77477/new/ https://reviews.llvm.org/D77477 Files: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll =================================================================== --- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll +++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll @@ -78,5 +78,18 @@ call void @SwiftError(i8** %0) ret void } + +; CHECK-LABEL: @NakedTest(i32* %a) +; CHECK-NEXT: call void @foo() +; CHECK-NEXT: %tmp1 = load i32, i32* %a, align 4 +; CHECK-NEXT: ret i32 %tmp1 +define i32 @NakedTest(i32* %a) naked sanitize_thread { + call void @foo() + %tmp1 = load i32, i32* %a, align 4 + ret i32 %tmp1 +} + +declare void @foo() nounwind + ; CHECK: define internal void @tsan.module_ctor() ; CHECK: call void @__tsan_init() Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -441,6 +441,11 @@ // the module constructor. if (F.getName() == kTsanModuleCtorName) return false; + // Naked functions can not have prologue/epilogue + // (__tsan_func_entry/__tsan_func_exit) generated, so don't instrument them at + // all. + if (F.hasFnAttribute(Attribute::Naked)) + return false; initialize(*F.getParent()); SmallVector<Instruction*, 8> AllLoadsAndStores; SmallVector<Instruction*, 8> LocalLoadsAndStores;
Index: llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll =================================================================== --- llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll +++ llvm/test/Instrumentation/ThreadSanitizer/tsan_basic.ll @@ -78,5 +78,18 @@ call void @SwiftError(i8** %0) ret void } + +; CHECK-LABEL: @NakedTest(i32* %a) +; CHECK-NEXT: call void @foo() +; CHECK-NEXT: %tmp1 = load i32, i32* %a, align 4 +; CHECK-NEXT: ret i32 %tmp1 +define i32 @NakedTest(i32* %a) naked sanitize_thread { + call void @foo() + %tmp1 = load i32, i32* %a, align 4 + ret i32 %tmp1 +} + +declare void @foo() nounwind + ; CHECK: define internal void @tsan.module_ctor() ; CHECK: call void @__tsan_init() Index: llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp =================================================================== --- llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp +++ llvm/lib/Transforms/Instrumentation/ThreadSanitizer.cpp @@ -441,6 +441,11 @@ // the module constructor. if (F.getName() == kTsanModuleCtorName) return false; + // Naked functions can not have prologue/epilogue + // (__tsan_func_entry/__tsan_func_exit) generated, so don't instrument them at + // all. + if (F.hasFnAttribute(Attribute::Naked)) + return false; initialize(*F.getParent()); SmallVector<Instruction*, 8> AllLoadsAndStores; SmallVector<Instruction*, 8> LocalLoadsAndStores;
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits