teak-llvm/clang/test/CodeGen/attr-speculative-load-hardening.cpp
Zola Bridges cbac3ad122 [clang][slh] add attribute for speculative load hardening
Summary:
Resubmit this with no changes because I think the build was broken
by a different diff.
-----
The prior diff had to be reverted because there were two tests
that failed. I updated the two tests in this diff

clang/test/Misc/pragma-attribute-supported-attributes-list.test
clang/test/SemaCXX/attr-speculative-load-hardening.cpp

----- Summary from Previous Diff (Still Accurate) -----

LLVM IR already has an attribute for speculative_load_hardening. Before
this commit, when a user passed the -mspeculative-load-hardening flag to
Clang, every function would have this attribute added to it. This Clang
attribute will allow users to opt into SLH on a function by function basis.

This can be applied to functions and Objective C methods.

Reviewers: chandlerc, echristo, kristof.beyls, aaron.ballman

Subscribers: llvm-commits

Differential Revision: https://reviews.llvm.org/D54915

llvm-svn: 347701
2018-11-27 19:56:46 +00:00

19 lines
657 B
C++

// RUN: %clang_cc1 -std=c++11 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK1
// RUN: %clang_cc1 -std=c++11 -disable-llvm-passes -emit-llvm %s -o - | FileCheck %s --check-prefix=CHECK2
//
// Check that we set the attribute on each function.
[[clang::speculative_load_hardening]]
int test1() {
return 42;
}
int __attribute__((speculative_load_hardening)) test2() {
return 42;
}
// CHECK1: @{{.*}}test1{{.*}}[[SLH1:#[0-9]+]]
// CHECK1: attributes [[SLH1]] = { {{.*}}speculative_load_hardening{{.*}} }
// CHECK2: @{{.*}}test2{{.*}}[[SLH2:#[0-9]+]]
// CHECK2: attributes [[SLH2]] = { {{.*}}speculative_load_hardening{{.*}} }